結果
| 問題 |
No.2382 Amidakuji M
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2024-09-14 13:15:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 336 bytes |
| コンパイル時間 | 424 ms |
| コンパイル使用メモリ | 81,996 KB |
| 実行使用メモリ | 109,056 KB |
| 最終ジャッジ日時 | 2024-09-14 13:15:31 |
| 合計ジャッジ時間 | 6,547 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 6 |
ソースコード
n,m=map(int,input().split())
p=list(map(int,input().split()))
B=450
st1=[0]*B*B
st2=[0]*B
f=0
for v in p[::-1]:
l=0
r=v
yl=l//B
yr=r//B
if yl==yr:
f+=sum(st1[l:r+1])
else:
f+=sum(st1[l:yl*B+B])
f+=sum(st2[yl+1:yr])
f+=sum(st1[yr*B:r+1])
st1[v]+=1
st2[v//B]+=1
m*=(f+m-1)//m
print(m if (m-f)%2==0 else -1)
sasa8uyauya