QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#752176#7894. Many Many Headsveg#WA 0ms3820kbC++14860b2024-11-15 22:32:472024-11-15 22:32:49

Judging History

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

  • [2024-11-15 22:32:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-11-15 22:32:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int maxn=1e5+10;

char s[maxn];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%s",s+1);
		int cnt1=0,cnt2=0,n=strlen(s+1);
		for(int i=1;i<=n;i++)
			if(s[i]=='('||s[i]==')') cnt1++;
			else cnt2++;
		if(cnt1&1||cnt2&1) puts("No");
		else
		{
			cnt1/=2,cnt2/=2;
			for(int i=1;i<=n;i++)
				if(s[i]=='('||s[i]==')')
				{
					if(cnt1>0) s[i]='(';
					else s[i]=')';
					cnt1--;	
				}
				else
				{
					if(cnt2>0) s[i]='[';
					else s[i]=']';
					cnt2--;	
				}
			for(int i=1;i<n/2;i++)
				if(s[i]==s[i+1])
				{
					puts("No");
					goto L;	
				}
			for(int i=1;i<=n/2;i++)
				if(s[i]=='('&&s[n-i+1]==')'||s[i]=='['&&s[n-i+1]==']');
				else 
				{
					puts("No");
					goto L;	
				}
			puts("Yes");L:;
		}
	}
	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: 3812kb

input:

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

output:

No
No

result:

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