题解 | 好串
好串
https://www.nowcoder.com/practice/9b072237ebdd4dd99562f01cbf594fac
#include<bits/stdc++.h>
using namespace std;
string s;
stack<char> st;
int main(){
cin>>s;
bool flag=true;
for(int i=0;i<s.size();i++){
if(s[i]=='a'){
st.push(s[i]);
}else{
if(st.empty()||st.top()!='a'){
flag=false;
break;
}else{
st.pop();
}
}
}
if(!st.empty()){
flag=false;
}
if(flag){
cout<<"Good"<<endl;
}else{
cout<<"Bad"<<endl;
}
return 0;
}
