提出 #44913379
ソースコード 拡げる
Copy
import sysdef get():return int(sys.stdin.readline().rstrip())N = get()sys.setrecursionlimit(N + 777)children = [[] for _ in range(N + 1)]for i in range(2, N + 1):P = get()children[P].append(i)ans = [0 for _ in range(N + 1)]def calc(node):ans[node] = 1 + sum([calc(c) for c in children[node]])return ans[node]calc(1)
import sys def get(): return int(sys.stdin.readline().rstrip()) N = get() sys.setrecursionlimit(N + 777) children = [[] for _ in range(N + 1)] for i in range(2, N + 1): P = get() children[P].append(i) ans = [0 for _ in range(N + 1)] def calc(node): ans[node] = 1 + sum([calc(c) for c in children[node]]) return ans[node] calc(1) print("\n".join(map(str, ans[1:])))
提出情報
提出日時 | |
---|---|
問題 | B - 部分木サイズ |
ユーザ | mikecat |
言語 | Python (CPython 3.11.4) |
得点 | 0 |
コード長 | 401 Byte |
結果 | RE |
実行時間 | 2204 ms |
メモリ | 256332 KB |
ジャッジ結果
セット名 | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
得点 / 配点 | 0 / 0 | 0 / 1 | ||||||
結果 |
|
|
セット名 | テストケース |
---|---|
Sample | sample-01.txt, sample-02.txt |
All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, sample-01.txt, sample-02.txt |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
01-01.txt | AC | 1008 ms | 111204 KB |
01-02.txt | AC | 960 ms | 111208 KB |
01-03.txt | RE | 2204 ms | 256228 KB |
01-04.txt | RE | 2180 ms | 256332 KB |
01-05.txt | AC | 553 ms | 108840 KB |
sample-01.txt | AC | 10 ms | 8508 KB |
sample-02.txt | AC | 10 ms | 8448 KB |