2025 ICPC Asia Seoul Regional Preliminary Solution Sketches

Disclaimer: This is an unofficial analysis of some possible ways to solve the problems of the 2025 ICPC Asia Seoul Regional Preliminary. They are not intended to give complete solutions, but rather to outline some approaches that can be used to solve the problems. If you find an error, please send me an email about it.

F. Inverse Look-and-Say

My solution: 239 bytes.

Read the input as a string SS. If ∣S∣\lvert S \rvert is odd, S[1]=0S[1] = 0, S[2i]=0S[2i] = 0, or S[2i+1]=S[2i+3]S[2i + 1] = S[2i + 3], then print −1-1.

Otherwise, for each 0≤i<∣S∣/20 \le i < \lvert S \rvert / 2, print S[2i+1]S[2i+1] S[2i]S[2i] times.

A. Best Partition

My solution: 346 bytes.

Let DcD_c denote the answer for the first cc elements. Compute DP in O(n2)O\left( n^2 \right).

Note that it can be solved in O(n)O(n).

H. Mountain

My solution: 354 bytes.

Sort the points (x,y)(x, y) by 107×(x−y)−y10^7 \times (x - y) - y, then take a longest strictly increasing sequence of x+yx + y.

I. Quadratic Equation

My solution: 114 bytes.

Let α\alpha and β\beta be the roots of the equation x2+px+kp=0x^2 + px + kp = 0.

Since (α+k)(β+k)=k2>0(\alpha + k)(\beta + k) = k^2 > 0 and p=2k−(α+k)−(β+k)p = 2k - (\alpha + k) - (\beta + k), we have Np=2×∣{n∈Z∩[1,∣k∣]:n∣k2}∣N_p = 2 \times \left\lvert \left\{ n \in \mathbb{Z} \cap \left[ 1, \lvert k \rvert \right] : n \mid k^2 \right\} \right\rvert, and ∑p=2k×Np\sum p = 2k \times N_p.

C. Docking Day

My solution: 865 bytes.

Send all the points to +∞+\infty in 33 moves; then ≤5\le 5 more moves always suffice to place them at their target positions.

Hence, we need 8−3=58 - 3 = 5 extra coordinates beyond the 66 critical ones. Insert up to 55 auxiliaries into the 77 gaps determined by 00, the 66 critical coordinates, and +∞+\infty; then run BFS over (6+5×7)3=413(6 + 5 \times 7)^3 = 41^3 states.

J. Rescue Squad

My solution: 1,053 bytes.

Reindex the vertices in nondecreasing degree, and orient each edge from the smaller to the larger index. With this orientation, each vertex has O(m)O\left( \sqrt{m} \right) outgoing edges.

Handle all three C4C_4 configurations in O(nm)O\left( nm \right) total time.

B. Bridge

My solution: 1,440 bytes.

Sweep the path left-to-right, maintaining a stack of downward segments that can host the bridge's left endpoint.

For each chosen pair of host segments, minimize the maximum of three linear functions; only their pairwise intersection points are relevant, but I suggest using ternary search due to floating-point error.

E. Image Analysis

My solution: 2,016 bytes.

Since all xx and yy are distinct, when the frame moves by Manhattan distance dd, the in-frame set changes by O(d)O(d) single-point updates.

Apply standard Mo's ordering over frames, and answer the queries with square-root decomposed bucket sums.

D. Fox Buki

My solution: 1,602 bytes.

Construct a bipartite graph: add an edge (i−,j+)(i^-, j^+) for each card of type jj owned by fan ii. The graph is nn-regular, so it decomposes into nn perfect matchings.

In matching kk, if (i−,j+)(i^-, j^+) is chosen, define fan ii's kk-th card to be of type jj. Then swapping fan aa's bb-th card with fan bb's aa-th card achieves the goal, with each card used at most once.

G. Magical Sort

My solution: 1,664 bytes.

Build a directed graph GG: if uu's group-cc receiver is vv, add an edge v→uv \rightarrow u with label cc. For every vertex, all outgoing edges share the same label.

Put v∈[Sv]v \in \left[ S_v \right] if every infinite walk from vv yields the same edge-label string SvS_v. The answer is ∏S∣[S]∣!\prod_S \left\lvert [S] \right\rvert !.

Form G′⊂GG' \subset G by keeping exactly one outgoing edge per vertex. Then each vv has a unique infinite walk; let its string be Sv′S'_v. These strings can be compared in O(1)O(1) after O(nlog⁡n)O( n \log n ) precomputation.

Now, in GG, the information from S∗′S'_* suffices to determine which vertices belong to which equivalence classes.

It is really challenging to generate valid inputs. If you know a way to validate inputs in o(n2)\mathcal{o}\left( n^2 \right), please let me know.