結果

問題 No.2197 Same Dish
ユーザー norikamenorikame
提出日時 2023-01-21 00:18:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 913 bytes
コンパイル時間 5,483 ms
コンパイル使用メモリ 311,276 KB
実行使用メモリ 5,280 KB
最終ジャッジ日時 2023-09-05 16:46:25
合計ジャッジ時間 7,369 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 12 ms
4,376 KB
testcase_14 AC 71 ms
5,096 KB
testcase_15 AC 78 ms
5,164 KB
testcase_16 AC 52 ms
4,376 KB
testcase_17 AC 46 ms
4,384 KB
testcase_18 AC 80 ms
5,136 KB
testcase_19 AC 80 ms
5,092 KB
testcase_20 AC 80 ms
5,228 KB
testcase_21 AC 79 ms
5,280 KB
testcase_22 AC 77 ms
5,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);
const ll mod = 998244353LL;

int main() {
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> xlst;
	rep(i, n) {
		int li, ri;
		cin >> li >> ri;
		xlst.emplace_back(li, 1);
		xlst.emplace_back(ri, -1);
	}
	sort(all(xlst));
	int tcnt = 0;
	ll sub = 1;
	for (const auto& pi : xlst) {
		if (pi.second == 1) {
			sub = sub * max(0, k-tcnt) % mod;
			++tcnt;
		}
		else --tcnt;
	}
	ll res = 1;
	rep(i, n) res = res * k % mod;
	res = (res - sub + mod) % mod;
	cout << res << endl;
	return 0;
}
0