QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#752170#7894. Many Many Headsveg#WA 0ms3848kbC++14766b2024-11-15 22:28:022024-11-15 22:28:03

Judging History

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

  • [2024-11-15 22:28:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2024-11-15 22:28:02]
  • 提交

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;i++)
				if(s[i]==s[i+1]) goto L;
			if(s[1]=='('&&s[n]==')'||s[1]=='['&&s[n]==']')
			{
				puts("Yes");
				continue;
			}
			L:puts("No");
		}
	}
	return 0;	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

No
No

result:

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