#P10498. 石头游戏
石头游戏
Problem Description
The stone game is played on a grid with rows and columns. Each cell corresponds to an operation sequence. There are at most kinds of operation sequences, denoted by the digits .
An operation sequence is a string of length at most that repeats in a cycle, executing one character per second.
Every second, all cells execute the next character in their own operation sequence at the same time.
Each character in a sequence is one of the following:
- A digit : move stones into this cell.
NWSE: push all stones in this cell to an adjacent cell.Nmeans up,Wmeans left,Smeans down, andEmeans right. If the operation is invalid (i.e., the stones would be pushed out of the grid), then the stones disappear.D: remove all stones from this cell.
You are given the string for each operation sequence, and for each cell in the grid, which operation sequence it uses. Find, after seconds, how many stones are in the cell that has the most stones.
At the start of the game, the grid is empty.
Input Format
The first line contains integers .
The next lines each contain characters, indicating the operation sequence used by each cell.
The last lines each contain one string, describing each operation sequence starting from .
Output Format
Output one integer: after seconds, the maximum number of stones among all cells.
1 6 10 3
011112
1E
E
0
3
Hint
For all testdata, , , .
Translated by ChatGPT 5