結果
| 問題 |
No.2611 Count 01
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2024-01-19 22:17:36 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 186 ms / 6,000 ms |
| コード長 | 1,794 bytes |
| コンパイル時間 | 4,139 ms |
| コンパイル使用メモリ | 276,992 KB |
| 実行使用メモリ | 24,576 KB |
| 最終ジャッジ日時 | 2024-09-28 04:38:16 |
| 合計ジャッジ時間 | 8,674 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using mint = modint998244353;
struct S {
mint lr, l, r, c;
mint c0, s0, c1, s1;
};
S op(S x, S y) {
return S{
x.lr + y.lr - x.c0 * y.c1 - x.c1 * y.c0,
x.l + y.l + x.c0 * y.s1 + x.c1 * y.s0,
x.r + y.r + x.s0 * y.c1 + x.s1 * y.c0,
x.c + y.c - x.s0 * y.s1 - x.s1 * y.s0,
x.c0 + y.c0, x.s0 + y.s0, x.c1 + y.c1, x.s1 + y.s1
};
}
S e() {
return S{};
}
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
string s;
cin >> s;
vector<S> init(n);
rep(i, n) {
init[i] = s[i] == '0' ? S{0, 0, 0, 0, 1, i, 0, 0} : S{0, 0, 0, 0, 0, 0, 1, i};
}
segtree<S, op, e> seg(init);
rep(_, q) {
int op;
cin >> op;
if (op == 1) {
int i;
cin >> i;
i--;
s[i] ^= '0' ^ '1';
seg.set(i, s[i] == '0' ? S{0, 0, 0, 0, 1, i, 0, 0} : S{0, 0, 0, 0, 0, 0, 1, i});
} else {
int l, r;
cin >> l >> r;
l--;
auto s = seg.prod(l, r);
l--;
mint ans = s.lr * l * r + s.l * l + s.r * r + s.c;
cout << ans.val() << '\n';
}
}
}
Kude