結果
| 問題 |
No.3217 Shiki no Shiki
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-08-01 22:03:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 382 bytes |
| コンパイル時間 | 310 ms |
| コンパイル使用メモリ | 82,160 KB |
| 実行使用メモリ | 104,620 KB |
| 最終ジャッジ日時 | 2025-08-01 22:03:18 |
| 合計ジャッジ時間 | 3,118 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 q in range(1, N+1):
if freq[q] > 0: continue
p = ps[q]
if p == q: continue
if p == 0: continue
i = ps[p]
if i > 0:
ans += 1
print(ans)
norioc