結果

問題 No.2382 Amidakuji M
ユーザー sharusharu
提出日時 2023-07-14 22:50:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 266 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 10,576 KB
実行使用メモリ 31,088 KB
最終ジャッジ日時 2023-10-14 13:10:10
合計ジャッジ時間 2,597 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,888 KB
testcase_01 AC 16 ms
7,892 KB
testcase_02 AC 16 ms
8,024 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 28 ms
10,860 KB
testcase_06 WA -
testcase_07 AC 45 ms
14,796 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 82 ms
23,148 KB
testcase_13 AC 16 ms
7,964 KB
testcase_14 WA -
testcase_15 AC 16 ms
7,988 KB
testcase_16 WA -
testcase_17 AC 16 ms
7,992 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 117 ms
31,064 KB
testcase_21 AC 116 ms
31,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

n, m = map(int, input().split())
p = list(map(int, input().split()))
c = 0
for i in range(n):
    if p[i] - 1 != i:
        c += 1
c = max(0, c - 1)
if gcd(2, m) != 1:
    print(-1)
else:
    n = (-c * pow(2, -1, m)) % m
    print((c + 2 * n))
0