稻花香里说丰年,听取WA声一片
查看原帖
稻花香里说丰年,听取WA声一片
757432
laijingnian楼主2023/8/17 19:24
#include <iostream>
#include <stack>

using namespace std;

stack<string> stk;
string s;

int main()
{
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	while(cin >> s)
	{
		if(s[0] == '@') break;
		if(s[0] == '(') stk.push(s);
		else if(s[0] == ')') 
			if(stk.empty())
			{
				cout<<"NO";
				return 0;
			} 
			else stk.pop();
	}
	if(!stk.empty()) cout<<"NO";
	else cout<<"YES";
	return 0;
}

0pts

2023/8/17 19:24
加载中...