結果
問題 | No.2197 Same Dish |
ユーザー |
|
提出日時 | 2023-01-20 21:55:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 163 ms / 2,000 ms |
コード長 | 415 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 85,100 KB |
最終ジャッジ日時 | 2024-06-23 09:54:35 |
合計ジャッジ時間 | 3,305 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
mod=998244353n,k=map(int,input().split())L=[]R=[]for i in range(n):l,r=map(int,input().split())L.append(l)R.append(r)L.sort(reverse=True)R.sort(reverse=True)r_ans=1n_c=0while(L):l=L.pop()r=R.pop()if l<r:r_ans*=k-n_cr_ans%=modn_c+=1R.append(r)else:n_c-=1L.append(l)ans=pow(k,n,mod)-r_ansans%=modprint(ans)