#P4601. [HEOI2012] 野外探险
[HEOI2012] 野外探险
Description
Using a GPS system, they obtained a rough map of the rainforest. The map is an -by- character grid: '.' denotes empty ground, '*' denotes impassable terrain, '#' denotes an area that needs to be cleared, and 'H' marks Xiao H's position, which is also empty ground.
There are types of movements, denoted by , (). If they are currently at row , column , then their next position can be row , column , or the opposite direction, row , column . Each day, they may choose exactly one movement type and move a positive number of steps continuously in the forward or backward direction, then stop; they are not allowed to stay put.
During that day’s movement, they may not enter any impassable cells ('*'). If they reach a cell marked '#', they stop moving immediately. For the rest of the day, they clear that cell; afterwards, it permanently becomes empty ground ('.').
They send you queries over the network, asking for the number of cells they can reach on day (). It is guaranteed that there is no situation where they cannot move at all. Can you help them?
Input Format
- The first line contains three positive integers , , and .
- Lines to : each line contains characters (each is one of '.', '*', '#', 'H'; there is exactly one 'H').
- Lines to : each line contains two integers and (not both ).
- Line : a single integer .
- Lines to : each of the next lines contains one integer , the queried day.
Output Format
Output lines. For each query, output the number of cells that can be reached on day .
3 3 2
H#.
*..
…
1 0
0 1
2
1
2
1
4
Hint
Constraints:
- For 20% of the testdata, , .
- For 70% of the testdata, .
- For 100% of the testdata, , , , .
HEOI 2012 Day 2 Task 3.
Translated by ChatGPT 5
京公网安备 11011102002149号