17 solutions

  • 0
    @ 2022-1-1 21:53:42

    日常蒟蒻确认

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	char wuhu[2000];
    	stack<char> s;
    	cin>>wuhu;
    	for(int i=0;wuhu[i]!='@';i++)
    	{
    			if(wuhu[i]=='(')
    			{
    			s.push(wuhu[i]);//放栈里 
    			}
    			else if(wuhu[i]==')')
    			{
    				if(!s.empty())//栈不空说明有'(' 
    				{
    				s.pop();//配对啦出来吧你 
    				}
    				else//空了 好吧重开 
    				{
    					cout<<"NO";
    					return 0;//这里还是看了大佬
    				}
    			}
    		}
    		if(!s.empty())//再看看栈空不空 
    		cout<<"NO";
    		else
    		cout<<"YES";
    	return 0;
    }
    

    Information

    ID
    289
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    5
    Tags
    # Submissions
    234
    Accepted
    87
    Uploaded By