結果

問題 No.2197 Same Dish
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-01-20 22:25:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 91,052 KB
最終ジャッジ日時 2023-09-05 14:44:29
合計ジャッジ時間 4,282 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
78,752 KB
testcase_01 AC 77 ms
78,832 KB
testcase_02 AC 81 ms
78,752 KB
testcase_03 AC 77 ms
78,928 KB
testcase_04 AC 79 ms
78,760 KB
testcase_05 AC 79 ms
78,868 KB
testcase_06 AC 78 ms
78,860 KB
testcase_07 AC 79 ms
78,904 KB
testcase_08 AC 78 ms
78,856 KB
testcase_09 AC 79 ms
78,876 KB
testcase_10 AC 78 ms
78,932 KB
testcase_11 AC 81 ms
78,888 KB
testcase_12 AC 82 ms
78,808 KB
testcase_13 AC 121 ms
81,324 KB
testcase_14 AC 187 ms
89,084 KB
testcase_15 AC 199 ms
91,024 KB
testcase_16 AC 168 ms
87,116 KB
testcase_17 AC 164 ms
86,776 KB
testcase_18 AC 199 ms
90,804 KB
testcase_19 AC 199 ms
90,920 KB
testcase_20 AC 197 ms
91,008 KB
testcase_21 AC 201 ms
91,052 KB
testcase_22 AC 194 ms
90,884 KB
権限があれば一括ダウンロードができます

ソースコード

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