結果
| 問題 |
No.2089 置換の符号
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 20:52:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 434 bytes |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 82,512 KB |
| 実行使用メモリ | 63,428 KB |
| 最終ジャッジ日時 | 2025-03-20 20:52:49 |
| 合計ジャッジ時間 | 2,344 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
n = int(input())
permutation = list(map(int, input().split()))
visited = [False] * n
count = 0
for i in range(1, n + 1):
if not visited[i - 1]:
current = i
cycle_length = 0
while not visited[current - 1]:
visited[current - 1] = True
current = permutation[current - 1]
cycle_length += 1
count += (cycle_length - 1)
sign = 1 if count % 2 == 0 else -1
print(sign)
lam6er