結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 21:52:13 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 908 bytes |
| 記録 | |
| コンパイル時間 | 3,814 ms |
| コンパイル使用メモリ | 336,804 KB |
| 実行使用メモリ | 1,308,364 KB |
| 最終ジャッジ日時 | 2026-04-17 21:53:43 |
| 合計ジャッジ時間 | 20,109 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | AC * 12 MLE * 2 -- * 16 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int Q;
cin >> Q;
vector<char> st;
vector<vector<char>> his;
his.push_back({});
for (int i = 0; i < Q; ++i) {
int type;
cin >> type;
if (type == 1) {
char c;
cin >> c;
vector<char> nxt = his.back();
nxt.push_back(c);
int n = nxt.size();
if (n >= 3 && nxt[n-3] == '(' && nxt[n-2] == '|' && nxt[n-1] == ')') {
nxt.pop_back();
nxt.pop_back();
nxt.pop_back();
}
his.push_back(nxt);
} else {
his.pop_back();
}
if (his.back().empty()) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
return 0;
}