結果

問題 No.2197 Same Dish
コンテスト
ユーザー flippergo
提出日時 2026-10-13 08:04:23
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 325 ms / 2,000 ms
+ 298µs
コード長 503 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 91 ms
コンパイル使用メモリ 65,112 KB
実行使用メモリ 84,600 KB
最終ジャッジ日時 2026-10-13 08:04:30
合計ジャッジ時間 6,053 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_right
MOD = 998244353
INFTY = 2*10**5+10
N,K = map(int,input().split())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
A = sorted(A,key=lambda x:x[1])
A = [(A[i][1],A[i][0]) for i in range(N)]
Deg = [0]*N
for i in range(1,N):
    r,l = A[i]
    ind = bisect_right(A,(l,INFTY))
    Deg[ind] += 1
    Deg[i] += -1
for i in range(1,N):
    Deg[i] += Deg[i-1]
ans = 1
for i in range(N):
    ans = (ans*(K-Deg[i]))%MOD
print((pow(K,N,MOD)-ans)%MOD)
0