#P9430. [NAPC-#1] Stage2 - Darkness

[NAPC-#1] Stage2 - Darkness

Background

Problem Description

There are nn armies distributed in different places, which can be viewed on a 2D Cartesian coordinate system. They are all under kid’s unified command, and kid issues a total of mm commands.

The commands are as follows:

  • 1 p q means moving the position of every army from (xi,yi)(x_i,y_i) to (xi+p,yi+q)(x_i+p,y_i+q).
  • 2 i means applying an axis symmetry (reflection) of the position of the ii-th army over the line y=xy=x (i.e., swapping the values of xix_i and yiy_i).
  • 3 i means querying the current position of the ii-th army (i.e., output the current xix_i and yiy_i).

Note that commands 1 and 2 operate on different targets: the former affects all armies, while the latter affects only one army.

kid could have used binoculars to see directly, but it is too dark, so he asks you to write a program to tell him.

Input Format

The first line contains two positive integers n,mn,m.

The next nn lines: the ii-th line contains two integers ai,bia_i,b_i, representing the initial position of the ii-th army (xi,yi)=(ai,bi)(x_i,y_i)=(a_i,b_i).

The next mm lines: each line contains two or three integers, representing a command issued by kid. Specifically, each command starts with a positive integer opop indicating the command type:

  • If op=1op=1, then two integers p,qp,q follow, meaning moving the position of every army from (xi,yi)(x_i,y_i) to (xi+p,yi+q)(x_i+p,y_i+q).
  • If op=2op=2, then a positive integer ii follows, meaning applying an axis symmetry of the ii-th army over y=xy=x.
  • If op=3op=3, then a positive integer ii follows, meaning querying the current position of the ii-th army.

Output Format

For each 3 command issued by kid, output one line with two integers xi,yix_i,y_i, representing the current position of the ii-th army.

3 7
1 2
2 5
6 2
3 2
1 1 4
3 3
2 3
3 1
1 -9 -1
3 3
2 5
7 6
2 6
-3 6

Hint

Constraints

This problem has 1010 test points, and each test point has equal score.

  • For 20%20\% of the testdata, n,m1000n,m\leqslant 1000.
  • For another 30%30\% of the testdata, it is guaranteed that there are no 2 commands.

For 100%100\% of the testdata, 1n1051\leqslant n\leqslant 10^5, 1m5×1051\leqslant m\leqslant 5\times10^5, ai,bi,p,q103|a_i|,|b_i|,|p|,|q|\leqslant 10^3, 1in1\leqslant i\leqslant n, op{1,2,3}op\in\{1,2,3\}.

Sample Explanation

Time (x1,y1)(x_1,y_1) (x2,y2)(x_2,y_2) (x3,y3)(x_3,y_3)
Initial (1,2)(1,2) (2,5)(2,5) (6,2)(6,2)
After the 2nd command (2,6)(2,6) (3,9)(3,9) (7,6)(7,6)
After the 4th command (6,7)(6,7)
After the 6th command (7,5)(-7,5) (6,8)(-6,8) (3,6)(-3,6)

Translated by ChatGPT 5