P7225 [RC-04] Maze Walking.
Background
**This is an interactive problem.**
Please make sure you carefully read before submitting, and are familiar with the implementation style of P1947.
You can directly edit in the following sample program:
```cpp
#include
using namespace std;
extern "C" bool move_to(char position);
extern "C" string find_out_map(int X,int Y,int N){
return "233";
}
```
Also, this problem does not support Pascal. Wishing Pascal users to switch to C++ as soon as possible.
Description
### Problem Description
**This is an interactive problem.**
You are trapped in a maze, and you need to find the map of this maze.
The maze is an $n\times n$ grid. Each cell is either an obstacle or a road. Obstacles are represented by `1`, and roads are represented by `0`. Coordinates are numbered from top to bottom and from left to right; the cell in row $i$ and column $j$ has coordinates $(i,j)$.
Two cells are defined to be connected if and only if they share a common edge (4-connected). It is guaranteed that there exists exactly one connected component made of `0`, and your starting point is inside this connected component.
### Implementation Details
You need to implement a function:
`string find_out_map(int x,int y,int n)`
The parameters are three integers $x,y,n$, and the return value is a string. Here, $x,y$ indicate that your coordinate is $(x,y)$ ($1
Input Format
You cannot read this part. It contains $n$ and the map. The input file is provided in encrypted form, and the interactor will not store it in decrypted form either.
Output Format
There is no output.
Explanation/Hint
### Example Interaction Process
Suppose the map is
```
1111
1011
1001
1111
```
The initial parameters passed in are $(2,2,4)$.
The following is one valid interaction process:
| Contestant Calls | Interactor Returns |
| :----------: | :----------: |
| `move_to('S')` | 1 |
| `move_to('D')` | 1 |
| `move_to('W')` | 0 |
| Return `1111101110011111` | Accepted |
### Constraints and Limits
**The time limit for this problem is $2$ seconds, the memory limit is $512\text{MB}$, and it is guaranteed that in the worst case the interactive library uses less than $0.5$ seconds and less than $15\text{MB}$ of memory.**
First, interactive problems are subject to the same limits as regular problems. For example, TLE / MLE will cause the whole test point to score $0$.
On this basis, you score points if and only if the maze map you report is completely correct. Let the maximum number of times you call the function in a single run be $W$. Then you get full score for that test point if and only if $W\le 5\times 10^5$.
For $100\%$ of the data, $5\le n\le 500$. Let the number of times your function is called be $x$ (equivalent to multiple test cases, and you need to re-initialize), then $1\le x\le 50$. The detailed constraints are as follows, where $(T)$ means this test point is worth $T$ points.
- Test point $1\ (8)$: $n=5,x\le 50$.
- Test point $2\ (8)$: $n=7,x\le 50$.
- Test point $3\ (20)$: $n\le 10,x\le 50$.
- Test point $4\ (10)$: $n\le 500,x\le 7$. It is guaranteed that there exists exactly one connected component made of `1`.
- Test point $5\ (10)$: $n\le 20,x\le 20$.
- Test point $6\ (10)$: $n\le 50,x\le 20$.
- Test point $7\ (9)$: $n\le 100,x\le 10$.
- Test point $8\ (10)$: $n\le 200,x\le 7$.
- Test point $9\ (15)$: $n\le 500,x\le 7$.
### How to Debug an Interactive Problem
The interaction process of this problem is too simple, so this problem does not provide an interactor. Please write your own.
If you do not know how to do it: just write a program that reads the map and implements the `move_to` function, then put your solution function inside it and run.
Translated by ChatGPT 5