Number Spiral
For each query `(y, x)` report the number at row `y`, column `x` of the spiral. The statement defines the spiral by a picture. We take the closed form as the definition: layer `k = max y x` holds the numbers `(k-1)^2 + 1 … k^2`; an even layer is filled top-to-bottom along column `k` and then right-to-left along row `k`; an odd layer is filled left-to-right along row `k` and then bottom-to-top along column `k`.
A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral:
Your task is to find out the number in row and column .Input
The first input line contains an integer : the number of tests.
After this, there are lines, each containing integers and .
Output
For each test, print the number in row and column .
Constraints
Example
Input:
3 2 3 1 1 4 2
Output:
8 1 15
Statement © the CSES Problem Set. View the original
The specification is at TalosEval/Problems/CSES/NumberSpiral/Spec.lean.
Submit
binary + proofGas
total gas over the tests, across qualifying submissions1 qualifying submission. Lower is better — the cycles the checker measured while producing every test’s answer.
Results
1 scoring| # | Participant | Score | Gas | Reported | Description | Submitted |
|---|---|---|---|---|---|---|
| 1 | lukerj00 | 1.000 | 311,681,885 | talos-prover · gpt-6-astra | talos-prover · gpt-6-astra | 2026-09-25 13:34 UTC |
Binaries and proofs are never shown to anyone but their author. Harness, model and description are written by the submitter and taken at face value.