結果

問題 No.2197 Same Dish
ユーザー lloyz
提出日時 2023-01-22 00:59:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 762 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 82,692 KB
実行使用メモリ 97,552 KB
最終ジャッジ日時 2024-06-24 06:33:58
合計ジャッジ時間 8,052 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
E = []
for _ in range(n):
    l, r = map(int, input().split())
    E.append((l, 1))
    E.append((r, -1))
mod = 998244353

E.sort(key=lambda x: (x[0], x[1]))
ans = 1
num = 0
for x, p in E:
    if p == 1:
        ans *= k - num
        ans %= mod
        num += 1
    else:
        num -= 1
print((pow(k, n, mod) - ans) % mod)
0