#include #include #include using namespace std; int main() { map stateGroups; map stateIds; stateGroups["xxx"] = 0; stateGroups["xxo"] = 1; stateGroups["xox"] = 1; stateGroups["xoo"] = 2; stateGroups["oxx"] = 1; stateGroups["oxo"] = 2; stateGroups["oox"] = 2; stateGroups["ooo"] = 3; stateIds["xxo"] = 0; stateIds["xox"] = 1; stateIds["xoo"] = 0; stateIds["oxx"] = 2; stateIds["oxo"] = 1; stateIds["oox"] = 2; int minTransitions[3][3] = { 0, 1, 2, 1, 2, 1, 2, 1, 0 }; string sBefore; int n; string sAfter; cin >> sBefore >> n >> sAfter; if (stateGroups[sBefore] != stateGroups[sAfter]) { cout << "SUCCESS" << endl; return 0; } int group = stateGroups[sBefore]; if (group == 0 || group == 3) { cout << "FAILURE" << endl; return 0; } if (stateIds[sBefore] == 1 && stateIds[sAfter] == 1 && n == 0) { cout << "FAILURE" << endl; return 0; } if (n >= minTransitions[stateIds[sBefore]][stateIds[sAfter]]) { cout << "FAILURE" << endl; return 0; } cout << "SUCCESS" << endl; return 0; }