luogu#P8070. [BalticOI 2002] Moving Robots (Day2)
[BalticOI 2002] Moving Robots (Day2)
Problem Description
Some robots move on a 2D plane according to commands. The robots do not affect each other during movement; even at the same time and the same point, there may be multiple robots.
There are two kinds of moves:
-
S: move forward one step.
Let the current position be and the current direction be : if , move to ; if , move to ; if , move to ; if , move to . -
T D: increase the direction by .
That is, set the current direction .
Given the preset command sequence of each robot, remove some commands so that all robots finally end up at the same position, and minimize the number of removed commands.
Input Format
The first line contains an integer , the number of robots.
Then for each robot:
- The first line contains four integers , representing the initial position, the initial direction, and the length of the command sequence.
- The next lines each contain one command. The format is as described in the statement.
Output Format
If it is possible to make all robots finally end up at the same position, output two lines:
- The first line contains an integer, the minimum number of removed commands.
- The second line contains two integers, the coordinates of the final position under the minimum number of removed commands (if there are multiple valid answers, output any one).
If it is impossible to make all robots finally end up at the same position, output one line containing .
Note: Although the Special Judge ignores the carriage return at the end of a line and the final newline, do not output more than characters, otherwise you will get Wrong Answer.
2
2 0 270 5
S
T 180
S
S
S
1 -1 0 8
S
S
T 90
S
T 270
S
T 90
S
2
2 1
Hint
Sample Explanation
There are two robots. The first one starts at with initial direction and has a command sequence of length . The second one starts at with initial direction and has a command sequence of length . At least two commands must be removed. For example, remove the third command of the first robot and the fifth command of the second robot; then the final position is .
Constraints
, , , , and it is guaranteed that the command format is as described in the statement.
Notes
BalticOI 2002 Day2 C.
Due to the configuration of a custom scoring script, for now only verdicts other than AC, WA, TLE, and MLE are not supported for display. If you get any other verdict, you will get UKE.
The Subtask settings are unrelated to the problem, and exist only to make the custom scoring script easier to run.
Translated by ChatGPT 5