90分求助第三个WA
查看原帖
90分求助第三个WA
774204
A_chicken_boy楼主2022/8/17 14:40
#include<bits/stdc++.h>
using namespace std;
string a;
int top=0,top1=0;int b[999999],c[999999];
int main(){
	getline(cin,a);
	if(a[0]==')'){
		cout<<"NO";
		return 0;
	}
	int l=a.size()-2;
	if(a[l]=='('){
			cout<<"NO";
		return 0;
	}
	for(int i=0;i<=l;i++){
		if(a[i]=='('){
		
			top++;
		} if(a[i]==')'&&top>top1&&top!=0){
			top1++;
	   }
	}
	if(top==top1){
		cout<<"YES";
	}else cout<<"NO";
	return 0;
}```
2022/8/17 14:40
加载中...