結果

問題 No.2197 Same Dish
ユーザー ntudantuda
提出日時 2023-01-22 21:54:25
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 590 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 92,852 KB
最終ジャッジ日時 2023-09-07 05:47:48
合計ジャッジ時間 8,330 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,172 KB
testcase_01 AC 76 ms
71,412 KB
testcase_02 AC 77 ms
71,404 KB
testcase_03 AC 75 ms
71,112 KB
testcase_04 AC 78 ms
71,532 KB
testcase_05 AC 76 ms
71,452 KB
testcase_06 AC 78 ms
71,128 KB
testcase_07 AC 76 ms
71,240 KB
testcase_08 AC 78 ms
71,612 KB
testcase_09 AC 77 ms
71,212 KB
testcase_10 AC 78 ms
71,220 KB
testcase_11 AC 80 ms
71,348 KB
testcase_12 AC 80 ms
71,548 KB
testcase_13 AC 203 ms
80,024 KB
testcase_14 AC 529 ms
90,220 KB
testcase_15 AC 579 ms
90,836 KB
testcase_16 AC 423 ms
86,664 KB
testcase_17 AC 381 ms
85,896 KB
testcase_18 AC 590 ms
91,396 KB
testcase_19 AC 574 ms
91,764 KB
testcase_20 AC 589 ms
91,580 KB
testcase_21 AC 488 ms
92,852 KB
testcase_22 AC 446 ms
88,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
from heapq import *

N, K = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(N)]
LR.sort()
q = []
cnt = 0
All = pow(K, N, MOD)
tmp = 1
for l, r in LR:
    if q:
        while q and q[0] <= l:
            cnt -= 1
            heappop(q)
    tmp *= (K - cnt)
    tmp %= MOD
    cnt += 1
    heappush(q, r)
print((All - tmp) % MOD)
0