**思路: 碰到'a'或者此时空栈 -》》字符入栈 碰到'b'并且此时非空栈-》》不符合题意,终止判断
检测完毕 -》》排除是否此时为空栈(符合题意的字符串此时栈一定为空)**
#include<bits/stdc++.h>
#define io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<int,int> PII;
stack<char>_st;
bool flag=true;
int main()
{
string x;
getline(cin,x);
cin>>x;
for(int i=0;i<x.size();i++)
{
if(x[i] == 'a' || _st.empty())
{
_st.push(x[i]);
}
else if(x[i] == 'b' && !_st.empty())
{
char c=_st.top();
if(c != 'a')
{
flag=false;
break;
}
else
{
_st.pop();
}
}
}
if(!_st.empty())flag=false;
if(flag)
{
puts("Good");
}
else
{
puts("Bad");
}
return 0;
}