Submission #6504891
Source Code Expand
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): return list(map(int, stdin.readline().split())) def LF(): return list(map(float, stdin.readline().split())) def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split())) def II(): return int(stdin.readline()) def IF(): return float(stdin.readline()) def LS(): return list(map(list, stdin.readline().split())) def S(): return list(stdin.readline().rstrip()) def IR(n): return [II() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] def SR(n): return [S() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] mod = 1000000007 inf = float('INF') #A def A(): a = II() ans = 0 for i in range(1,a): for k in range(1,a): if i + k == a: ans = max(ans, i * k) print(ans) return #B def B(): n = II() x = IR(n) x.sort() ans = 0 t = 0 for i in x: ans += i ** 2 * [1, -1][t] t ^= 1 print(abs(ans*math.pi)) return #C def C(): n = II() b = [[] for i in range(n)] for i in range(1,n): bi = II() b[bi - 1].append(i) def dfs(now, pre): big = 0 small = inf f = True for n in b[now]: if n != pre: x = dfs(n, now) big = max(x, big) small = min(x, small) f = False if f: return 1 return big + small + 1 print(dfs(0,-1)) return #D def D(): return #Solve if __name__ == '__main__': C()
Submission Info
Submission Time | |
---|---|
Task | C - 高橋君の給料 |
User | horiso0921 |
Language | PyPy3 (2.4.0) |
Score | 100 |
Code Size | 2035 Byte |
Status | AC |
Exec Time | 195 ms |
Memory | 38768 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
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 | 174 ms | 38640 KB |
example_1.txt | AC | 173 ms | 38640 KB |
example_2.txt | AC | 173 ms | 38640 KB |
example_3.txt | AC | 172 ms | 38640 KB |
maxrand_0.txt | AC | 176 ms | 38640 KB |
maxrand_1.txt | AC | 177 ms | 38640 KB |
maxrand_2.txt | AC | 175 ms | 38640 KB |
random_0.txt | AC | 195 ms | 38768 KB |
random_1.txt | AC | 175 ms | 38640 KB |
random_2.txt | AC | 174 ms | 38640 KB |
random_3.txt | AC | 173 ms | 38640 KB |
random_4.txt | AC | 174 ms | 38640 KB |
random_5.txt | AC | 174 ms | 38640 KB |
random_6.txt | AC | 172 ms | 38640 KB |
random_7.txt | AC | 172 ms | 38768 KB |
random_8.txt | AC | 173 ms | 38640 KB |
random_9.txt | AC | 173 ms | 38640 KB |
special_0.txt | AC | 174 ms | 38640 KB |