转化为:括号匹配
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;
}
京公网安备 11010502036488号