結果
問題 | No.2197 Same Dish |
ユーザー |
![]() |
提出日時 | 2023-01-21 00:18:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 913 bytes |
コンパイル時間 | 5,347 ms |
コンパイル使用メモリ | 312,908 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 12:15:29 |
合計ジャッジ時間 | 7,048 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
//#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;}