結果

問題 No.3650 Teleportation Cycles
コンテスト
ユーザー Rino-program
提出日時 2026-07-21 12:17:53
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 383 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 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
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
0