Problem setter’s solution: specialized swap, sign, rotation and translation tags. Both representations take
Programs and credits: std.cpp implements the problem setter’s solution; Codex (GPT-6) contributed implementation details, boundary handling and proof exposition. For the affine matrices method used by Codex (GPT-6), see alternative.cpp and the peer method editorial.
A tag applies coordinate swapping, independent sign changes, rotation, then translation. With swap matrix
Store a swap flag, two sign flags, the rotation's sine and cosine, and two translation coordinates. Each leaf initially stores its input point as a translation. No interval coordinate sums are needed: queries request individual points, followed by a final traversal of all points.
Apply the new tag's components in order while preserving the canonical representation:
- Swap: exchange old translation coordinates and sign flags, toggle the swap flag, and negate the old sine.
- Negate one axis: negate that translation coordinate, toggle its sign flag, and negate the old sine.
- Rotate: rotate the old translation and combine sine and cosine by angle-addition identities.
- Translate: add the new translation to the transformed old translation.
The reflection steps use
Build by point index. A fully covered update appends its transformation to the node's tag. Before partial updates or point queries, append the parent tag to each child tag and reset the parent.
The invariant is that a tag represents all chronologically ordered operations not yet received by its subtree. Composition preserves this invariant. At a queried leaf, every relevant operation has acted on its initial coordinate, so the translation stored there is the answer. A final traversal yields every final point.
Building and final output take
Use long double and print eight decimal places. Both tag representations incur floating-point rounding. The supplied checker.cpp checks each coordinate with absolute tolerance
Timing and peak-memory measurements are available in environment and measurements.