| HPI 2024 Advanced |
|---|
| Finished |
On his visit to Paris, Lazy Bob encountered the Eiffel Tower. He thought to himself: "Wow, that's a tall tower." Also on his visit, he watched acrobats at a Cirque du Soleil event. Combining these two made him think of a genius idea: what if he made a pile of turning 'acrobats' as tall as the Eiffel Tower, but out of his favorite automobile, the truck?
The concept would be as follows: Lazy Bob would stack $$$N$$$ ($$$1 ≤ N ≤ 100,000$$$) trucks on top of a small metal ball, each having their backs placed on the fronts of the truck below it. However, all of the trucks would have cool magnetic sides, which allow them to stick to the truck below them, no problem.
However, it is pretty difficult for Bob to think about so many trucks concurrently, since his imagination can't really handle that much complexity; so he asks you to figure something out for him.
He wants to perform a specific operation: rotate a specific truck $$$r_q$$$ ($$$1 ≤ r_q ≤ N$$$) by $$$3366$$$ degrees clockwise around the front/ball below it (he chose this number because it is the biggest number he knows). When a truck $$$r_q$$$ is rotated, all of the trucks on top of it will remain in the same position relative to $$$r_q$$$ because their magnetic sides are super strong.
After each operation, Bob wants to find out the $$$x$$$ and $$$y$$$ coordinates of the head of the last truck, relative to the starting ball which is placed at the origin.
Because Bob's brain is quite mystical, each truck might have different integer lengths, represented by $$$l_i$$$ ($$$1 ≤ l_i ≤ 10,000$$$). Also, you can completely disregard any physics, so trucks can pass through other trucks and their heights and the starting ball can be treated as infinitely small (Bob does not yet know any physics). Also, the trucks can go underground into negative y-coordinates.
At the beginning, the trucks are stacked upward, so the original coordinates of the head of the last truck are ($$$0, sum(l_i)$$$). Help Bob find these coordinates after every one of the $$$Q$$$ ($$$1 ≤ Q ≤ 100,000$$$) rotation operations.
Line 1: Two space-separated integers, $$$N$$$ and $$$Q$$$ ($$$1 ≤ N, Q ≤ 100,000$$$).
Line 2: $$$N$$$ space-separated integers $$$l_1,l_2,...,l_N$$$ ($$$1 ≤ l_i ≤ 10,000$$$).
Line 3: $$$Q$$$ space-separated integers $$$r_1,r_2,...,r_q$$$ ($$$1 ≤ r_q ≤ N$$$).
Line 1…$$$Q$$$: Two space separated floating point numbers (to 3 decimal places, truncated) representing the $$$(x, y)$$$ coordinates after every one of the $$$Q$$$ queries.
2 11 12
0.809 0.412
After one rotation of the second truck, it can be shown that the final coordinates will be $$$(0.809, 0.412)$$$.
| Name |
|---|


