// yukicoder: No.197 手品 // 2019.5.8 bal4u // 2019.6.14 debug #include int pat[7][3][3] = { {0},{0},{0}, /* OXX */ {{3,0},{3,5,0},{3,5,6}}, {0}, /* XOX */ {{5,0},{3,6,0},{3,5,6}}, /* XXO */ {{6,0},{5,6,0},{3,5,6}}}; int main() { int i, s, t, N; char S[5], T[5]; scanf("%s%d%s", S, &N, T); s = t = 0; for (i = 0; i < 3; i++) { s = (s << 1) + (S[i]=='x'); t = (t << 1) + (T[i]=='x'); } if (s == 0 && t == 0) goto NG; if (s == 7 && t == 7) goto NG; if (s == 0 && t != 0) goto OK; if (s == 7 && t != 7) goto OK; if (s == 1 || s == 2 || s == 4) s = 7-s, t = 7-t; if (N == 0) { if (t == s) goto NG; } else if (N == 1) { for (i = 0; i < 2; i++) { if (pat[s][1][i] == t) goto NG; } } else { // if (N >= 2) { if (t == 3 || t == 5 || t == 6) goto NG; } OK: puts("SUCCESS"); return 0; NG: puts("FAILURE"); return 0; }