/* -*- coding: utf-8 -*- * * 870.cc: No.870 無敵囲い - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int H = 9; const int W = 9; const int M = 3; const int sts[M][2] = { {1, 7}, {2, 8}, {6, 8} }; const int gls[M][2] = { {4, 7}, {3, 7}, {5, 7} }; // (2,8),(3,9),(7,9) -> (5,8),(4,8),(6,8) /* typedef */ /* global variables */ int flds[H][W]; /* subroutines */ inline int xy2p(int x, int y) { return y * W + x; } /* main */ int main() { for (int y = 0; y < H; y++) for (int x = 0; x < W; x++) flds[y][x] = xy2p(x, y); int n; scanf("%d", &n); while (n--) { int x0, y0, x1, y1; scanf("%d%d%d%d", &x0, &y0, &x1, &y1); x0--, y0--, x1--, y1--; flds[y1][x1] = flds[y0][x0]; flds[y0][x0] = -1; } for (int i = 0; i < M; i++) { int sti = xy2p(sts[i][0], sts[i][1]); if (flds[gls[i][1]][gls[i][0]] != sti) { puts("NO"); return 0; } } puts("YES"); return 0; }