U514704 【LAR-1】Desert Explore
题目背景
[//]: # (vjudge-owner:#991849)
You are an explorer.
Your mission is to explore an ancient city in the desert.
But there's no map.
---
Your mission has changed.
Go to the desert and draw the map.
---
The whole city is covered in sand...
The only thing you know is that there are some traps around the ancient city.
You found some scrolls at the entrance of the desert, enabling you to rewind time.
But the scrolls are limited... Try your best...
题目描述
**This is an interactive problem.**
The desert can be regarded as an $n$ by $m$ rectangular area. Its upper left corner is cell $(1,1)$ while its lower right corner is $(n,m)$. The ancient city is also a rectangular area, whose upper left corner is cell $(x_1,y_1)$ and lower right corner is $(x_2,y_2)$. It is satisfied that $1\le x_1 \le x_2 \le n$ and $1\le y_1\le y_2\le m$.
When you ask a question, you must give the interactive lib an initial position $(x_0,y_0)$ satisfying $1\le x_0\le n,1\le y_0\le m$ and your moves. Your moves shall be represented by a string $s$ containing only characters `WASD`, which represents the directions of your moves. The interactive lib will tell you when you will fall into a trap.
Traps are positions $(i,j)$ satisfying $i\in\{x_1,x_2\},j\in[y_1,y_2]$ or $i\in[x_1,x_2],j\in\{y_1,y_2\}$。
Ask no more than $2$ questions to find out the value of $x_1,x_2,y_1,y_2$.
输入格式
Input contains two integers $n$ and $m$.
Output `? x0 y0 s` to ask a question. $(x_0,y_0)$ is your initial position and $s$ is your move direction sequence.
The interactive lib will output an integer $x$ between $-1$ and $|s|$:
- $x=-1$ means that you never falls into a trap or goes out of the desert.
- $x=0$ means that you have already fallen into a trap or gone out of the desert when you're at the initial position $(x_0,y_0)$.
- Otherwise it means that you will fall into a trap or go out of the desert after the $x$-th move.
If you find the answer, output `! x1 y1 x2 y2` and quit the program immediately.
输出格式
See **Input Format**.
Please make sure that your output is legal, or the result may be unpredictable.
说明/提示
### Sample Explanation
The desert is like this: (`#` means ancient city while `.` means empty ground)
```plain
.##..
.##..
.##..
.....
.....
```
In the Sample, the participant asks only $2$ questions and answered correctly. He gets full marks in this test case.
### Constraints
- $1\le n,m\le10^3$.
- The interactive lib will not exceed time limit if your output contains no more than $10^7$ characters.
### Scoring
- If the anwer is incorrect, participant gets no points.
- If an error of TLE, MLE or RE occurs, participant gets no points.
- Otherwise, participant gets points based on the number of questions he asks $x$:
| Range of $x$ | Percentage of points gain |
|:-:|:-:|
| $0\sim2$ | $100\%$ |
| $3$ | $80\%$ |
| $4$ | $50\%$ |
| $5$ | $20\%$ |
| $6$ or more | $0\%$ |
There are $10$ test cases in this problem and each of them is $10$ points.
### Hints
`WASD` represents:
- `W`: $(x,y)\rightarrow(x-1,y)$
- `A`: $(x,y)\rightarrow(x,y-1)$
- `S`: $(x,y)\rightarrow(x+1,y)$
- `D`: $(x,y)\rightarrow(x,y+1)$