Submission #6514710


Source Code Expand

N = int(input())
buka = [[] for _ in range(N+1)]

for n in range(2,N+1):
  b = int(input()) #上
  buka[b].append(n)

def F(n):
  b = buka[n]
  if len(b) == 0:
    return 1
  arr = [F(x) for x in b]
  return max(arr) + min(arr) + 1

answer = F(1)
print(answer)

Submission Info

Submission Time
Task C - 高橋君の給料
User EikiSiki
Language Python (3.4.3)
Score 100
Code Size 277 Byte
Status AC
Exec Time 17 ms
Memory 3060 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 4
AC × 22
Set Name Test Cases
Sample example_0.txt, example_1.txt, example_2.txt, example_3.txt
All example_0.txt, example_1.txt, example_2.txt, example_3.txt, maxrand_0.txt, maxrand_1.txt, maxrand_2.txt, random_0.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, special_0.txt, example_0.txt, example_1.txt, example_2.txt, example_3.txt
Case Name Status Exec Time Memory
example_0.txt AC 17 ms 2940 KB
example_1.txt AC 17 ms 3060 KB
example_2.txt AC 17 ms 2940 KB
example_3.txt AC 17 ms 2940 KB
maxrand_0.txt AC 17 ms 3060 KB
maxrand_1.txt AC 17 ms 2940 KB
maxrand_2.txt AC 17 ms 3060 KB
random_0.txt AC 17 ms 2940 KB
random_1.txt AC 17 ms 2940 KB
random_2.txt AC 17 ms 2940 KB
random_3.txt AC 17 ms 2940 KB
random_4.txt AC 17 ms 2940 KB
random_5.txt AC 17 ms 2940 KB
random_6.txt AC 17 ms 2940 KB
random_7.txt AC 17 ms 2940 KB
random_8.txt AC 17 ms 2940 KB
random_9.txt AC 17 ms 2940 KB
special_0.txt AC 17 ms 2940 KB