QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627399#7894. Many Many Headshansue#WA 0ms3820kbC++14780b2024-10-10 15:48:492024-10-10 15:48:49

Judging History

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

  • [2024-10-10 15:48:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-10-10 15:48:49]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N = 1e5;

	int n, a[N + 3];
	char s[N + 3];
	
bool isbra(char ch){
	return ch == '(' || ch == ')' || ch == '[' || ch == ']';
}
	
void sol(){
	n = 1;
	while(isbra(s[n] = getchar()))
		n++;
	s[n] = '\0';
	n--;
	
	for(int i = 1; i <= n; i++)
		a[i] = (s[i] == '(' || s[i] == ')')?0:1;
	
	bool flag = true;
	for(int i = 1; flag && i + i <= n; i++){
		if(a[i] != a[n - i + 1])
			flag = false;
		if(i % 2 == 1 && a[i] != a[1])
			flag = false;
		if(i % 2 == 0 && a[i] == a[1])
			flag = false;
	}
	
	printf("%s\n", flag?"Yes":"No");
	
}

int main(){
	int T;
	scanf("%d\n", &T);
	while(T--)
		sol();

	return 0;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

No
No

result:

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