QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#627520 | #7894. Many Many Heads | Tytytony# | WA | 0ms | 3688kb | C++23 | 818b | 2024-10-10 16:12:36 | 2024-10-10 16:12:37 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 1000010
using namespace std;
char a[N];
int cnt,tf;
void check1(){
for(int i=0;i<cnt/2;i++){
if(a[i]!=a[cnt-i-1]) return;
if(i!=0&&a[i-1]==a[i]) return;
}
tf=1;
return;
}
void check2(){
if(cnt%4!=0) return;
for(int i=0;i<cnt/4;i++){
if(a[i]!=a[cnt/2-i-1]||a[cnt/2+i]!=a[cnt-i-1]) return;
if(i!=0&&(a[i-1]==a[i]||a[cnt/2+i-1]==a[cnt/2+i])) return;
}
if(a[cnt/2-1]==a[cnt/2]) return;
tf=1;
return;
}
int main(){
int T; cin>>T;
while(T--){
cin>>a;
cnt=0,tf=0;
for(int i=0;a[i]!=0;i++){
cnt++;
if(a[i]==')') a[i]='(';
if(a[i]==']') a[i]='[';
}
check1();
check2();
if(tf) cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
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: 3688kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]