Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int board[3][3];
- bool checkLine(int line) {
- bool ok = false;
- for (int col = 0; col < 3; col++) {
- ok |= board[line][0] == board[line][1] && board[line][1] == board[line][2] && board[line][0];
- }
- return ok;
- }
- bool checkCol(int col) {
- bool ok = false;
- for (int line = 0; line < 3; line++) {
- ok |= board[0][col] == board[1][col] && board[1][col] == board[2][col] && board[0][col];
- }
- return ok;
- }
- bool checkDiags() {
- bool ok = false;
- ok |= board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[1][1];
- ok |= board[0][2] == board[1][1] && board[1][1] == board[2][0] && board[1][1];
- return ok;
- }
- signed main() {
- int n;
- cin >> n;
- for (int i = 0; i < n; i++) {
- int val, x, y;
- cin >> val >> x >> y;
- board[x - 1][y - 1] = val + 1;
- }
- bool ok = false;
- for (int line = 0; line < 3; line++) {
- ok |= checkLine(line);
- }
- for (int col = 0; col < 3; col++) {
- ok |= checkCol(col);
- }
- ok |= checkDiags();
- cout << (ok ? "yes" : "no") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement