結果

問題 No.2197 Same Dish
ユーザー lloyzlloyz
提出日時 2023-01-22 00:59:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 697 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 1,105 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 98,352 KB
最終ジャッジ日時 2023-09-06 11:56:44
合計ジャッジ時間 8,655 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,292 KB
testcase_01 AC 70 ms
71,536 KB
testcase_02 AC 71 ms
71,312 KB
testcase_03 AC 70 ms
71,332 KB
testcase_04 AC 70 ms
71,384 KB
testcase_05 AC 68 ms
71,196 KB
testcase_06 AC 71 ms
71,292 KB
testcase_07 AC 70 ms
71,308 KB
testcase_08 AC 71 ms
71,324 KB
testcase_09 AC 70 ms
71,336 KB
testcase_10 AC 71 ms
71,368 KB
testcase_11 AC 71 ms
71,388 KB
testcase_12 AC 72 ms
71,360 KB
testcase_13 AC 159 ms
80,408 KB
testcase_14 AC 608 ms
96,216 KB
testcase_15 AC 668 ms
97,732 KB
testcase_16 AC 472 ms
90,524 KB
testcase_17 AC 417 ms
89,388 KB
testcase_18 AC 682 ms
97,756 KB
testcase_19 AC 681 ms
98,088 KB
testcase_20 AC 697 ms
98,180 KB
testcase_21 AC 684 ms
98,352 KB
testcase_22 AC 663 ms
97,892 KB
権限があれば一括ダウンロードができます

ソースコード

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