提出 #70734364
ソースコード 拡げる
// PriashisG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// Typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;
/*
greater<int> for large to small
less_equal for not unique
finding sz-th element --> os.find_by_order(sz); // O(log n)
finding the number of elements smaller than x --> os.order_by_szey(x); // O(log n)
os.erase(x);
*/
// Macros
#define PB push_back
#define IN insert
#define all(x) x.begin(), x.end()
#define trav(i, a) for (auto &i : a)
#define GCD __gcd
#define F first
#define S second
#define endl '\n'
#define LB lower_bound
#define UB upper_bound
#define DEBUG(i) cout << "DEBUG " << i << "\n";
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define GT(x) greater<x>()
#define setpre(n) fixed << setprecision(n)
#define SZ(x) x.size()
#define on_bit(x) __builtin_popcount(x)
// Functions
template <typename T> void pv(vector<T> &a){
for (T u : a) cout << u << ' ';
cout << '\n';
}
template <typename T> void pv2(vector<vector<T>> &a){
trav(aa, a) pv(aa);
}
template <typename T, typename U> void pvp( vector<pair<T, U>> &a){
trav(p, a) cout << "(" << p.F << ", " << p.S << ") ";
cout << '\n';
}
// Constants
const ll MOD7 = 1e9 + 7;
const ll MOD9 = 998244353;
const ll INF = LLONG_MAX;
// Custom Functions
void fast(){
ios::sync_with_stdio(false); cin.tie(0);
}
ll LCM(ll a, ll b){
return (a * b) / GCD(a, b);
}
// Custom Comparator
bool cmp(const pair<ll, ll>& x, const pair<ll, ll>& y){
if (x.F == y.F) return x.S > y.S;
else return x.F < y.F;
}
// Global Variables
void solve(ll tc){
int n;
cin >> n;
stack<char> st;
stack<int> mn;
int shuru = 0, shesh = 0, low = 0;
for (int i = 0; i < n; i++){
int type;
cin >> type;
if (type == 1){
char nibo;
cin >> nibo;
if (nibo == '(') shuru++;
else shesh++;
low = min(low, shuru - shesh);
mn.push(low);
st.push(nibo);
}
else{
char ber_hobe = st.top();
st.pop();
mn.pop();
if (ber_hobe == '(') shuru--;
else shesh--;
low = mn.empty() ? 0 : mn.top();
}
if (low >= 0 && shuru == shesh) cout << "Yes\n";
else cout << "No\n";
}
}
int main(void){
fast();
// precal();
// freopen("final_product_chapter_1_validation_input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ll t = 1;
int i = 1;
// cin >> t;
// for (ll i = 1; i <= t; i++)
solve(i);
}
提出情報
コンパイルエラー
Main.cpp: In function ‘void solve(ll)’:
Main.cpp:83:15: warning: unused parameter ‘tc’ [-Wunused-parameter]
83 | void solve(ll tc){
| ~~~^~
Main.cpp: In function ‘int main()’:
Main.cpp:128:8: warning: unused variable ‘t’ [-Wunused-variable]
128 | ll t = 1;
| ^
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
300 / 300 |
| 結果 |
|
|
| セット名 |
テストケース |
| 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 |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
2 ms |
3416 KiB |
| 01_small_00.txt |
AC |
26 ms |
3528 KiB |
| 02_random_00.txt |
AC |
48 ms |
3516 KiB |
| 02_random_01.txt |
AC |
48 ms |
3412 KiB |
| 02_random_02.txt |
AC |
48 ms |
3596 KiB |
| 02_random_03.txt |
AC |
48 ms |
3536 KiB |
| 02_random_04.txt |
AC |
48 ms |
3520 KiB |
| 02_random_05.txt |
AC |
48 ms |
3460 KiB |
| 02_random_06.txt |
AC |
48 ms |
3420 KiB |
| 02_random_07.txt |
AC |
48 ms |
3460 KiB |
| 02_random_08.txt |
AC |
47 ms |
3460 KiB |
| 02_random_09.txt |
AC |
48 ms |
3528 KiB |
| 03_corner_00.txt |
AC |
46 ms |
7368 KiB |
| 03_corner_01.txt |
AC |
45 ms |
7396 KiB |
| 03_corner_02.txt |
AC |
45 ms |
7348 KiB |
| 03_corner_03.txt |
AC |
44 ms |
7408 KiB |
| 03_corner_04.txt |
AC |
45 ms |
7328 KiB |
| 03_corner_05.txt |
AC |
46 ms |
5220 KiB |