QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665488#7894. Many Many Headsqzez#WA 0ms3832kbC++14676b2024-10-22 13:29:522024-10-22 13:29:52

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 13:29:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3832kb
  • [2024-10-22 13:29:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T,n,b[N];
char a[N];
int main(){
    scanf("%d",&T);
    for(;T--;){
        scanf("%s",a+1),n=strlen(a+1);
        static int top,stk[N];
        for(int i=1;i<=n;i++)b[i]=a[i]=='('||a[i]==')';
        top=0;
        for(int i=1;i<=n;i++){
            if(top&&stk[top]==b[i])top--;
            else stk[++top]=b[i];
        }
        if(top){
            puts("No");
            continue;
        }
        bool flag=1;
        for(int i=1;i<n/2;i++)if(b[i]==b[i+1])flag=0;
        for(int i=1;i<=n/2;i++)if(b[i]!=b[n+1-i])flag=0;
        puts(flag?"Yes":"No");
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3832kb

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: 3640kb

input:

2
(([([[([
]]))])]])]

output:

No
No

result:

wrong answer expected YES, found NO [1st token]