QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627520#7894. Many Many HeadsTytytony#WA 0ms3688kbC++23818b2024-10-10 16:12:362024-10-10 16:12:37

Judging History

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

  • [2024-10-10 16:12:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3688kb
  • [2024-10-10 16:12:36]
  • 提交

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;

}

詳細信息

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]