結果

問題 No.2197 Same Dish
ユーザー t98slidert98slider
提出日時 2023-01-20 22:47:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 3,875 ms
コンパイル使用メモリ 144,368 KB
実行使用メモリ 4,668 KB
最終ジャッジ日時 2023-09-05 15:11:52
合計ジャッジ時間 6,000 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 8 ms
4,376 KB
testcase_14 AC 33 ms
4,652 KB
testcase_15 AC 37 ms
4,668 KB
testcase_16 AC 24 ms
4,376 KB
testcase_17 AC 23 ms
4,388 KB
testcase_18 AC 37 ms
4,596 KB
testcase_19 AC 37 ms
4,596 KB
testcase_20 AC 38 ms
4,668 KB
testcase_21 AC 35 ms
4,656 KB
testcase_22 AC 35 ms
4,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, l, r;
    cin >> n >> k;
    vector<pair<int,int>> seg(n);
    fenwick_tree<int> fw(200000);
    for(int i = 0; i < n; i++){
        cin >> seg[i].second >> seg[i].first;
        fw.add(seg[i].second, 1);
    }
    sort(seg.begin(), seg.end());
    mint coef = 1;
    for(int i = 0; i < n; i++){
        tie(r, l) = seg[i];
        fw.add(l, -1);
        coef *= max(0, k - fw.sum(0, r));
    }
    cout << (mint(k).pow(n) - coef).val() << '\n';
}
0