QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#394873#7894. Many Many Headsucup-team3294#WA 1ms3844kbC++231.0kb2024-04-20 21:02:252024-04-20 21:02:26

Judging History

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

  • [2024-04-20 21:02:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3844kb
  • [2024-04-20 21:02:25]
  • 提交

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;
	n=s.size();
	s=' '+s;
	bool flag1=false,flag2=false;
	for(int i=1;i<=n;i++)
	{
		if(flag1==false&&(s[i]=='('||s[i]==')'))
		{
			cnt1++;
		}
		else if(flag1==false&&(s[i]=='['||s[i]==']'))
		{
			flag1=true;
			cnt2++;
			//if(cnt2%2==0) flag1=false;
		}
		else if(flag1==true&&(s[i]=='['||s[i]==']'))
		{
			cnt2++;
			flag1=false;
		}
		
	}
	if(cnt1>=4)
	{
		cout<<"No"<<endl;
		return ;
	}
	cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
	{
		if(flag2==false&&(s[i]=='['||s[i]==']'))
		{
			cnt2++;
		}
		else if(flag2==false&&(s[i]=='('||s[i]==')'))
		{
			flag2=true;
			cnt1++;
			//if(cnt2%2==0) flag1=false;
		}
		else if(flag2==true&&(s[i]=='('||s[i]==')'))
		{
			cnt1++;
			flag1=false;
		}
		
	}
	if(cnt2>=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: 3844kb

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

input:

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

output:

Yes
Yes

result:

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