Submission #70244521
Source Code Expand
#include <bits/stdc++.h>
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
using ll = long long;
using db = double;
const ll N = 1e6 + 5;
const ll md = 998244353;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db eps = 1e-6;
const db E = 2.718281828459045;
typedef pair<ll, ll> PLL;
#define fi first
#define se second
ll a[N], b[N];
void solve()
{
ll q;
cin >> q;
char c;
ll op;
stack<char> s;
ll f = 1;
ll cnt = 0;
ll x = 0, y = 0;
while (q--)
{
cin >> op;
if (op == 1)
{
cin >> c;
a[cnt] = x;
b[cnt] = y;
cnt++;
if (c == '(')
x++;
else
x--;
y = min(x, y);
if (x == 0 && y >= 0)
cout << "Yes\n";
else
cout << "No\n";
}
else
{
cnt--;
x = a[cnt];
y = b[cnt];
if (x == 0 && y >= 0)
cout << "Yes\n";
else
cout << "No\n";
}
}
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T;
T = 1;
// cin >> T;
while (T--)
{
solve();
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Brackets Stack Query |
| User | AChievedreaM |
| Language | C++ 20 (gcc 12.2) |
| Score | 300 |
| Code Size | 1386 Byte |
| Status | AC |
| Exec Time | 46 ms |
| Memory | 16020 KiB |
Compile Error
Main.cpp: In function ‘void solve()’:
Main.cpp:28:8: warning: unused variable ‘f’ [-Wunused-variable]
28 | ll f = 1;
| ^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt |
| All | 00_sample_00.txt, 01_small_00.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 03_corner_00.txt, 03_corner_01.txt, 03_corner_02.txt, 03_corner_03.txt, 03_corner_04.txt, 03_corner_05.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3512 KiB |
| 01_small_00.txt | AC | 24 ms | 3640 KiB |
| 02_random_00.txt | AC | 44 ms | 3456 KiB |
| 02_random_01.txt | AC | 45 ms | 3536 KiB |
| 02_random_02.txt | AC | 45 ms | 3544 KiB |
| 02_random_03.txt | AC | 44 ms | 3536 KiB |
| 02_random_04.txt | AC | 45 ms | 3540 KiB |
| 02_random_05.txt | AC | 44 ms | 3464 KiB |
| 02_random_06.txt | AC | 44 ms | 3464 KiB |
| 02_random_07.txt | AC | 44 ms | 3392 KiB |
| 02_random_08.txt | AC | 45 ms | 3672 KiB |
| 02_random_09.txt | AC | 44 ms | 3428 KiB |
| 03_corner_00.txt | AC | 45 ms | 16004 KiB |
| 03_corner_01.txt | AC | 45 ms | 15988 KiB |
| 03_corner_02.txt | AC | 46 ms | 15940 KiB |
| 03_corner_03.txt | AC | 44 ms | 15936 KiB |
| 03_corner_04.txt | AC | 45 ms | 16020 KiB |
| 03_corner_05.txt | AC | 42 ms | 9664 KiB |