結果

問題 No.2395 区間二次変換一点取得
ユーザー 👑 hitonanodehitonanode
提出日時 2023-08-05 11:38:31
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 95,804 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 08:48:47
合計ジャッジ時間 4,024 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 8 ms
5,376 KB
testcase_13 AC 60 ms
5,376 KB
testcase_14 AC 60 ms
5,376 KB
testcase_15 AC 60 ms
5,376 KB
testcase_16 AC 61 ms
5,376 KB
testcase_17 AC 60 ms
5,376 KB
testcase_18 AC 54 ms
5,376 KB
testcase_19 AC 55 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;


#include <atcoder/fenwicktree>
#include <atcoder/modint>
using mint = atcoder::modint;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int N, B, Q;
    cin >> N >> B >> Q;
    mint::set_mod(B);

    vector<mint> Y(Q + 1, 1);
    auto Z = Y;
    for (int q = 1; q <= Q; ++q) {
        Y.at(q) = Y.at(q - 1) * 3 + Z.at(q - 1) * ((q + 1) * 2);
        Z.at(q) = Z.at(q - 1) * 3;
    }

    atcoder::fenwick_tree<int> bit(N + 1);

    while (Q--) {
        int l, m, r;
        cin >> l >> m >> r;
        --l;
        bit.add(l, 1);
        bit.add(r, -1);
        int s = bit.sum(0, m);
        cout << mint(s + 1).val() << ' ' << Y.at(s).val() << ' ' << Z.at(s).val() << '\n';
    }
}
0