問題一覧 > 通常問題

No.1226 I hate Robot Arms

レベル : / AI推定難易度 : 1600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-5}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 82
作問者 : tyawanmusi / テスター : tko919
お気に入りにしたユーザー ProblemId : 5075 / 自分の提出
問題文最終更新日: 2020-09-12 14:48:54
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 265 (順位表) の他の問題:

Notice

Because the test cases had precision errors, the maximum arm length has been changed from $10^9$ to $10$.

After a rejudge following the test case change, the results of some submissions changed from WA to AC. We apologize for the inconvenience.

Original Problem

Robot Arms
It is an interesting problem.

Problem Statement

Snuke's factory has a Robot Arm EX with the following features.

  • Robot Arm EX consists of $N$ arms and $N+1$ joints. The arms are numbered $1,2,\dots,N$ and the joints are numbered $0,1,\dots,N$. Arm $i$ connects joint $i-1$ and joint $i$.
  • An angle and a length can be specified independently for each arm.
  • Regarding the factory as a coordinate plane, the coordinates $(x_i,y_i)$ of joint $i$ are determined as follows.
    • $(x_0,y_0) = (0,0)$
    • Let $d_i$ be the length of arm $i$ and $\theta_{i}$ be the angle of arm $i$.
    • With $\phi_{i} = \theta_{1} + \theta_{2} + \dots + \theta_{i}$, we have $(x_{i},y_{i})=(x_{i-1}+d_i\cos \phi_{i},y_{i-1}+d_i\sin \phi_{i})$
  • The angle and length of each arm can be changed as follows.
    • Change the angle of arm $i$ to $X$ degrees.
    • Change the length of arm $i$ to $X$.

You are an engineer at Snuke's factory. You are given $Q$ queries in the following input format; process them.

  • Query $0$: 0 i x: Change the angle of arm $i$ to $x$ degrees.
  • Query $1$: 1 i x: Change the length of arm $i$ to $x$.
  • Query $2$: 2 i: Print the $x$ coordinate and $y$ coordinate of joint $i$ on $1$ line, separated by a space.

Initially, all arms have an angle of $0$ degrees and a length of $1$.

AC has been confirmed with PyPy, but AC has not been confirmed with Python.

Constraints

  • All input values are integers.
  • $1 \le N \le 10^5$
  • $1 \le Q \le 10^5$
  • For queries $0,1,2$, $1 \le i \le N$
  • For query $0$, $0 \le x < 360$
  • For query $1$, $1 \le x \le 10$
  • Query $2$ is given at least $1$ time.

Input

$N\ Q$
$query_1$
$query_2$
$\vdots$
$query_Q$

Line $1$ contains $N,Q$ separated by a space.
Line $1 + i$ contains the $i$-th query, separated by spaces. See the problem statement for details.

Output

Let $q$ be the number of queries $2$. Print $q$ lines.
Line $i$ should contain the result of the $i$-th query $2$.
Print a newline at the end.

Your answer is considered correct if the absolute or relative error from the expected answer is at most $10^{-5}$.

Sample

Sample 1
Input
3 8
0 1 90
0 2 270
0 3 315
1 2 2
1 3 2
2 1
2 2
2 3
Output
0.000000 1.000000
2.000000 1.000000
3.414213 -0.414213

After the $5$ queries, Robot Arm EX takes the following shape.

The coordinates of joints $1,2,3$ are $(0,1),(2,1),(2+\sqrt 2,1-\sqrt 2)$, respectively.

Sample 2
Input
1024 6
0 537 53
2 538
0 435 88
1 684 9
0 623 221
2 705
Output
537.203630046 1.597271020
461.669761237 159.235272186

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