Contributions: the problem setter's solution supplies repeated-pivot adjacency queries, binary search for neighbors, and growth from both ends. Codex (GPT-6) supplies the endpoint search order and 741-query bound, protocol, implementation, local judge, and verification.
For pivot
Its length is
The setter's approach uses these tests and binary search, identifies and orients neighbors on both sides of a pivot, and extends both ends through unused labels. The implementation retains this adjacency principle and grows right first, then left, allowing at most one unsuccessful endpoint search.
Answer directly for [1,v] to orient the chosen neighbor. This gives a correctly oriented contiguous fragment.
When extending right endpoint
A reply at least 2 means the right neighbor is in that subset. To extend left, query
Keep the possibility that no neighbor exists. With
Grow right until the first absent neighbor, then switch permanently to the left. Every remaining label lies on that side, so no later search fails. A lone candidate still requires a query when its existence has not been established.
Initialization creates a correct contiguous fragment. Each successful search finds its immediate predecessor or successor, preserving that invariant. A failed right search means the fragment reaches the permutation's right endpoint. All unused labels must then extend its left side. The final fragment contains every label and is the hidden permutation.
Initialization uses at most eight neighbor tests and one orientation test. Every successful extension consumes one unused label, with
Every query has length at most 100. This is a worst-case bound, independent of random permutations or measured averages.
std.cpp is the submission; solver.hpp contains the algorithm. Flush every query and exit immediately on
judge.py holds the hidden permutation and communicates through pipes. It checks syntax, query count, the final answer, successful exit, and extra output. simulate.cpp is an offline test harness for the shared algorithm. It reads the hidden permutation and is not an interactive submission. See the testing guide.
For
Each formal input has five timing runs and a separate peak-memory run. The standard program's slowest median is 0.074435 seconds and peak memory is 5.28 MiB. Twice the median, rounded up to 0.5 seconds, gives a 0.5-second limit. See the environment and individual measurements. Recalibrate in other environments.