結果

問題 No.2395 区間二次変換一点取得
ユーザー random contestantrandom contestant
提出日時 2023-07-28 22:55:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 4,939 ms
コンパイル使用メモリ 260,112 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-04-16 06:52:21
合計ジャッジ時間 8,406 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
9,472 KB
testcase_01 AC 12 ms
9,472 KB
testcase_02 AC 12 ms
9,472 KB
testcase_03 AC 12 ms
9,600 KB
testcase_04 AC 12 ms
9,728 KB
testcase_05 AC 13 ms
9,472 KB
testcase_06 AC 13 ms
9,600 KB
testcase_07 AC 13 ms
9,472 KB
testcase_08 AC 13 ms
9,472 KB
testcase_09 AC 13 ms
9,472 KB
testcase_10 AC 13 ms
9,600 KB
testcase_11 AC 15 ms
9,600 KB
testcase_12 AC 37 ms
9,600 KB
testcase_13 AC 277 ms
9,472 KB
testcase_14 AC 275 ms
9,472 KB
testcase_15 AC 286 ms
9,472 KB
testcase_16 AC 275 ms
9,600 KB
testcase_17 AC 279 ms
9,472 KB
testcase_18 AC 255 ms
9,472 KB
testcase_19 AC 254 ms
9,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back
#define int long long
#define double long double
#define INF (ll) 3e18
// Ctrl + Shift + B コンパイル
// Ctrl + C 中断
// ./m 実行


signed main(){
  int n, b, q;
  cin >> n >> b >> q;
  fenwick_tree<int> ft(200010);
  vector<tuple<int,int,int>> xyz(200010);
  xyz[0] = make_tuple(1,1,1);
  for(int i = 0; i <= 200000; i++){
    auto[x, y, z] = xyz[i];
    xyz[i+1] = make_tuple((x+1)%b, (3*y+2*(x+1)*z)%b, 3*z%b);
  }
  while(q--){
    int l, m, r;
    cin >> l >> m >> r;
    ft.add(l, 1);
    ft.add(r+1, -1);
    auto [x, y, z] = xyz[ft.sum(0, m+1)];
    cout << x << " " << y << " " << z << endl;
  }
}


// 変化量が固定なので、更新された回数が分かれば良さそう。
0