問題一覧 > 通常問題

No.675 Dot-chans

レベル : / AI推定難易度 : 1000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 75
作問者 : nmnmnmnmnmnmnm / テスター : Pulmn
お気に入りにしたユーザー ProblemId : 1572 / 自分の提出
問題文最終更新日: 2026-06-26 06:07:46
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 188 (順位表) の他の問題:

Problem Statement

A Dot-chan is a character that can stand on integer coordinates of the XY plane.
Initially, there are no Dot-chans on the XY plane.
Dot-chans repeat the following spawning and movement exactly $N$ times.

・One Dot-chan is born at the integer coordinates ($Px$,$Py$).
・All Dot-chans follow the specified movement command on the XY plane.

The specified movement command is one of the following 3 types of commands.

Command 1: Move by $Dx$ in the positive direction of the X-axis (right).
Command 2: Move by $Dy$ in the positive direction of the Y-axis (up).
Command 3: Rotate 90 degrees clockwise around the origin.

In the end, there will be $N$ Dot-chans on the XY coordinates.
Find the final coordinates of each Dot-chan, in order starting from the Dot-chan born first.

Input

$N$ $Px$ $Py$
$Command_0$
$Command_1$
$\vdots$
$Command_{N-1}$

$N$ is the number of times Dot-chans spawn and move. $1 \le N \le 100000$.
($Px$,$Py$) are the integer coordinates where Dot-chans are born. $-1000000000 \le Px,Py \le 1000000000$.
$Command_i$ is the $i$-th specified command.
For Command 1, the digit '1' followed by the integer $Dx$ is given, separated by a space. $0 \le Dx \le 10000$.
For Command 2, the digit '2' followed by the integer $Dy$ is given, separated by a space. $0 \le Dy \le 10000$.
For Command 3, the digit '3' is given.

Output

$Ax_0$ $Ay_0$
$Ax_1$ $Ay_1$
$\vdots$
$Ax_{N-1}$ $Ay_{N-1}$

Output the Dot-chans from top to bottom in order of birth, from the 0-th to the ${N-1}$-th.
Here, ($Ax_i$,$Ay_i$) denotes the final coordinates of the $i$-th born Dot-chan.
Print a newline at the end of every line.

Sample

Sample 1
Input
2 0 1
1 3
1 4
Output
7 1
4 1

The 0-th Dot-chan is born at (0,1), moves 3 in the X-axis direction, and then moves 4 in the X-axis direction.
The 1-st Dot-chan is born at (0,1) and moves 4 in the X-axis direction.
The 0-th Dot-chan is finally at (7,1).
The 1-st Dot-chan is finally at (4,1).

Sample 2
Input
3 1 2
1 2
2 1
3
Output
3 -3
3 -1
2 -1

The 0-th Dot-chan is born at (1,2), moves 2 in the X-axis direction, moves 1 in the Y-axis direction, and rotates 90 degrees clockwise around the origin.
The 1-st Dot-chan is born at (1,2), moves 1 in the Y-axis direction, and rotates 90 degrees clockwise around the origin.
The 2-nd Dot-chan is born at (1,2) and rotates 90 degrees clockwise around the origin.
The 0-th Dot-chan is finally at (3,-3).
The 1-st Dot-chan is finally at (3,-1).
The 2-nd Dot-chan is finally at (2,-1).

Sample 3
Input
4 2 3
3
3
3
3
Output
2 3
-3 2
-2 -3
3 -2

The 0-th Dot-chan ends up back at the place where it was born.

Sample 4
Input
5 0 0
1 0
2 0
1 0
1 0
2 0
Output
0 0
0 0
0 0
0 0
0 0

All Dot-chans stay at the origin, where they were born, without moving.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。