QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#627378 | #7894. Many Many Heads | Yurily# | WA | 0ms | 3748kb | C++20 | 638b | 2024-10-10 15:44:23 | 2024-10-10 15:44:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e6+5;
int n;
string s;
bool a[MAX];
bool check1(){
for(int i=1;i<=n/2;++i){
if(i%2==1&&a[i]||i%2==0&&!a[i]||a[i]!=a[n-i+1]){
return 0;
}
}
return 1;
}
bool check2(){
for(int i=1;i<=n/2;++i){
if(i%2==0&&a[i]||i%2==1&&!a[i]||a[i]!=a[n-i+1]){
return 0;
}
}
return 1;
}
void solve(){
cin>>s;
n=s.size();
for(int i=0;i<n;++i)
if(s[i]=='('||s[i]==')')
a[i+1]=0;
else
a[i+1]=1;
if(check1()||check2()){
printf("Yes\n");
}
else
printf("No\n");
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3748kb
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: 3736kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]