#P9430. Army Movements and Queries
Army Movements and Queries
Army Movements and Queries
You are given n armies positioned on a 2D coordinate plane. The i-th army is initially located at \( (x_i, y_i) \). A commander named kid issues m commands to manipulate the positions of these armies. There are three types of commands:
- Command
1 p q
: Move every army from \( (x_i, y_i) \) to \( (x_i+p, y_i+q) \). - Command
2 i
: Reflect the i-th army with respect to the line \( y=x \), i.e. swap its coordinates from \( (x_i,y_i) \) to \( (y_i,x_i) \). - Command
3 i
: Query the current position of the i-th army, outputting its coordinates \( x_i \) and \( y_i \).
Note that the command of type 1
applies to all armies, while the command of type 2
applies only to a single specified army.
You are required to simulate the commands and output the results for each query command.
inputFormat
The first line contains two integers n and m representing the number of armies and the number of commands, respectively.
The next n lines each contain two space-separated integers \( x_i \) and \( y_i \), representing the initial coordinates of the i-th army.
The following m lines each describe a command in one of the following formats:
1 p q
: Shift every army by vector \( (p,q) \).2 i
: Reflect the i-th army over the line \( y=x \).3 i
: Query the current position of the i-th army.
It is guaranteed that i is 1-indexed.
outputFormat
For each query command (command type 3
), output a line containing two integers representing the current \( x \) and \( y \) coordinates of the queried army.
sample
3 5
1 2
3 4
5 6
3 1
1 1 1
2 2
3 2
3 3
1 2
5 4
6 7
</p>