Submission #88585

#TimeUsernameProblemLanguageResultExecution timeMemory
88585GogotchuriTriumphal arch (POI13_luk)Cpython 3
60 / 100
2068 ms68364 KiB
import sys sys.setrecursionlimit(200000) def depth_first(h, p, t, ls, memo): memo[h] = t - len(ls[h]) memo[h] += 0 if p == 0 else 1 for elem in ls[h]: if elem == p: continue depth_first(elem, h, t, ls, memo) if memo[elem] < 0: memo[h] += memo[elem] def main(): n = int(input()) ls = [[] for i in range(n + 2)] memo = [0 for i in range(n + 2)] for _ in range(n - 1): f, s = map(int, input().split()) ls[f].append(s) ls[s].append(f) s = 0 e = n while s < e: m = (s + e)//2 t = m depth_first(1, 0, t, ls, memo) if memo[1] < 0: s = m + 1 else: e = m print(s) if __name__ == "__main__": main()
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...