为什么这也会RE?
查看原帖
为什么这也会RE?
758581
name1ess_0123210楼主2024/6/13 13:40
#include<bits/stdc++.h>

using namespace std;

int main()
{
	string str;
	stack<char> s;
	cin>>str;
	for(int i=0;i<str.length();i++)
	{
		if(str[i]=='@')
		{
			break;
		}
		if(str[i]=='(')
		{
			s.push(str[i]);
		}
		if(str[i]==')')
		{
			if(/*!s.empty() && */s.top()=='(')
			{
				s.pop();
			}
			else
			{
				cout<<"NO";
				return 0;
			}
		}
	}
	if(s.empty())
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}

s.top()=='('不是已经说明栈非空了吗?

2024/6/13 13:40
加载中...