結果

問題 No.2197 Same Dish
ユーザー shobonvipshobonvip
提出日時 2023-01-20 21:53:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 81,072 KB
最終ジャッジ日時 2023-09-05 14:10:08
合計ジャッジ時間 4,436 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
79,664 KB
testcase_01 AC 84 ms
79,504 KB
testcase_02 AC 87 ms
79,444 KB
testcase_03 AC 87 ms
79,180 KB
testcase_04 AC 87 ms
79,532 KB
testcase_05 AC 87 ms
79,580 KB
testcase_06 AC 86 ms
79,536 KB
testcase_07 AC 85 ms
79,304 KB
testcase_08 AC 87 ms
79,204 KB
testcase_09 AC 85 ms
79,356 KB
testcase_10 AC 86 ms
79,692 KB
testcase_11 AC 88 ms
79,536 KB
testcase_12 AC 86 ms
79,300 KB
testcase_13 AC 130 ms
80,760 KB
testcase_14 AC 180 ms
80,788 KB
testcase_15 AC 192 ms
80,756 KB
testcase_16 AC 164 ms
80,876 KB
testcase_17 AC 167 ms
80,988 KB
testcase_18 AC 194 ms
81,072 KB
testcase_19 AC 192 ms
80,840 KB
testcase_20 AC 197 ms
81,036 KB
testcase_21 AC 183 ms
80,816 KB
testcase_22 AC 172 ms
80,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 余事象を求める. (つまり, 全部被らない)

mod = 998244353

n,k = map(int,input().split())
ins = [0 for i in range(200003)]
outs = [0 for i in range(200003)]

for i in range(n):
	l, r = map(int,input().split())
	ins[l] += 1
	outs[r] += 1

now = 0
ans = 1

for i in range(200002):
	for j in range(outs[i]):
		now -= 1
	for j in range(ins[i]):
		ans *= k-now
		ans %= mod
		now += 1

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