結果
| 問題 |
No.3217 Shiki no Shiki
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-08-01 21:32:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 264 bytes |
| コンパイル時間 | 185 ms |
| コンパイル使用メモリ | 82,596 KB |
| 実行使用メモリ | 96,816 KB |
| 最終ジャッジ日時 | 2025-08-01 21:32:15 |
| 合計ジャッジ時間 | 2,877 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 20 |
ソースコード
n=int(input())
p=[0]+list(map(int,input().split()))
d=[0]*(n+1)
for i in range(1,n+1):
d[p[i]]+=1
v=[0]*(n+1)
q=[i for i in range(1,n+1) if d[i]==0]
for s in q:
v[s]=1
for s in q:
t=p[s]
if t!=0 and v[t]==0:
v[t]=v[s]+1
q+=[t]
print(v[1:].count(3))
sasa8uyauya