2026 ICPC Asia Seoul Regional Finals Solution Sketches
Disclaimer: This is an unofficial analysis of some possible ways to solve the problems of the 2026 ICPC Asia Seoul Regional Finals. 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.
Live Solutions Presentation: https://www.youtube.com/live/SRL9GUXGMXo?t=11867
K. Stepping Numbers
Start a queue with . Whenever is popped, let and append if , followed by if .
This generates the stepping numbers in increasing order: numbers of a smaller length come first, and the order within each length is preserved. There are only about stepping numbers below , so one can simply generate them and take the -th. The time and space complexity is .
G. Glowing Devices
Work backwards. A device that is not forced on can be viewed as a unit-time job with deadline , whose reward is the saved payment .
Sort the devices by increasing deadline and insert their rewards into a min-heap. Whenever the number of jobs in the heap exceeds the current deadline, remove the smallest reward and pay for that device instead. The heap contains a maximum-weight feasible set of devices that can be activated for free.
The overall time complexity is .
D. Circuit X
Consider any two pins. If their orders in the upper and lower layers differ, their wires must cross exactly once: either above the middle layer, at cost , or below it, at cost . Their minimum contribution is therefore .
If their orders agree, the wires can cross neither layer or both layers, giving a minimum contribution of .
These pairwise lower bounds can be attained simultaneously. Depending on the signs and relative values of and , choose the middle permutation to be the upper permutation, the lower permutation, or the reverse of either one.
Let be the number of pairs whose orders differ between the two given permutations. The answer is
Compute by inversion counting in time.
E. Drones
Classify the drones in the order Inner, Boundary, and Outer.
For Inner, first check whether the point lies on a polygon edge; such a point is Inner. Otherwise, ordinary ray casting suffices. Shoot a horizontal ray to the right and count its intersections with the polygon boundary. An odd count means inside, and an even count means outside. Handle vertices using the standard half-open convention.
Once a drone is known not to be Inner, it is Boundary exactly when its distance to the polygon is at most . Geometrically, the points within distance of the boundary form the union of radius- disks around the vertices and width- rectangles along the edges.
Testing a disk is immediate. For the rectangle around segment , write and . The point belongs to the rectangle if and only if
The first inequality checks whether the orthogonal projection lies on the segment, and the second checks its distance to the supporting line. Any remaining drone is Outer. With polygon edges and drones, the time complexity is . All comparisons can be made with integer arithmetic.
B. Boss Raid Log
Let be the required spell sequence and the recorded sequence. An occurrence chooses the spells of in order, with consecutive chosen positions at least apart. We need to determine whether every position in belongs to some occurrence.
Find , the earliest possible position of the -th spell, by greedily matching from left to right. Similarly, find , the latest possible position, from right to left. If the greedy matching fails, the answer is NO.
A position can serve as the -th spell of some occurrence if and only if
For sufficiency, concatenate an earliest possible prefix, position , and a latest possible suffix. The spacing constraints are preserved.
Thus each contributes an interval for the spell type . Sweep , activating intervals when their left endpoints are reached. For each spell type , maintain the largest right endpoint among the activated intervals of that type. Position is covered precisely when .
The time and space complexity is .
J. Safe
Choose one of the given edit-cost tables, partition into at least two nonempty pieces, and minimize the maximum edit distance from to a piece.
Binary-search a threshold . For a fixed cost table, check whether admits a partition in which every piece has edit distance at most . The usual edit-distance DP can process all possible starting positions of the current piece together, rather than restarting a DP for each substring.
After reading a prefix of , let denote the number of characters of processed in the current piece. Maintain two edit-distance rows:
- : the current piece is still the first piece.
- : at least one earlier piece has already been completed with cost at most .
For the next character of , apply the usual insertion, deletion, and replacement transitions to both rows. When a row reaches with cost at most , the current piece may end. Starting with the next character, a new piece may begin in , initialized using the costs of deleting a prefix of . This restart is merged with the continuing states by taking minima.
Two details are important. A partition consisting of just one piece is invalid, so accept only when the final . Empty pieces are also invalid: finish a piece only after consuming a character of , and start the next piece only when another character arrives.
A sufficient upper bound is , obtained by dividing into nonempty pieces of length at most . The time complexity is , using DP space per cost table.
M. Workbench
Let , and let be the minimum cost of processing the first steps. If the last batch comprises steps , then
where is valid exactly when .
Set and . Splitting the maximum at gives
Coordinate-compress the values and maintain two range minima in a segment tree. At step , insert and remove old indices whose intermediate parts no longer fit on the workbench. Because the sizes are positive, the valid form a contiguous interval, so this can be maintained with a moving left endpoint.
Query the prefix and the suffix . The time complexity is , with space.
I. Potion Shop
Write each pile size as , where . Define
The position is losing for the player to move if and only if .
To see why, consider a losing position. A move affecting only one pile must change either its quotient, hence the xor, or the sum of remainders modulo . A move removing fewer than crystals in total also changes the latter by a nonzero amount unless a quotient changes; in that case the quotient xor cannot remain zero when only one quotient is changed.
Conversely, if , use the usual Nim move to decrease one quotient so that the xor becomes zero, choosing the new remainder so that the total remainder sum is zero modulo . If but , remove exactly crystals from the remainder parts, without changing any quotient.
For each update, remove the old quotient and remainder from these two aggregates and insert the new ones. The total time complexity is .
A. Baduk Solitaire
Ignore empty cells and compress consecutive stones of the same color into runs. We may assume that each removal deletes an entire run: a partially removed run can be finished when it would otherwise disappear.
It is also safe to join the ends and consider the runs on a circle. A removal crossing this artificial cut can be postponed until the runs between the two ends have been cleared, after which the saved end stones can be removed together.
If there is only one circular run, the answer is YES exactly when it contains at least two stones. Otherwise, let there be alternating runs, and call a run of size one a singleton. The answer is
A block of consecutive singletons is an obstruction that survives every legal removal. In the other direction, if no such block exists, one can remove a nonsingleton run adjacent to an appropriate longest block and preserve the condition with decreased by one. This proves sufficiency by induction.
The criterion can be checked in time.
L. Summoning Triangle
Count triangles containing exactly one stone of each color, including the three vertices. Fix a directed side , rotate the coordinates so that is the origin and lies on the positive -axis, and consider only candidate third vertices to the left of .
For another point on this side, the condition is equivalent to
Sweep the candidate points in increasing -slope. The first condition is then handled by the sweep; membership in the triangle depends only on a threshold in the ordering around .
Assign each point a rank increasing with its -slope. For each color , maintain the two largest ranks encountered so far, and , using zero for missing colors and a maximum sentinel for the colors of and . Skip a side whose endpoints have the same color.
After inserting , its triangle is valid precisely when
Indeed, supplies its own color, and every other color must have exactly one processed point whose rank is above the threshold.
For a fixed , maintain a histogram of the current maxima . Every maximum can only increase, so a pointer to the smallest occupied rank moves in one direction and takes time in total. Also maintain . When a color's previous maximum is and the new point has rank , update . Thus each step of the sweep costs amortized .
Pre-sort the angular order around every point. The resulting deterministic algorithm takes time and space.
An variant maintains the maxima in an ordered structure, but its implementation must be efficient to meet the time limit. There is also a randomized approach using hashing.
F. Erin Needs Cake
We are given a triangulation of a simple polygon, possibly with interior vertices. The cake lies inside one triangular face, and a query asks whether it lies inside a simple loop along the given edges. We are allowed at most queries.
The key is to remove boundary triangles one by one while ensuring that the remaining union is still a topological disk. A triangle is removable if it has at least two edges on the current boundary, or if it has exactly one boundary edge and its opposite vertex is an interior vertex. In the second case, removing the triangle exposes that interior vertex on the new boundary. If the opposite vertex is already on the boundary, removing the triangle may disconnect or pinch the remaining region and is not allowed.
Keep a queue of removable candidates, rechecking the condition whenever a candidate is popped. After removing one face, only its neighbors need to be reconsidered. Record the removal order , keeping the last face. Every suffix
has a single simple boundary.
Let the unknown face be . Query the boundary of the suffix beginning at the midpoint . The answer is 1 exactly when , so an ordinary binary search locates in at most queries.
To construct a query, an edge belongs to the suffix boundary exactly when it has one adjacent face in the suffix and the other outside it. Follow these edges to recover the cycle. The removed prefix need not be a simple polygon, so querying the prefix—or an arbitrary interval in the removal order—is not generally valid.
The total time complexity is and the space complexity is .
C. Chemistry Experiment
Count safe strings of length over , where adjacent nonzero symbols must agree and every symbol must appear.
First allow only nonzero symbols, without requiring all of them. Let be the number of such strings. By inclusion–exclusion, the answer modulo is
To compute , let and count safe prefixes of length ending in zero and nonzero, respectively. Then
Hence , which can be computed by binary exponentiation of a matrix. Evaluate the inclusion–exclusion sum in time, using space.
H. Last Jump
Let be the string constructed so far and the given string. A useful invariant is that the current position is the earliest ending position of an occurrence of in .
When we append a character , no occurrence of can end before or at . If , its earliest ending position is , so this move is not a jump. Otherwise, the next state is the earliest ending position of later in , and the move is a jump. If the extension does not occur, the move is illegal.
A suffix automaton compresses substrings with the same set of ending positions; they have the same legal extensions and jump behavior. For a transition , it is a jump exactly when
where is the earliest ending position represented by state .
Let indicate whether the current player can win, where means the current player will win if no further jump occurs. At a terminal state with , set . For a move to , the opponent's flag is if the move does not jump, and if it does. Thus the current player can win if any legal transition satisfies
Evaluate the states in decreasing order of represented substring length and return . The time complexity is per string.