luogu#P8070. [BalticOI 2002] Moving Robots (Day2)

    ID: 7319 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2002Special JudgeBalticOI(波罗的海)

[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 (x,y)(x, y) and the current direction be CC: if C=0C = 0, move to (x+1,y)(x + 1, y); if C=90C = 90, move to (x,y+1)(x, y + 1); if C=180C = 180, move to (x1,y)(x - 1, y); if C=270C = 270, move to (x,y1)(x, y - 1).

  • T D: increase the direction by DD.
    That is, set the current direction C(C+D)mod360C \gets (C + D) \bmod 360.

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 RR, the number of robots.

Then for each robot:

  • The first line contains four integers x,y,C,nx, y, C, n, representing the initial position, the initial direction, and the length of the command sequence.
  • The next nn 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 1-1.

Note: Although the Special Judge ignores the carriage return at the end of a line and the final newline, do not output more than 6464 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 (2,0)(2, 0) with initial direction 270270 and has a command sequence of length 55. The second one starts at (1,1)(1, -1) with initial direction 00 and has a command sequence of length 88. 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 (2,1)(2, 1).

Constraints

2R102 \le R \le 10, 1n501 \le n \le 50, 50x,y50-50 \le x, y \le 50, C,D{0,90,180,270}C, D \in \lbrace 0, 90, 180, 270 \rbrace, 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