QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627378#7894. Many Many HeadsYurily#WA 0ms3748kbC++20638b2024-10-10 15:44:232024-10-10 15:44:23

Judging History

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

  • [2024-10-10 15:44:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3748kb
  • [2024-10-10 15:44:23]
  • 提交

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();
	}
}

詳細信息

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]