题解 | #好串#

好串

https://ac.nowcoder.com/acm/problem/21874

转化为:括号匹配

Code

#include <bits/stdc++.h>

using namespace std;

const int N = 100;

char s[N];

int main(){
    cin>>s+1;
    int d=0; bool op=false;
    for(int i=1;s[i];i++){
       if(s[i]=='a') d++;
        else {
           if(d<=0)    op=true;  
           d--;  
        }
    }

    if(op||d) puts("Bad");
    else puts("Good");

    return 0;
}
全部评论

相关推荐

点赞 评论 收藏
分享
2025-12-16 17:17
门头沟学院 产品经理
烤点老白薯:他第二句话的潜台词是想让你帮他点个瑞幸或者喜茶啥的
mt对你说过最有启发的一...
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务