結果

問題 No.3217 Shiki no Shiki
ユーザー detteiuu
提出日時 2025-08-01 21:25:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 82,636 KB
実行使用メモリ 86,752 KB
最終ジャッジ日時 2025-08-01 21:25:22
合計ジャッジ時間 2,740 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = list(map(int, input().split()))

F = [False]*N
for p in P:
    if 1 <= p:
        F[p-1] = True

ans = [False]*N
for i in range(N):
    if P[i] == 0:
        continue
    if F[i]:
        continue
    a = P[i]-1
    if P[a] == 0:
        continue
    ans[P[a]-1] = True

print(sum(ans))
0