結果
問題 |
No.3217 Shiki no Shiki
|
ユーザー |
![]() |
提出日時 | 2025-08-01 21:58:53 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 373 bytes |
コンパイル時間 | 249 ms |
コンパイル使用メモリ | 82,276 KB |
実行使用メモリ | 104,536 KB |
最終ジャッジ日時 | 2025-08-01 21:58:56 |
合計ジャッジ時間 | 3,316 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 19 |
ソースコード
from collections import defaultdict N = int(input()) P = list(map(int, input().split())) ps = [0] + P freq = defaultdict(int) for i in range(1, N+1): if ps[i] == 0: continue freq[ps[i]] += 1 ans = 0 for i in range(1, N+1): if freq[i] > 0: continue x = ps[i] if x != 0: y = ps[x] if y != 0 and y != i: ans += 1 print(ans)