結果

問題 No.2197 Same Dish
ユーザー SidewaysOwl
提出日時 2023-01-21 00:22:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 679 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 820 ms
コンパイル使用メモリ 81,916 KB
実行使用メモリ 100,256 KB
最終ジャッジ日時 2024-06-23 12:19:50
合計ジャッジ時間 7,574 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

arr = []
for i in range(n):
    l,r = map(int,input().split())
    arr.append((l,1,i))
    arr.append((r,0,i))
arr.sort()
cnt = 0
ans = 1
for x,io,l in arr:
    if io == 1:
        ans *= k-cnt
        ans %= mod
        cnt += 1
    else:
        cnt -= 1
print((pow(k,n,mod)-ans) % mod)
0