結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 15:28:10 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,291 bytes |
| 記録 | |
| コンパイル時間 | 7,966 ms |
| コンパイル使用メモリ | 551,408 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-18 15:28:56 |
| 合計ジャッジ時間 | 38,588 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 24 |
ソースコード
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
#include <utility>
#include <stack>
#include <iomanip>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace atcoder;
using namespace boost::multiprecision;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using mint = modint998244353;
#define int long long
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
const ll INF = 1e18;
const int dx[8] = {0, 1, 0, -1, -1, -1, 1, 1};
const int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1};
template <typename T>
inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template <typename T>
inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
void yn(bool t) { cout << (t ? "Yes" : "No") << endl; }
uint64_t seed = chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count();
mt19937_64 rng(seed);
int randint(int l, int r)
{
return uniform_int_distribution<int>(l, r)(rng);
}
int solve()
{
int q;
cin >> q;
stack<char> s;
while (q--)
{
int t;
cin >> t;
if (t == 1)
{
char c;
cin >> c;
if (c == ')' && s.size() >= 2)
{
char s2 = s.top();
s.pop();
char s1 = s.top();
s.pop();
if (!(s1 == '(' && s2 == '|'))
{
s.push(s1);
s.push(s2);
s.push(c);
}
}
else
{
s.push(c);
}
}
else
{
if (s.size() >= 1)
{
s.pop();
}
else
{
s.push('(');
s.push('|');
}
}
yn(s.size() == 0);
}
return 0;
}
signed main()
{
#ifdef INPUT_FILE_PATH
freopen(INPUT_FILE_PATH, "r", stdin);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
solve();
return 0;
}