Submission #1084060

#TimeUsernameProblemLanguageResultExecution timeMemory
1084060IzzyBosses (BOI16_bosses)Cpython 3
0 / 100
10 ms2908 KiB
def test(start): visited = [False for i in range(n)] levels = [[start]] lvl = 0 pos = 0 salary = 0 visited[start] = True while lvl < len(levels): # print(levels, salary) start = levels[lvl][pos] if start in arr: for i in arr[start]: if not visited[i]: visited[i] = True if len(levels) > lvl + 1: levels[lvl + 1].append(i) else: levels.append([i]) pos += 1 if pos == len(levels[lvl]): salary += len(levels[lvl]) * (pos + 1) lvl += 1 pos = 0 a = set(visited) if True in a and len(a) == 1: print(levels) return salary return float('inf') salary = float('inf') n = int(input()) arr = {} for i in range(n): x = [int(i) - 1 for i in input().split(' ')[1:]] for j in x: if j in arr: arr[j].append(i) else: arr[j] = [i] for i in arr: salary = min(salary, test(i)) print(salary)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...