求一个大佬指点迷津,AC3题,最后两题自测全过了,但是提交之后都是0分
第四题 自测过了 但是超时了
import sys n,k = map(lambda x: int(x), sys.stdin.readline().strip().split()) li st_ = [] count = 0 for i in range(n): t = list(map(lambda x: int(x), sys.stdin.readline().strip().split())) list_.append(t) for i in range(n-1): for j in range(i+1,n,1): temp=list(map(lambda x :x[0]+x[1] ,zip(list_[i], list_[j]))) if len(set(temp)) == 1: count += 1 print(count)第五题 自测过了 但是提交之后是0分
import sys T = int(sys.stdin.readline().strip()) output = [] for i in range(T): n = int(sys.stdin.readline().strip()) dict1 = {} for j in range(n): temp_list = list(map(lambda x: int(x),sys.stdin.readline().strip().split())) m = temp_list[0] t = temp_list[1] dict1[m] = dict1.get(m, set([m])) dict1[m].add(t) dict1[t] = dict1.get(t, set([t])) dict1[t].add(m) max_len = 0 for item in dict1.items(): tempset = set() for temp in item[1]: tempset = tempset|set(dict1[temp]) max_len = max(max_len,len(tempset)) output.append(max_len) for out in output: print(out)
全部评论
(14) 回帖