@[shooting__star](/user/955954) 你没考虑一种情况
如果遍历到右括号已经没有左括号可以配对了,要直接输出NO
by ICU152_QWQ_IS8 @ 2024-01-05 23:52:09
+1
------------
~~qp~~
by _L_i_n_k_ @ 2024-01-06 08:34:15
@[ISU152_YYDS](/user/933802) 谢谢大佬,我也错这了
by joseph0530 @ 2024-01-16 09:22:45
@[ISU152_YYDS](/user/933802) 加上也不对啊
```cpp
#include<bits/stdc++.h>
using namespace std;
int cnt=0,l;
char a[500001];
int main(){
cin>>a+1;
l=strlen(a+1);
for(int i=1;i<=l;++i){
if(a[i]=='(') cnt++;
else if(a[i]==')'&&cnt>0) cnt--;
if(a[i]=='@') break;
if(cnt<0) break;
}
if(cnt==0) cout<<"YES";
else cout<<"NO";
return 0;
}
```
帮我调下呗
by joseph0530 @ 2024-01-16 09:24:58
```cpp
#include<bits/stdc++.h>
using namespace std;
int cnt=0,l;
char a[500001];
int main(){
cin>>a+1;
l=strlen(a+1);
for(int i=1;i<=l;++i){
if(a[i]=='(') cnt++;
else if(a[i]==')') cnt--;
if(a[i]=='@') break;
if(cnt<0) break;
}
if(cnt==0) cout<<"YES";
else cout<<"NO";
return 0;
}
```
把else if里的cnt>0给去掉
by liyuteng @ 2024-01-17 14:41:26
@[liyuteng](/user/807403) ,其实可以这样:
while(1){
cin>>a;
if(a=='@') break;
if(a=='('){
cnt1++;
}
else if(a==')'){
cnt2++;
}
}
by my_name_qunge @ 2024-01-30 11:42:39