Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)
E
Robot Arm
Codeforces
2500
原题
← DF →
翻译中…

Roger is a robot. He has an arm that is a series of $*n*$ segments connected to each other. The endpoints of the $*i*$-th segment are initially located at points $(*i* - 1, 0)$ and $(*i*, 0)$. The endpoint at $(*i* - 1, 0)$ is colored red and the endpoint at $(*i*, 0)$ is colored blue for all segments. Thus, the blue endpoint of the $*i*$-th segment is touching the red endpoint of the $(*i* + 1)$-th segment for all valid $*i*$.

翻译中…

Roger can move his arm in two different ways:

翻译中…
  1. He can choose some segment and some value. This is denoted as choosing the segment number $*i*$ and picking some positive $*l*$. This change happens as follows: the red endpoint of segment number $*i*$ and segments from $1$ to $*i* - 1$ are all fixed in place. Imagine a ray from the red endpoint to the blue endpoint. The blue endpoint and segments $*i* + 1$ through $*n*$ are translated $*l*$ units in the direction of this ray. image image In this picture, the red point labeled $*A*$ and segments before $*A*$ stay in place, while the blue point labeled $*B*$ and segments after $*B*$ gets translated.
  2. He can choose a segment and rotate it. This is denoted as choosing the segment number $*i*$, and an angle $*a*$. The red endpoint of the $*i*$-th segment will stay fixed in place. The blue endpoint of that segment and segments $*i* + 1$ to $*n*$ will rotate clockwise by an angle of $*a*$ degrees around the red endpoint. image image In this picture, the red point labeled $*A*$ and segments before $*A*$ stay in place, while the blue point labeled $*B*$ and segments after $*B*$ get rotated around point $*A*$.
翻译中…

Roger will move his arm $*m*$ times. These transformations are a bit complicated, and Roger easily loses track of where the blue endpoint of the last segment is. Help him compute the coordinates of the blue endpoint of the last segment after applying each operation. Note that these operations are cumulative, and Roger's arm may intersect itself arbitrarily during the moves.

翻译中…

Input

翻译中…

The first line of the input will contain two integers $*n*$ and $*m*$ ($1 ≤ *n*, *m* ≤ 300 000$) — the number of segments and the number of operations to perform.

翻译中…

Each of the next $*m*$ lines contains three integers $*x*_{*i*}$, $*y*_{*i*}$ and $*z*_{*i*}$ describing a move. If $*x*_{*i*} = 1$, this line describes a move of type $1$, where $*y*_{*i*}$ denotes the segment number and $*z*_{*i*}$ denotes the increase in the length. If $*x*_{*i*} = 2$, this describes a move of type 2, where $*y*_{*i*}$ denotes the segment number, and $*z*_{*i*}$ denotes the angle in degrees. ($1 ≤ *x*_{*i*} ≤ 2, 1 ≤ *y*_{*i*} ≤ *n*, 1 ≤ *z*_{*i*} ≤ 359$)

翻译中…

Output

翻译中…

Print $*m*$ lines. The $*i*$-th line should contain two real values, denoting the coordinates of the blue endpoint of the last segment after applying operations $1, ..., *i*$. Your answer will be considered correct if its absolute or relative error does not exceed $10^{ - 4}$.

翻译中…

Namely, let's assume that your answer for a particular value of a coordinate is $*a*$ and the answer of the jury is $*b*$. The checker program will consider your answer correct if image for all coordinates.

翻译中…

Note

翻译中…

The following pictures shows the state of the arm after each operation. The coordinates of point $*F*$ are printed after applying each operation. For simplicity, we only show the blue endpoints of a segment (with the exception for the red endpoint of the first segment). For instance, the point labeled $*B*$ is the blue endpoint for segment $1$ and also the red endpoint for segment $2$.

翻译中…

Initial state:

翻译中…

image

翻译中…

Extend segment

翻译中…

1

翻译中…

by

翻译中…

3

翻译中…

.

翻译中…

image

翻译中…

Rotate segment

翻译中…

3

翻译中…

by

翻译中…

90

翻译中…

degrees clockwise.

翻译中…

image

翻译中…

Rotate segment

翻译中…

5

翻译中…

by

翻译中…

48

翻译中…

degrees clockwise.

翻译中…

image

翻译中…

Extend segment

翻译中…

4

翻译中…

by

翻译中…

1

翻译中…

.

翻译中…

image

翻译中…

样例

Input #1
5 4
1 1 3
2 3 90
2 5 48
1 4 1
Output #1
8.0000000000 0.0000000000
5.0000000000 -3.0000000000
4.2568551745 -2.6691306064
4.2568551745 -3.6691306064
InputCopy OutputCopy
题目信息
题号
618E
时间限制
8 s
内存限制
256 MB
标签
数据结构
计算几何

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。