結果

問題 No.2395 区間二次変換一点取得
ユーザー matsup10matsup10
提出日時 2023-07-28 22:14:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 1,362 bytes
コンパイル時間 7,574 ms
コンパイル使用メモリ 310,752 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-16 06:12:48
合計ジャッジ時間 10,557 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 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 3 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 26 ms
5,376 KB
testcase_13 AC 283 ms
5,888 KB
testcase_14 AC 270 ms
6,016 KB
testcase_15 AC 270 ms
6,016 KB
testcase_16 AC 270 ms
6,016 KB
testcase_17 AC 267 ms
6,016 KB
testcase_18 AC 251 ms
6,016 KB
testcase_19 AC 246 ms
5,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,a,b) for(int i=a;i<=int(b);i++)
#define ALL(x) x.begin(),x.end()
#define INF INT_MAX
#define INFL LLONG_MAX / 4
using namespace atcoder;
using mint = modint998244353;
template<typename T> void chmin(T& a, T b) { a = min(a, b); }
template<typename T> void chmax(T& a, T b) { a = max(a, b); }
#define PR(x) cerr << #x << "=" << x << endl
using i128 = __int128_t;

template <typename T>
struct BIT {
  int n;          // 配列の要素数(数列の要素数+1)
  vector<T> bit;  // データの格納先(1-index)
  BIT(int n_) : n(n_ + 1), bit(n, 0) {}
  void add(int idx, T x) {
    for (int i = idx; i < n; i += (i & -i)) {
      bit[i] += x;
    }
  }
  T sum(int idx) {
    T s(0);
    for (int i = idx; i > 0; i -= (i & -i)) {
      s += bit[i];
    }
    return s;
  }
};
int main() {
  int n, b ,q;
  cin >> n >> b >> q;
  vector<tuple<ll, ll, ll>> ansl(q+1);
  ansl[0] = {1, 1, 1};

  REP(i, q) {
    auto [x, y, z] = ansl[i];
    ansl[i+1] = {(x+1)%b, (3*y+2*(x+1)*z)%b, 3*z%b};
  }

  BIT<int> bit(n+1);
  REP(i, q) {
    int l, m, r;
    cin >> l >> m >> r;
    bit.add(l, 1);
    bit.add(r+1, -1);
    auto [x, y, z] = ansl[bit.sum(m)];
    cout << x << ' ' << y << ' ' << z << endl;
  }


  return 0;
}
0