60分求救!!!RE了!
查看原帖
60分求救!!!RE了!
1098756
wzx2012楼主2024/8/6 22:24
#include<bits/stdc++.h>
using namespace std;
int main(){
    stack <long long> st; 
    string s;
    cin>>s;
    long long n=s.size();
    for(long long i=0;i<n;i++)
    {
    	if(s[i]=='(')
    		st.push(1);
    	if(s[i]==')')
    	{
    		if(st.top()!=1)
    		{
    			cout<<"NO";
    			return 0;
    		}
    		else
    		{
    			st.pop();
    		}
    	}
    }
    if(st.empty())
    	cout<<"YES";
    else
    	cout<<"NO";
	return 0;
}
2024/8/6 22:24
加载中...