提交时间:2023-12-07 19:01:58
运行 ID: 23992
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define lc(x) ((x) << 1) #define rc(x) ((x) << 1 | 1) //#define double long double #define pii pair<int,int> #define p1(x) ((x).first) #define p2(x) ((x).second) map<pii,int>S; int n; const int M=998244353; signed main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); // freopen("s4.in","r",stdin); //freopen("rec.in", "r", stdin); //freopen("rec.out", "w", stdout); cin>>n; for(int i=1;i<=n;i++){ string s; map<pii,int>ct; cin>>s; int now=0; int w=0; int len=0; for(char x:s){ if(x=='('){ now++; w=(w<<1|1)%M; } else{ now--; w=(w<<1)%M; } len++; if(now==0){ ct[{len,w}]++; len=w=0; } } for(auto e:ct){ S[p1(e)]^=p2(e); if(!S[p1(e)]) S.erase(p1(e)); } cout<<!S.empty()<<endl; } cout.flush(); return 0; }