結果
| 問題 |
No.2382 Amidakuji M
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2024-09-14 13:13:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 336 bytes |
| コンパイル時間 | 323 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 262,912 KB |
| 最終ジャッジ日時 | 2024-09-14 13:13:56 |
| 合計ジャッジ時間 | 5,057 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 18 |
ソースコード
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=l//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