# coding:utf-8 import sys Input = [] while True: line = sys.stdin.readline() if not line: break Input.append(line.split('\n')) num = Input.pop(0) node = [] for i in xrange(len(Input)): node.append(Input[i][0].split(' ')) print node # 建立树节点字典 shu_dict = {} for i in xrange(len(node)): shu_dict[int(node[i][1])] = int(node[i][0]) all_high = [] if num == 1: print 1 else: for key in shu_dict.keys(): high = 2 while shu_dict[key] != 0: high += 1 key = shu_dict[key] all_high.append(high) print max(all_high)
点赞 评论

相关推荐

M_bao:换个排版吧哥们,看着费劲
点赞 评论 收藏
分享
lxylxy_:其实是美团卷起来了
点赞 评论 收藏
分享
牛客网
牛客企业服务