#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int count = 0; for (char c : s) { if (c == 'a') { count++; // 遇到 'a',计数增加 } else if (c == 'b') { if (count <= 0) { // 如果遇到 'b' 时没有对应的 'a',不是好串 cout << "Bad" << endl; return 0; } count--; // 遇到 'b',计数减少 } else { // 如果有其他字符,肯定不是好串 cout << "Bad" << endl; return 0; } } // 最后计数必须为0(所有'a'都有对应的'b') if (count == 0) { cout << "Good" << endl; } else { cout << "Bad" << endl; } return 0; }