結果

問題 No.2197 Same Dish
ユーザー aaaaaaaaaa2230
提出日時 2023-01-20 22:25:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 90,120 KB
最終ジャッジ日時 2024-06-23 10:22:14
合計ジャッジ時間 3,257 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
mod = 998244353

LR = [list(map(int,input().split())) for i in range(n)]
M = 2*10**5+1
eL = [0]*M
eR = [0]*M
for l,r in LR:
    eL[l] += 1
    eR[r-1] += 1


now = 0
dp = 1
for l,r in zip(eL,eR):
    if l:
        for i in range(l):
            dp *= k-now
            dp %= mod
            now += 1
    
    now -= r

ans = pow(k,n,mod)-dp
print(ans%mod)
0