社区讨论
蓝桥杯不要再圈米了
P8765[蓝桥杯 2021 国 AB] 翻转括号序列参与者 4已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @mm02odgj
- 此快照首次捕获于
- 2026/02/24 11:55 2 周前
- 此快照最后确认于
- 2026/02/25 21:10 2 周前
CPP
for (int i = 1, tot, x, y; i <= m; i ++) {
cin >> tot;
if (tot == 1) {
cin >> x >> y;
for (int i = x; i <= y; i ++) op[i] = (op[i] == '(' ? ')' : '(');
}
if (tot == 2) {
cin >> x;
int res = 0;
for (int i = x, cnt = 0; i <= n; i ++) {
if (op[i] == '(') cnt ++;
if (op[i] == ')') {
if (cnt == 0) break;
if (cnt) cnt --;
if (cnt == 0) res = i;
}
}
cout << res << '\n';
}
}
}
能过 1e6 的来了
回复
共 5 条回复,欢迎继续交流。
正在加载回复...