結果

問題 No.2197 Same Dish
ユーザー ripityripity
提出日時 2023-01-20 22:08:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 7,071 ms
コンパイル使用メモリ 301,600 KB
実行使用メモリ 5,488 KB
最終ジャッジ日時 2023-09-05 14:26:24
合計ジャッジ時間 8,242 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 37 ms
5,180 KB
testcase_15 AC 41 ms
5,232 KB
testcase_16 AC 27 ms
4,380 KB
testcase_17 AC 24 ms
4,376 KB
testcase_18 AC 42 ms
5,256 KB
testcase_19 AC 42 ms
5,488 KB
testcase_20 AC 41 ms
5,488 KB
testcase_21 AC 40 ms
5,316 KB
testcase_22 AC 39 ms
5,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	mint ans_comp = 1;
	vector<pair<int, int>> event;
	for( int i = 0; i < N; i++ ) {
		int L, R;
		cin >> L >> R;
		event.emplace_back(make_pair(L, 1));
		event.emplace_back(make_pair(R, -1));
	}
	sort(event.begin(), event.end());
	mint cnt = 0;
	for( auto& p : event ) {
		if( p.second == 1 ) {
			ans_comp *= K-cnt;
		}
		cnt += p.second;
	}
	cout << (mint(K).pow(N)-ans_comp).val() << endl;
}
0