結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー cho435
提出日時 2026-04-18 01:38:19
言語 C++23(gnu拡張)
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,171 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,665 ms
コンパイル使用メモリ 375,960 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2026-04-18 01:38:30
合計ジャッジ時間 10,477 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
	return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
	return x < y ? (x = y, true) : false;
}

using mint = atcoder::modint998244353;

void solve() {
	int q;
	cin >> q;
	vector<int> v;
	int m = 100;
	auto add = [&]() {
		char c;
		cin >> c;
		if (c == '(') v.push_back(1);
		else if (c == '|') {
			if (!v.empty() && v.back() == 1) v.back()++;
			else v.push_back(m + 1);
		} else if (c == ')') {
			if (!v.empty() && v.back() == 2) v.pop_back();
			else v.push_back(m + 1);
		} else assert(0);
	};
	auto del = [&]() {
		if (v.empty()) v.push_back(2);
		else {
			v.back()--;
			if (v.back() == 0 || v.back() == m) v.pop_back();
		}
	};
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) add();
		else del();
		if (v.empty()) cout << "Yes\n";
		else cout << "No\n";
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	int t = 1;
	// cin >> t;
	while (t--) solve();
}
0