#include<bits/stdc++.h>
using namespace std;
char a[101];
int top;
void push(char x)
{
	if(top<101)
	{
		top++;
		a[top]=x;
	}
	return;
}
void pop()
{
	if(top>0)
	{
		top--;
	}
	return;
}
char gettop()
{
	return a[top];
}
void clear()
{
	top=0;
	return;
}
int main()
{
	string s;
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++)
	{
		if(s[i]=='(')
		{
			push(s[i]);
		}
		else if(gettop()=='(')
		{
			pop();
		}
		else
		{
			cout<<" NO";
			return 0;
		}
	}
	if(top==0)
	{
		cout<<"YES";
	 } 
	else
	{
		cout<<"NO";
	}
	return 0;
} 

@Goodnight@白起

1 comments

  • @ 2026-1-17 23:10:15

    第48的cout<<" NO";中间多输出了个空格

    • 1

    Information

    ID
    1821
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    5
    Accepted
    2
    Uploaded By