#include <iostream>
#include <string>
using namespace std;
enum class State { Idle, Busy, Error };
const char* toString(State s) {
switch (s) {
case State::Idle: return "Idle";
case State::Busy: return "Busy";
case State::Error: return "Error";
}
return "";
}
int main() {
int n;
cin >> n;
State state = State::Idle;
for (int i = 0; i < n; i++) {
string cmd;
cin >> cmd;
if (state == State::Error) {
continue;
}
if(cmd == "start"){
if(state == State::Idle){
state = State::Busy;
}
}else if(cmd == "done"){
if(state == State::Busy){
state = State::Idle;
}
}else if(cmd == "fail"){
if(state == State::Busy){
state = State::Error;
}
}
// implement transition logic to update state
}
cout << toString(state);
return 0;
}
Input
3 start done start
Expected Output
Busy