結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
AK_Mi
|
| 提出日時 | 2026-04-18 14:20:03 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 92 ms / 2,000 ms |
| コード長 | 1,255 bytes |
| 記録 | |
| コンパイル時間 | 2,170 ms |
| コンパイル使用メモリ | 336,688 KB |
| 実行使用メモリ | 16,000 KB |
| 最終ジャッジ日時 | 2026-04-18 14:20:15 |
| 合計ジャッジ時間 | 10,753 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using mint = modint998244353;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll q;
cin >> q;
vector<ll> ans(q+1,0);
vector<ll> ref(q+1,0);
ll it = 0;
ll que;
char c;
while(q--){
cin >> que;
if(que == 1){
cin >> c;
it++;
if(c == '('){
ans[it] = 1;
ref[it] = it-1;
}else if(c == '|'){
if(ans[it-1] == 1){
ans[it] = 2;
ref[it] = ref[it-1];
}else{
ans[it] = -1;
ref[it] = ref[it-1];
}
}else{
if(ans[it-1] == 2){
ans[it] = ans[ref[it-1]];
ref[it] = ref[ref[it-1]];
}else{
ans[it] = -1;
ref[it] = ref[it-1];
}
}
}else{
it--;
}
if(ans[it] == 0)cout << "Yes" << '\n';
else cout << "No" << '\n';
}
}
AK_Mi