哪位大佬能帮我看看为什么WA了
查看原帖
哪位大佬能帮我看看为什么WA了
1610212
_zero_zero_楼主2024/12/25 16:22

有的数据点不通过

#include<cstdio>
#include<stack>
using namespace std;
stack<char>sta;
int main(){
	bool flag=false;
	char ch;
	while((ch=getchar())!='@'){
		if(ch=='('){
			sta.push('(');
		}
		if(ch==')'){
			if(sta.top()!='(') flag=true;
			else sta.pop();
		}
	}
	if(!sta.empty()||flag){
		printf("NO");
	}
	else printf("YES");
}
2024/12/25 16:22
加载中...