misholovac
You're given labyrinth of dimensions M x N. Exactly one field maze containing cheese, while the other fields, are either passage or a wall. There is cat and mouse in certain initial positions. They move one after another,in turns. The mouse moves first. In its turn cat or the mouse can move to a neighboring field (the fields that are also adjacent diagonal), or to remain in the same field. When moving cats on a field where the mouse is it eats it, while moving the mouse on the field where the cheese is he eats the cheese. THe cat can not move to the field where the cheese is. The cat always knows the exact position of the mouse and vice versa. The aim of the mouse to eat cheese and cats to prevent it, regardless of whether you eat or not. Examine what will happen to the two at their optimal motion.
InputIn the first line of the standard input are the dimensions maze M and N, where m is the number of species, a number of columns (1 <= M, N <= 50). In each of the following M lines are N characters that describe a labyrinth. Character "*" is a field where the cheese is, "X" field that contains the wall, while "." a blank field. Other characters will not appear. The next line is the number of P (1 <= P <= 8), and the number of pairs of initial position of cat and mouse that are examined. In each of the following P rows are four in number. The first pair of numbers represents the coordinates of the mouse (the first number of species, then the number of columns), and the other cats. Upper left-field maze has coordinates (1, 1), and lower-right (m, n).
OutputTo the standard output you should print P lines. For i-th position in a few cat and mouse from the input file and-line output file you should enter 1 if the mouse manages to eat cheese, a 0 if the cat can prevent it.
Input
Output:
4 3
.*.
...
.X.
...
2
3 1 3 3
4 2 2 2
Output:
1
0Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.