結果

問題 No.2197 Same Dish
ユーザー 👑 H20H20
提出日時 2023-01-20 22:31:17
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 732 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 117,252 KB
最終ジャッジ日時 2023-09-05 14:50:29
合計ジャッジ時間 8,352 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
71,760 KB
testcase_01 AC 99 ms
71,608 KB
testcase_02 AC 100 ms
71,828 KB
testcase_03 AC 99 ms
71,724 KB
testcase_04 AC 100 ms
71,596 KB
testcase_05 AC 101 ms
71,596 KB
testcase_06 AC 101 ms
71,728 KB
testcase_07 AC 102 ms
71,508 KB
testcase_08 AC 101 ms
71,620 KB
testcase_09 AC 101 ms
71,500 KB
testcase_10 AC 97 ms
71,732 KB
testcase_11 AC 99 ms
71,448 KB
testcase_12 AC 101 ms
71,612 KB
testcase_13 AC 215 ms
83,700 KB
testcase_14 AC 582 ms
113,856 KB
testcase_15 AC 602 ms
108,248 KB
testcase_16 AC 478 ms
106,356 KB
testcase_17 AC 438 ms
102,748 KB
testcase_18 AC 642 ms
116,816 KB
testcase_19 AC 636 ms
117,252 KB
testcase_20 AC 626 ms
117,084 KB
testcase_21 AC 555 ms
111,620 KB
testcase_22 AC 732 ms
115,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N,K = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(N)]
D = collections.defaultdict(int)
for l,r in LR:
    D[l*2]+=1
    D[r*2-1]-=1
D = sorted(D.items())
mod = 998244353
eat = 0
dp = 1


for k,v in D:
    if k%2==0:
        for _ in range(v):
            dp = (dp*(K-eat))%mod
            eat+=1
    else:
        eat+=v
print((pow(K,N,mod)-dp)%mod)
0