QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#394894#7894. Many Many Headsucup-team3294#WA 1ms3636kbC++231.1kb2024-04-20 21:25:422024-04-20 21:25:43

Judging History

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

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

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;
	bool flag=false;
	for(int i=1;i<=n;i++)
	{
		if(flag1==false&&(s[i]=='['||s[i]==']')) continue;
		if(flag1==false&&(s[i]=='('||s[i]==')'))
		{
			cnt1++;
		}
		else if(flag1==false&&(s[i]=='['||s[i]==']'))
		{
			flag1=true;
		}
		else if(flag1==true&&(s[i]=='['||s[i]==']'))
		{
			flag1=false;
		}
		
	}
	if(cnt1>=4)
	{
		cout<<"No"<<endl;
		return ;
	}
	flag1=false,flag2=false;
	cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
	{
		//if(flag2==false&&s[i]=='')
		if(flag2==false&&(s[i]=='('||s[i]==')')) continue;
		if(flag2==false&&(s[i]=='['||s[i]==']'))
		{
			cnt2++;
		}
		else if(flag2==false&&(s[i]=='('||s[i]==')'))
		{
			flag2=true;
		}
		else if(flag2==true&&(s[i]=='('||s[i]==')'))
		{
			flag2=false;
		}
		
	}
	if(cnt2>=4)
	{
		cout<<"No"<<endl;
		return ;
	}
	else cout<<"Yes"<<endl;
	
}
signed main()
{
	int T;
	cin>>T;
	while(T--)
	{
		solve();
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3636kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

Yes
No
Yes
No
No
No

result:

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