結果
問題 |
No.3217 Shiki no Shiki
|
ユーザー |
![]() |
提出日時 | 2025-08-01 21:37:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 238 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 82,652 KB |
実行使用メモリ | 93,040 KB |
最終ジャッジ日時 | 2025-08-01 21:37:37 |
合計ジャッジ時間 | 2,728 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
N = int(input()) P = [0] + list(map(int, input().split())) in_deg = [0]*(N+1) for x in range(N+1): in_deg[P[x]] += 1 Q = [x for x in range(1, N+1) if in_deg[x] == 0] dp = [0]*(N+1) for v in Q: dp[P[P[v]]] |= 1 print(sum(dp[1:]))