結果
| 問題 | No.3650 Teleportation Cycles |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-21 12:17:53 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 383 bytes |
| 記録 | |
| コンパイル時間 | 248 ms |
| コンパイル使用メモリ | 96,232 KB |
| 実行使用メモリ | 129,152 KB |
| 最終ジャッジ日時 | 2026-08-28 20:59:27 |
| 合計ジャッジ時間 | 5,100 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 27 |
ソースコード
N = int(input())
A = list(map(int, input().split()))
S = [0] * N
ans = 0
for i in range(N):
now_idx = i
now_li = []
if not S[now_idx]:
while not S[now_idx]:
now_li.append(now_idx)
S[now_idx] = 1
now_idx = A[now_idx] - 1 # 1-indexed を 0-indexedに直す
ans += 1
for idx in now_li:
S[idx] = 2
print(ans)