Lapin Noir
Time limit1sMemory limit512 MB
For each starting cell on a hex grid, decide whether a cat can always reach (0, 0) while a rabbit blocks cells, except inside the cat's hexagonal territory.
- Level
Hard9 of 10
- Topics
- Game theory, Geometry, Implementation
- Solved
- No attempts yet
Problem
This city has a ground paved with regular hexagonal cells. Each cell is represented by two integers, as shown in the figure below.

A cat wants to reach the cell . A mischievous black rabbit learns of this and plans to interfere with the cat.
The black rabbit jumps to the cell where the cat is standing and can block one of the six surrounding cells or two adjacent ones. The cat picks one of the six surrounding cells that is not blocked and moves there. After each move by the cat, the black rabbit chases the cat and can block again. When the rabbit moves, its previous blocks are removed. The figure below shows a blocked position.

The city has several cells that form the cat's territory. A territory is the union of sets, where each set is the collection of cells along the perimeter of a regular hexagon. The black rabbit can enter the cat's territory but cannot block cells there. In other words, the cat can move freely inside its territory.
There are candidate starting cells, and the -th one is (). For each candidate, determine whether the cat can always reach the destination , or whether the black rabbit can interfere well enough to prevent the cat from reaching it.
Input
The first line contains (). Lines 2 through each give the six vertices of a regular hexagon that forms part of the cat's territory, listed counterclockwise.
The next line contains (). The following lines each contain the starting cell .
- (each coordinate)
Output
For each candidate starting cell, print one line per candidate. Print "YES" if the cat can always reach . Print "NO" if the black rabbit can block the cat so that it cannot reach .
Hint
