結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-27 19:43:02 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,078 bytes |
| 記録 | |
| コンパイル時間 | 2,703 ms |
| コンパイル使用メモリ | 339,508 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-17 19:46:21 |
| 合計ジャッジ時間 | 37,605 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 24 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int q,t;
char c;
int main(){
cin >> q;
stack<char> st;
stack<bool> history;
while(q--){
cin >> t;
if(t == 1){
cin >> c;
st.push(c);
if(st.size() >= 3){
char a = st.top(); st.pop();
char b = st.top(); st.pop();
char c = st.top(); st.pop();
if(a == ')' && b == '|' && c == '('){
history.push(1);
}
else {
st.push(c);
st.push(b);
st.push(a);
history.push(0);
}
}
else {
history.push(1);
}
}
else{
int last = history.top();
history.pop();
if(last){
st.push('(');
st.push('|');
}
else{
st.pop();
}
}
cout << (st.empty() ? "Yes" : "No") << "\n";
}
}