結果
| 問題 | No.3650 Teleportation Cycles |
| コンテスト | |
| ユーザー |
とある理系大学生の日常
|
| 提出日時 | 2026-07-20 17:02:44 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 377 ms / 2,000 ms |
| + 306µs | |
| コード長 | 672 bytes |
| 記録 | |
| コンパイル時間 | 317 ms |
| コンパイル使用メモリ | 21,288 KB |
| 実行使用メモリ | 33,884 KB |
| 最終ジャッジ日時 | 2026-08-28 20:58:49 |
| 合計ジャッジ時間 | 8,245 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
D=[]
ANS=0
for n in range(N):
if B[n]==0:#未出発なら
s=n
D.append(s)
while True:
if B[A[s]-1]==0:
s=A[s]-1
D.append(s)
B[s]=1
elif B[A[s]-1]==1:
ANS+=1
B[s]=2
if len(D)==1:
break
else:
D.pop()
s=D[-1]
else:
B[s]=2
if len(D)==1:
break
else:
D.pop()
s=D[-1]
print(ANS)
とある理系大学生の日常