結果
| 問題 | No.3217 Shiki no Shiki |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-06 17:06:43 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 355 bytes |
| 記録 | |
| コンパイル時間 | 233 ms |
| コンパイル使用メモリ | 95,980 KB |
| 実行使用メモリ | 98,176 KB |
| 最終ジャッジ日時 | 2026-07-13 20:23:46 |
| 合計ジャッジ時間 | 4,215 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 21 |
ソースコード
from collections import defaultdict
N = int(input())
P = list(map(int, input().split()))
shikigami = defaultdict(lambda: -1)
ans = 0
for i in range(N):
p = P[i]-1
if p == -1:
cnt = 0
c = i
while shikigami[c] != -1:
cnt += 1
c = shikigami[c]
ans += cnt >= 2
shikigami[p] = i
print(ans)