結果
| 問題 |
No.3217 Shiki no Shiki
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2025-08-01 21:25:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 2,000 ms |
| コード長 | 261 bytes |
| コンパイル時間 | 217 ms |
| コンパイル使用メモリ | 82,592 KB |
| 実行使用メモリ | 85,864 KB |
| 最終ジャッジ日時 | 2025-08-01 21:25:35 |
| 合計ジャッジ時間 | 2,565 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
n = int(input())
p = [x - 1 for x in map(int, input().split())]
par_cnt = [0] * n
for x in p:
if x != -1:
par_cnt[x] += 1
ok = [0] * n
for i in range(n):
if par_cnt[i] == 0 and p[i] != -1 and p[p[i]] != -1:
ok[p[p[i]]] = 1
print(sum(ok))
Kude