#include #define ONLINE_JUDGE using namespace std; char cell[10][10]; int getRow() { int i, j, br; for (i = 1; i <= 3; i++) { br = 0; for (j = 1; j <= 3; j++) { if (cell[i][j] == 'X') br++; } if (br < 2) return i; } return -1; } int getCol() { int i, j, br; for (j = 1; j <= 3; j++) { br = 0; for (i = 1; i <= 3; i++) { if (cell[i][j] == 'X') br++; } if (br < 2) return j; } return -1; } void init(const pair &x) { int i, j; for (i = 1; i <= 3; i++) { for (j = 1; j <=3; j++) { if (make_pair(i, j) == x) cell[i][j] = 'X'; else cell[i][j] = 'O'; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifdef ONLINE_JUDGE freopen("tictactoe.in", "r", stdin); freopen("tictactoe.out", "w", stdout); #endif // ONLINE_JUDGE pair start; int turn = 2; int row, col, i; cin >> start.first >> start.second; init(start); while (true) { /* for (i = 1; i <= 3; i++) { for (int j = 1; j <= 3; j++) { cout << cell[i][j] << ' '; } cout << '\n'; } cout << '\n' << getRow() << ' ' << getCol() << "\n\n"; */ row = getRow(); if (row > -1) { for (i = 1; i <= 3; i++) { if (cell[row][i] == 'O') { cell[row][i] = 'X'; break; } } if (turn == 2) turn = 1; else turn = 2; } else { col = getCol(); if (col > -1) { for (i = 1; i <= 3; i++) { if (cell[i][col] == 'O') { cell[i][col] = 'X'; break; } } if (turn == 2) turn = 1; else turn = 2; } else { /* for (i = 1; i <= 3; i++) { for (int j = 1; j <= 3; j++) { cout << cell[i][j] << ' '; } cout << '\n'; } */ //cout << turn << '\n'; if (turn == 1) cout << "No\n"; else cout << "Yes\n"; break; } } } return 0; }