QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#638027 | #7894. Many Many Heads | Etha# | WA | 4ms | 3640kb | C++14 | 1.1kb | 2024-10-13 14:41:21 | 2024-10-13 14:41:21 |
Judging History
answer
#include<iostream>
#include<cstdio>
#define N 100100
using namespace std;
int a[N];
int main(){
int t;
cin>>t;
string str;
while(t--){
cin>>str;
int len = str.length();
for (int i=0;i<len;i++){
if(str[i]=='('||str[i]==')') a[i+1]=1;
else a[i+1]=2;
}
int flag=0,ff=0;
if(len==2&&a[1]==a[2]){
cout<<"Yes"<<endl;
continue;
}
if(a[1]==a[2]) ff++;
if(a[len]==a[len-1]) ff++;
if(ff==2){
cout<<"No"<<endl;
continue;
}
else if(a[1]==a[2]){
for(int i=3;i<=len/2+1;i++){
if(a[i]!=a[len+3-i]||a[i]==a[i-1]) flag=1;
}
if(!flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
continue;
}
else if(a[len]==a[len-1]){
for(int i=1;i<=len/2-1;i++){
if(a[i]!=a[len-1-i]||a[i]==a[i-1]) flag=1;
}
if(a[len-1]==a[len-2]) flag=1;
if(!flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
continue;
}else{
for(int i=1;i<=len/2;i++){
if(a[i]!=a[len+1-i]||a[i]==a[i-1]) flag=1;
}
if(!flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
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: 0
Accepted
time: 0ms
memory: 3536kb
input:
2 (([([[([ ]]))])]])]
output:
Yes No
result:
ok 2 token(s): yes count is 1, no count is 1
Test #3:
score: -100
Wrong Answer
time: 4ms
memory: 3604kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes No Yes Yes No Yes No Yes Yes Yes Yes No Yes No Yes No No Yes Yes No No No No No No Yes Yes No No Yes No No No No Yes No No No No No No No No No Yes Yes No No No No No No No No No No No No Yes Yes No No No No No No No No No Yes No No No No No No No No No No Yes No No No No No No No No No No N...
result:
wrong answer expected YES, found NO [3rd token]