結果

問題 No.2197 Same Dish
ユーザー titiatitia
提出日時 2023-01-23 01:16:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 508 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 10,700 KB
実行使用メモリ 22,104 KB
最終ジャッジ日時 2023-09-07 07:56:42
合計ジャッジ時間 5,869 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,944 KB
testcase_01 AC 17 ms
8,008 KB
testcase_02 AC 17 ms
7,940 KB
testcase_03 AC 16 ms
7,956 KB
testcase_04 AC 16 ms
7,944 KB
testcase_05 AC 17 ms
8,048 KB
testcase_06 AC 16 ms
7,940 KB
testcase_07 AC 17 ms
8,052 KB
testcase_08 AC 16 ms
7,956 KB
testcase_09 AC 17 ms
7,936 KB
testcase_10 AC 16 ms
8,064 KB
testcase_11 AC 17 ms
8,092 KB
testcase_12 AC 16 ms
8,092 KB
testcase_13 AC 72 ms
10,048 KB
testcase_14 AC 447 ms
20,572 KB
testcase_15 AC 493 ms
21,900 KB
testcase_16 AC 309 ms
17,120 KB
testcase_17 AC 279 ms
15,936 KB
testcase_18 AC 498 ms
21,860 KB
testcase_19 AC 508 ms
21,904 KB
testcase_20 AC 499 ms
21,856 KB
testcase_21 AC 427 ms
22,104 KB
testcase_22 AC 425 ms
21,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop,heappush

N,K=map(int,input().split())
LR=[tuple(map(int,input().split())) for i in range(N)]

LR.sort()
ANS=1
mod=998244353

Q=[]

for l,r in LR:
    while Q and Q[0]<=l:
        heappop(Q)

    ANS=ANS*(K-len(Q))%mod
    heappush(Q,r)

print((pow(K,N,mod)-ANS)%mod)
0