QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#612779 | #7894. Many Many Heads | wzxtsl# | WA | 0ms | 3544kb | C++23 | 845b | 2024-10-05 12:53:24 | 2024-10-05 12:53:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
int n,m;
int getss(char c){
if(c=='('||c==')')return 0;
if(c=='['||c==']')return 1;
}
void solve(){
cin>>n;
string s;
for(int i=1;i<=n;i++){
cin>>s;
if(s.length()%2==1){
cout<<"No"<<endl;
continue;
}
int tp=getss(s[0]);int fl=0;
for(int j=1;j<s.length()/2;j++){
if(tp==getss(s[j])^1) {tp=tp^1;continue;}
else {
cout<<"No"<<endl;
fl=1;
break;
}
}
if(!fl)
cout<<"Yes"<<endl;
}
}
signed main(){
fast;
int t=1;
//cin>>t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
6 )) ((() [()] ()[()]() ([()]) ([])([])
output:
Yes No Yes No Yes No
result:
ok 6 token(s): yes count is 3, no count is 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3528kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]