Run ID:65600

提交时间:2024-01-26 13:13:35

#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; stack<char> a; for(int i=0;i<s.size();i++){ if(s[i]=='('){ a.push(s[i]); } if(s[i]==')' && !a.empty()){ a.pop(); } } if(a.empty()){ cout<<"YES"; }else{ cout<<"NO"; } }