結果
| 問題 | No.3217 Shiki no Shiki |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-08-01 21:57:20 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 362 bytes |
| 記録 | |
| コンパイル時間 | 230 ms |
| コンパイル使用メモリ | 96,360 KB |
| 実行使用メモリ | 102,432 KB |
| 最終ジャッジ日時 | 2026-07-13 16:54:17 |
| 合計ジャッジ時間 | 4,121 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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:
ans += 1
print(ans)
norioc