#P12704. Retribution
Retribution
Background

Problem Description
You are given an chessboard. Each grid point is labeled with a character $c_{i,j}\in\{\texttt{U},\texttt{D},\texttt{L},\texttt{R}\}$, representing up, down, left, and right. From a grid point, you may move to an adjacent grid point, but the moving direction must not be the same as the direction indicated by the character on the current grid point, and you must not move outside the board.
There are queries. Each query gives two grid points and asks whether it is possible to reach from by making several moves.
Input Format
To avoid oversized input, this problem uses a special input method. Please write and submit using C++11 or above.
The first line contains four positive integers , where is an input parameter.
The next lines each contain characters describing the board.
mt19937_64 R;
inline void init(int seed){
R=mt19937_64(seed);
}
inline int get(int l,int r){
uniform_int_distribution<int> distribution(l,r);
return distribution(R);
}
You need to include this code in your program, and call init(seed); during initialization.
Then, for times, call int a=get(1,n),b=get(1,m),x=get(1,n),y=get(1,m);, where describe the positions of as , representing one query.
Output Format
Output one line containing characters. The -th character is if in the -th query cannot reach , and otherwise.
2 3 6 0
RLD
RLU
2 1 1 3
2 2 1 3
2 3 1 1
2 3 1 2
1 2 2 3
1 3 2 3
010111
3 3 5 0
DRU
ULU
DRD
1 1 1 3
1 3 1 1
3 1 2 1
2 3 2 1
1 1 1 1
01111
2 3 6 10000001
RLD
RLU
111001
Hint
Retribution - Kry.exe & nm-y (Insane 16.2)
Sample Explanation
For readability, in Sample 1 and Sample 2, the queries are given directly instead of using the special input method.
For the first query of Sample 1, the grid point cannot move out of column .
For the fourth query of Sample 1, the grid point can move to and then to .
For the sixth query of Sample 1, the grid point can move to in order.
Constraints
This problem uses bundled testdata.
| Score | ||||
|---|---|---|---|---|
For all testdata, it is guaranteed that , , $c_{i,j}\in\{\texttt{U},\texttt{D},\texttt{L},\texttt{R}\}$, , , .
Subtask Dependencies
All reasonable subtask dependencies are enabled for this problem.
Translated by ChatGPT 5