QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#276294#7894. Many Many HeadsqkyWA 4ms3536kbC++17650b2023-12-05 19:26:562023-12-05 19:26:57

Judging History

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

  • [2023-12-05 19:26:57]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3536kb
  • [2023-12-05 19:26:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
string s;
int a[100001];
int main()
{
	int T;cin>>T;
	while(T--)
	{
		cin>>s;
		int n=s.length();s=" "+s;
		int pre=-1;bool f=true;
		for(int i=1;i<=n;i++)
		{
			if(s[i]=='('||s[i]==')')
			{
				a[i]=0;
			}
			else
			{
				a[i]=1;
			}
		}
		if(n==2){cout<<"Yes\n";continue;}
		int st=1,ed=n;
		if(a[1]==a[2]&&a[2]!=a[3])st=3;
		if(a[n]==a[n-1]&&a[n-1]!=a[n-2])ed=n-2;
		if(st==3&&ed==n-2)f=false;
		for(int i=st+1;i<=ed;i++)
		{
			if(a[i]==a[i-1]&&i!=(st+ed)/2+1)f=false;
			if(a[i]!=a[i-1]&&i==(st+ed)/2+1)f=false;
		}
		if(f)cout<<"Yes\n";else cout<<"No\n";
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 1ms
memory: 3536kb

input:

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

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: -100
Wrong Answer
time: 4ms
memory: 3424kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
No
No
No
No
No
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
N...

result:

wrong answer expected YES, found NO [3rd token]