#P3684. [CERC2016] 机棚障碍 Hangar Hurdles
[CERC2016] 机棚障碍 Hangar Hurdles
Description
You are evaluating construction plans for a giant airplane hangar. The hangar floor can be represented as an grid, where each cell is either empty or contains an obstacle. Rows are numbered from to from top to bottom, and columns are numbered from to from left to right.
It is important that large containers for storing airplane parts can move freely on the floor. Each container can be seen as an axis-aligned square centered at some cell. For an odd integer , a container of size is a square covering rows and columns. The coordinate of a container is the coordinate of its center cell. A container can move up, down, left, or right, but it cannot touch obstacles and cannot move outside the hangar boundary.
Given pairs of cells and , for each pair, find the maximum size (also an odd integer) of a container that can move from to .
Input Format
The first line contains a positive integer (), the size of the hangar.
The next lines each contain characters describing the hangar, where . denotes an empty cell and # denotes an obstacle.
The next line contains a positive integer (), the number of queries.
Each of the next lines contains four positive integers (), the coordinates of and .
It is guaranteed that and are distinct empty cells.
Output Format
Output lines, each with one integer. For each query, output the maximum size. If no solution exists, output .
7
.....#.
...#.#.
....#..
....###
....#..
#......
.......
5
2 5 5 2
2 5 3 6
2 2 6 3
2 2 6 6
1 1 7 7
1
0
3
1
1
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号