結果
| 問題 | No.3652 Range Bracket Sequence |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-28 22:39:06 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 289 ms / 2,000 ms |
| + 971µs | |
| コード長 | 980 bytes |
| 記録 | |
| コンパイル時間 | 4,253 ms |
| コンパイル使用メモリ | 378,088 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2026-08-28 22:39:23 |
| 合計ジャッジ時間 | 14,988 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 57 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
struct S {
int l, r, num;
};
S op(S a, S b) {
int x = min(a.l, b.r);
return S(a.l+b.l-x, a.r+b.r-x, a.num+b.num+x);
}
S e() { return S(0, 0, 0); }
int main() {
int n, q;
string s;
cin >> n >> q >> s;
vector<S> init(n);
rep(i, n) {
if (s[i] == '(') init[i] = S(1, 0, 0);
else init[i] = S(0, 1, 0);
}
segtree<S, op, e> seg(init);
rep(qi, q) {
int type;
cin >> type;
if (type == 1) {
int x, t;
cin >> x >> t;
--x;
if (t == 1) seg.set(x, S(1, 0, 0));
else seg.set(x, S(0, 1, 0));
}
else {
int l, r;
cin >> l >> r;
--l;
int ans = seg.prod(l, r).num*2;
cout << ans << '\n';
}
}
return 0;
}