```
#include<bits/stdc++.h>
using namespace std;
int main()
{
stack<char> n;
string s;
cin >> s;
for(int i = 0;i < s.length();i++)
{
if(s[i] == '(') n.push(s[i]);
else if(s[i] == ')')
{
if(!n.empty()) n.pop();
else{
cout << "NO";
return 0;
}
}
}
if(n.empty()) cout << "YES";
else cout << "NO";
return 0;
}
by Null_h @ 2023-09-01 15:12:13
谢谢大佬
by zengziyuezzy @ 2023-09-01 15:13:45