QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#394910#7894. Many Many Headsucup-team3294#WA 16ms3608kbC++23801b2024-04-20 21:37:502024-04-20 21:37:51

Judging History

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

  • [2024-04-20 21:37:51]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:3608kb
  • [2024-04-20 21:37:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
	int n;
	string s;
	cin>>s;
	int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
	n=s.size();
	s=' '+s;
	bool flag1=false,flag2=false;
	bool flag=false;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='('||s[i]==')')
		{
			if(cnt2%2==0) cnt1++;
			else cnt3++;
		}
		else 
		{
			cnt2++;
		}
		
	}
	if(cnt1>=4||cnt3>=4)
	{
		cout<<"No"<<endl;
		return ;
	}
	flag1=false,flag2=false;
	cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='['||s[i]==']')
		{
			if(cnt1%2==0) cnt2++;
			else cnt4++;
		}
		else 
		{
			cnt1++;
		}
		
	}
	if(cnt2>=4||cnt4>=4)
	{
		cout<<"No"<<endl;
		return ;
	}
	else cout<<"Yes"<<endl;
	
}
signed main()
{
	int T;
	cin>>T;
	while(T--)
	{
		solve();
	}
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3608kb

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

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: 16ms
memory: 3540kb

input:

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

output:

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

result:

wrong answer expected YES, found NO [36th token]