WA60求条
查看原帖
WA60求条
1065925
hyacinth_lpy楼主2025/1/23 15:28
#include<bits/stdc++.h>
using namespace std;
char a[1010101];
int top;
bool pan(string s)
{
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='(' || s[i]=='[')
		{
			a[++top]=s[i];
		}
		else
		{
			if(top==0)return false;
			if(s[i]-a[top]==1 || s[i]-a[top]==2)top--;
			else return false;
		}
	}
	if(top)return false;
	return true;
}
int main()
{
	string s;
	cin>>s;
	if(pan(s))cout<<"YES";
	else cout<<"NO";
	return 0;
}

不知为何WA60分。

2025/1/23 15:28
加载中...