QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#276296#7894. Many Many HeadsqkyWA 11ms3608kbC++17656b2023-12-05 19:28:362023-12-05 19:28:36

Judging History

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

  • [2023-12-05 19:28:36]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3608kb
  • [2023-12-05 19:28:36]
  • 提交

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&&n!=4)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: 3596kb

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: 0ms
memory: 3580kb

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: 11ms
memory: 3608kb

input:

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

output:

Yes
Yes
Yes
Yes
Yes
Yes
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...

result:

wrong answer expected YES, found NO [22nd token]