|
@@ -0,0 +1,81 @@
|
|
|
+#include <cstdio>
|
|
|
+#include <cstring>
|
|
|
+
|
|
|
+#define X 10
|
|
|
+#define Y 9
|
|
|
+
|
|
|
+int dx[4] = {1, 0, -1, 0};
|
|
|
+int dy[4] = {0, 1, 0, -1};
|
|
|
+
|
|
|
+int hx[8] = {2, 2, 1, -1, -2, -2, 1, -1};
|
|
|
+int hy[8] = {1, -1, 2, 2, 1, -1, -2, -2};
|
|
|
+
|
|
|
+char board[X + 1][Y + 1];
|
|
|
+
|
|
|
+bool is_out(int x, int y) {
|
|
|
+ return x < 1 || X < x || y < 1 || Y < y;
|
|
|
+}
|
|
|
+
|
|
|
+bool solve(int x, int y) {
|
|
|
+ if (x < 1 || 3 < x || y < 4 || 6 < y) return true;
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ int nx = x + dx[i];
|
|
|
+ int ny = y + dy[i];
|
|
|
+ char c = 0;
|
|
|
+ int gap = 0;
|
|
|
+ while (gap < 2 && !is_out(nx, ny)) {
|
|
|
+ c = board[nx][ny];
|
|
|
+ nx += dx[i];
|
|
|
+ ny += dy[i];
|
|
|
+ if (c == 0) continue;
|
|
|
+ switch (c) {
|
|
|
+ case 'G': case 'R':
|
|
|
+ if (gap == 0) return true;
|
|
|
+ break;
|
|
|
+ case 'C':
|
|
|
+ if (gap == 1) return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ gap++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 0; i < 8; i++) {
|
|
|
+ int nx = x + hx[i];
|
|
|
+ int ny = y + hy[i];
|
|
|
+ if (is_out(nx, ny)) continue;
|
|
|
+ if (board[nx][ny] == 'H') {
|
|
|
+ nx = x + dx[i / 2];
|
|
|
+ ny = y + dy[i / 2];
|
|
|
+ if (board[nx][ny] == 0) return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+int main() {
|
|
|
+ int N, gx, gy;
|
|
|
+ for (;;) {
|
|
|
+ scanf("%d %d %d", &N, &gx, &gy);
|
|
|
+ if (N == 0 && gx == 0 && gy == 0) break;
|
|
|
+ memset(board, 0, sizeof(board));
|
|
|
+ char s[2];
|
|
|
+ int x, y;
|
|
|
+ for (int n = 0; n < N; n++) {
|
|
|
+ scanf("%s %d %d", &s, &x, &y);
|
|
|
+ board[x][y] = s[0];
|
|
|
+ }
|
|
|
+ bool checkmate = true;
|
|
|
+ for (int nx = gx + 1, ny = gy; !is_out(nx, ny); nx++) {
|
|
|
+ char c = board[nx][ny];
|
|
|
+ if (c == 0) continue;
|
|
|
+ if (c == 'G') checkmate = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ int nx = gx + dx[i];
|
|
|
+ int ny = gy + dy[i];
|
|
|
+ checkmate &= solve(nx, ny);
|
|
|
+ }
|
|
|
+ printf(checkmate ? "YES\n" : "NO\n");
|
|
|
+ }
|
|
|
+}
|