#include <stdio.h> int main(void) { int length, width, height, cases; while (scanf("%d%d%d", &length, &width, &height) != EOF) { char cube[height][length][width], line[width + 2]; for (int z = 0; z < height; z++) { for (int y = 0; y < length; y++) { scanf("%s", line); for (int x = 0; x < width; x++) { cube[z][y][x] = line[x]; } } } scanf("%d", &cases); while (cases--) { int x, y, z; scanf("%d%d%d", &y, &x, &z); x -= 1; y -= 1; z -= 1; int transparent = 1; for (int index = 0; index < height && transparent; index++) { if (cube[index][y][x] == '1') { transparent = 0; } } for (int index = 0; index < length && transparent; index++) { if (cube[z][index][x] == '1') { transparent = 0; } } for (int index = 0; index < width && transparent; index++) { if (cube[z][y][index] == '1') { transparent = 0; } } puts(transparent? "YES": "NO"); } } return 0; } |
Double click to view unformatted code.