Submission #88885

#TimeUsernameProblemLanguageResultExecution timeMemory
88885sailormoonTriumphal arch (POI13_luk)Cpython 3
30 / 100
2065 ms66264 KiB
graph = dict() visited = list() visited = [False for i in range(300001)] ###################### n = int(input()) ###################### def canHandle(v, crs): num_children = 0 need_crews = 0 visited[v] = True for i in range(len(graph[v])): if visited[graph[v][i]] == False: num_children += 1 need_crews += canHandle(graph[v][i], crs) return max(0, num_children + need_crews - crs) start = 0 end = n for i in range(0, n - 1): x = input() x = x.split() a = int(x[0]) b = int(x[1]) for_a = list() for_b = list() if a in graph and b in graph: graph[a].append(b) graph[b].append(a) elif a in graph: graph[a].append(b) for_b = list() for_b.append(a) graph[b] = for_b elif b in graph: graph[b].append(a) for_a = list() for_a.append(b) graph[a] = for_a else: for_a = list() for_b = list() for_a.append(b) for_b.append(a) graph[a] = for_a graph[b] = for_b while start < end: midpoint = int((start + end) / 2) for i in range(n): visited[i] = False if canHandle(1, midpoint) == 0: end = midpoint else: start = 1 + midpoint print(start)
#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...