結果

問題 No.2197 Same Dish
ユーザー flygonflygon
提出日時 2023-01-20 22:10:33
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 771 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 928 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 100,820 KB
最終ジャッジ日時 2023-09-05 14:27:52
合計ジャッジ時間 9,259 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,220 KB
testcase_01 AC 73 ms
71,136 KB
testcase_02 AC 72 ms
71,056 KB
testcase_03 AC 74 ms
71,324 KB
testcase_04 AC 73 ms
70,888 KB
testcase_05 AC 73 ms
71,080 KB
testcase_06 AC 72 ms
71,344 KB
testcase_07 AC 72 ms
71,108 KB
testcase_08 AC 73 ms
71,104 KB
testcase_09 AC 72 ms
71,248 KB
testcase_10 AC 72 ms
71,224 KB
testcase_11 AC 73 ms
71,072 KB
testcase_12 AC 74 ms
71,316 KB
testcase_13 AC 161 ms
79,324 KB
testcase_14 AC 666 ms
97,732 KB
testcase_15 AC 733 ms
100,316 KB
testcase_16 AC 504 ms
92,208 KB
testcase_17 AC 451 ms
90,772 KB
testcase_18 AC 764 ms
100,340 KB
testcase_19 AC 767 ms
100,432 KB
testcase_20 AC 771 ms
100,820 KB
testcase_21 AC 769 ms
100,772 KB
testcase_22 AC 719 ms
100,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

lr.sort()
ans = 1
now = 0
for a,b in lr:
  if b == -1:
    now -= 1
  else:
    ans *= k-now
    now += 1
  ans %= mod

ans = pow(k, n, mod) - ans
ans %= mod
print(ans)

0