CF618E.Robot Arm

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

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 ii and picking some positive ll . This change happens as follows: the red endpoint of segment number ii and segments from 11 to i1i-1 are all fixed in place. Imagine a ray from the red endpoint to the blue endpoint. The blue endpoint and segments i+1i+1 through nn are translated ll units in the direction of this ray. In this picture, the red point labeled AA and segments before AA stay in place, while the blue point labeled BB and segments after BB gets translated.
  2. He can choose a segment and rotate it. This is denoted as choosing the segment number ii , and an angle aa . The red endpoint of the ii -th segment will stay fixed in place. The blue endpoint of that segment and segments i+1i+1 to nn will rotate clockwise by an angle of aa degrees around the red endpoint. In this picture, the red point labeled AA and segments before AA stay in place, while the blue point labeled BB and segments after BB get rotated around point AA .

Roger will move his arm mm 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.

输入格式

The first line of the input will contain two integers nn and mm ( 1<=n,m<=3000001<=n,m<=300000 ) — the number of segments and the number of operations to perform.

Each of the next mm lines contains three integers xix_{i} , yiy_{i} and ziz_{i} describing a move. If xi=1x_{i}=1 , this line describes a move of type 11 , where yiy_{i} denotes the segment number and ziz_{i} denotes the increase in the length. If xi=2x_{i}=2 , this describes a move of type 2, where yiy_{i} denotes the segment number, and ziz_{i} denotes the angle in degrees. ( 1<=xi<=2,1<=yi<=n,1<=zi<=3591<=x_{i}<=2,1<=y_{i}<=n,1<=z_{i}<=359 )

输出格式

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

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

输入输出样例

  • 输入#1

    5 4
    1 1 3
    2 3 90
    2 5 48
    1 4 1
    

    输出#1

    8.0000000000 0.0000000000
    5.0000000000 -3.0000000000
    4.2568551745 -2.6691306064
    4.2568551745 -3.6691306064
    

说明/提示

The following pictures shows the state of the arm after each operation. The coordinates of point FF 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 BB is the blue endpoint for segment 11 and also the red endpoint for segment 22 .

Initial state:

Extend segment 11 by 33 . Rotate segment 33 by 9090 degrees clockwise. Rotate segment 55 by 4848 degrees clockwise. Extend segment 44 by 11 .

首页