Problems

Pick a problem and write your solution in the built-in editor. The judge runs it against real test cases while you watch, and the wider archive is open to read whenever you like.

Total results6,382 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Alice and the BombGiven disjoint polygons, a bomb point, and Alice at the origin, find the shortest path she runs outside all polygon interiors until some building blocks the blast to the bomb.Hard8GeometryShortest path+2No attempts yet8s512 MBJudgeable
Dig or ClimbGiven a polyline terrain cross-section, find the shortest travel time from the first point to the last, walking along the surface or tunneling horizontally between two same-height points whose interior stays below the terrain.Hard8GraphShortest path+2No attempts yet8s512 MBJudgeable
Rotation EstimationGiven two unordered point sets related by a rotation plus translation, find the smallest counterclockwise rotation angle in [0, 2pi) that maps the first set onto the second.Hard8GeometrySorting+2No attempts yet8s512 MBJudgeable
Ramen Shop SeatingSimulate a ramen shop with N counters of fixed seats where arriving groups pick the best free block under a preference rule and may leave if they wait too long; report average customer satisfaction.Hard8SimulationImplementation+2No attempts yet8s512 MBJudgeable
Cousin's AuntGiven a chain of up to ten kinship terms describing how C relates to A, report the maximum and minimum possible degree of kinship between A and C.Hard8GraphShortest path+2No attempts yet8s512 MBJudgeable
Colony MaintenanceGiven up to 16 unit cubes forming a connected polycube, find the shortest path over its exposed surface between two points, with moves constrained by the three surface-adjacency cases.Hard8GraphBFS+2No attempts yet8s512 MBJudgeable
Turn PolygonsGiven a rotating polygon around a center and a fixed convex polygon inside it, find the angle until the two polygons first touch.Hard8GeometryBinary search+2No attempts yet8s512 MBJudgeable
Online Quiz SystemGiven per-player delays and each player's answer timing, simulate the polling protocol and report bytes sent and received by the server and each player.Hard8SimulationImplementation+2No attempts yet8s512 MBJudgeable
Restriction Enzyme MapReconstruct which positions on a circular DNA of length up to 20 are cut by enzyme A or B, given the distinct fragment lengths from cutting with A, with B, and with both, minimizing site count then lexicographic order.Hard8Brute forceBacktracking+2No attempts yet8s512 MBJudgeable
Favorite musicGiven n note strings and q pairs, find the shortest string containing both given fragments as contiguous substrings, allowing overlap.Hard8String matchingTrie+2No attempts yet1s256 MBJudgeable
Back to the FutureGiven a graph of compatible pairs, find the largest vertex subset where each chosen vertex has at least A neighbors and at least B non-neighbors inside the subset.Hard8GraphGreedy+2No attempts yet2s512 MBJudgeable
Sky TaxOn a tree with a moving capital, each vertex answers for all vertices whose path to the capital passes through it; move the capital or query a vertex's count.Hard8TreeDFS+2No attempts yet1s512 MBJudgeable
Sequence and Queries 13Maintain an array under range add, range multiply, and range assign modulo 1e9+7, answering range sum queries.Hard8Segment treeLinked list+2No attempts yet2s512 MBJudgeable
gcd(n, k) = 1Given n up to 10^18, count how many k in [1, n] satisfy gcd(n, k) = 1, that is, compute Euler's totient function of n.Hard8MathNumber theory+2No attempts yet2s512 MBJudgeable
Arranging HatEach of n m-digit strings may have individual digits rewritten; find the minimum number of digit changes so the sequence becomes nondecreasing.Hard8Dynamic programmingGreedy+2No attempts yet5s512 MBJudgeable
ZoltanCero builds a deque by placing each array element on the left or right in order; over all 2^(N-1) builds, find the longest strictly increasing subsequence length and the total number of subsequences attaining it, modulo 1e9+7.Hard8Dynamic programmingCombinatorics+2No attempts yet1s32 MBJudgeable
Flyswatter placementsCount the integer translations of a fixed polygon that keep it inside an axis-aligned rectangle and avoid all given points, including points on the boundary.Hard8GeometryPrefix sum+2No attempts yet1s256 MBJudgeable
Invisible IntegersGiven up to 10 hints, each a walk order of distinct digits 1 to 9, find the shortest hidden integer sequence that can produce every hint.Hard8BacktrackingDFS+2No attempts yet5s512 MBJudgeable
Power towersGiven lists of positive integers, compute each power tower modulo M, where the tower can be astronomically large.Hard8Number theoryRecursion+2No attempts yet2s512 MBJudgeable
Game on GraphOn a directed graph, Gennady prefers an endless game over winning and Georgiy prefers winning over everything but an endless game; report the outcome (W, L, D) for every start vertex and both first players.Hard8GraphGame theory+2No attempts yet2s512 MBJudgeable
Jenga BoomSimulate removals from a Jenga-like tower and report whether it falls, and at which removal, when a level's center of mass leaves the convex hull of the blocks still supporting it.Hard8GeometrySimulation+2No attempts yet2s512 MBJudgeable
Kids Designing KidsGiven three grid pictures, find the translation of the second that makes the XOR of the first two match the third, up to translation.Hard8ImplementationString matching+2No attempts yet2s512 MBJudgeable
Timpani RetuningChoose tunings for up to 4 ordered drums before each of N notes so the shortest retuning interval time is maximized; output that time rounded to two decimals.Hard8Binary searchDynamic programming+2No attempts yet2s512 MBJudgeable
Zombie ApocalypseGiven up to 2000 zombie cells on an N by M grid with Chebyshev distance spreading, count how many cells end up at level Q.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Beautiful PathsOn a tree with capitals 1 and 2, sum over all pairs of cities of the minimum distance-to-nearest-capital along their path.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
WalkA fractal tiling is built by repeated splits; given a start cell and a walk, report for each move whether he crossed between tiles.Hard8Divide and conquerRecursion+2No attempts yet2s512 MBJudgeable
IvoizationSum the Ivoization values of every K by K submatrix, where Ivoization is the pairwise absolute-difference sum of all K^2 entries, modulo 10007.Hard8SortingPrefix sum+2No attempts yet1.5s128 MBJudgeable
Painting SquaresAn infinite canvas starts white; each step picks the largest monochrome axis-aligned square of side at most D centered at a given point and flips its color. Find the final black area.Hard8GeometryDivide and conquer+2No attempts yet1s128 MBJudgeable
SamtrisGiven N marked cells in a 7-column grid, find the fewest 3x1 bars (vertical or horizontal) that can be dropped so all marked cells end up covered.Hard8Dynamic programmingGreedy+2No attempts yet5s128 MBJudgeable
MatchesGiven a spanning tree drawn on a grid of tokens with matches, count the ways to remove one match and add another so the graph stays a valid crossing-free spanning tree.Hard8GraphUnion-find+1No attempts yet1.5s256 MBJudgeable
Median filterGiven a piecewise-linear integer signal by its corner points, output the corners of its median-filtered signal of width 2d+1.Hard8MathImplementation+2No attempts yet1s128 MBJudgeable
MaxplusGiven 3x3 integer matrices A and C, find the entrywise-largest integer matrix B with A (max-plus) B = C, or report that none exists.Hard8MathMatrix+2No attempts yet1s128 MBJudgeable
FrogsFrogs of type d land on pads d, 2d, 3d, ... stopping at the first pad with no other frog; find the farthest occupied pad for each type.Hard8Number theoryMath+2No attempts yet1s128 MBJudgeable
SwitchesChoose a subset and order of switches to press so the cost of hand-fixing the remaining closed barns (morning) or open barns (evening) is minimized.Hard8Bit manipulationBrute force+1No attempts yet10s64 MBJudgeable
ExpressionParse a two-dimensional rendering of nested fractions, additions, multiplications, and divisions, then print the reduced value as a fraction.Hard8ImplementationRecursion+2No attempts yet2s512 MBJudgeable
Assigning jobs 2Given an N by N cost matrix, assign each of N people to a distinct job so the total cost is minimum.Hard8GreedyMath+1No attempts yet0.5s512 MBJudgeable
Wolves 2Count binary strings of length N in which every given interval contains at most two ones, modulo 1e9+7.Hard8Dynamic programmingPrefix sum+2No attempts yet2s512 MBJudgeable
Nice ArrayCount ways to fill the erased cells of an N by N array so that every permutation's diagonal sum is equal, modulo 1e9+7.Hard8CombinatoricsMath+1No attempts yet2s512 MBJudgeable
Block stackingCount structures built on one 1x1xw base block using unlimited 1x1x1, 1x1x2, and 1x1x3 blocks with height at most h, where long blocks need both ends supported.Hard8Dynamic programmingCombinatorics+1No attempts yet2s512 MBJudgeable
Company Culture 4On a rooted tree, praise spreads downward from an employee to all descendants or upward to all ancestors, the direction flips over time, and queries ask for an employee's accumulated praise.Hard8TreePrefix sum+2No attempts yet2s512 MBJudgeable
Sorting Array (Large)Given a permutation of 1..N and a limit P, partition it into contiguous blocks, sort each, then reorder at most P blocks by swaps; maximize the number of blocks.Hard8GreedySorting+2No attempts yet30s512 MBJudgeable
Stretch Rope (Large)Given N rubber bands with stretch ranges [A_i, B_i] and prices, pick a subset whose summed range contains L at minimum total cost within budget M.Hard8Dynamic programmingGreedy+2No attempts yet30s512 MBJudgeable
Imbalance ObviationAssign each marble L or R so the pan difference stays within 1 during insertion in order and during a given removal permutation; output the lexicographically smallest assignment.Hard8GreedyImplementation+2No attempts yet20s1024 MBJudgeable
Integeregex (Large)Count integers in [A, B] whose decimal form (no leading zeros) matches a small regular expression over digits.Hard8Dynamic programmingString+2No attempts yet5s512 MBJudgeable
Gallery of Pillars (Small)Count the pillars in an N by N grid that are visible from the corner viewpoint, given identical circular pillars of radius R whose centers sit at cell centers.Hard8GeometryNumber theory+2No attempts yet5s512 MBJudgeable
Radioactive Islands (Small)Find the minimum radiation dose for a boat crossing from (-10, A) to (10, B) at speed 1, given 1 unit/hour plus 1/D^2 per island at (0, C_i).Hard8GeometryMath+2No attempts yet30s512 MBJudgeable
Go++ (Large)Decide whether two bounded Go++ programs can jointly print every good string while never printing the bad string, and construct them by the given rule.Hard8ImplementationSimulation+1No attempts yet5s512 MBJudgeable
The Gardener of Seville (Small)Fill an R by C grid with / and \ hedges so that each given pair of border courtiers is connected by a wall-free path, choosing the lexicographically smallest grid.Hard8BacktrackingBrute force+2No attempts yet5s512 MBJudgeable
StreliceOn an arrow board, choose K non-last-column cells so that a robot starting anywhere in column 1 passes through exactly one of them or loops forever.Hard8GraphGreedy+1No attempts yet1s512 MBJudgeable
ParallelogramsGiven N points, produce a sequence of moves that translates one point to A+B-C each time, following a fixed published rule to bring every point into the first quadrant or report impossibility when all points are collinear.Hard8GeometryImplementation+2No attempts yet1s64 MBJudgeable
SoccerFind the minimum total fatigue for moving a soccer ball from player 1 to player N using kicks, walks, and player handoffs.Hard8GraphShortest path+2No attempts yet3s256 MBJudgeable
Rides 1Each day one child grows by 1 cm; after each growth, count how many of Q given pairs (i,j) can ride their specified ride, where the pair's combined height meets the ride's limit.Hard8SortingBinary search+2No attempts yet2s256 MBJudgeable
Stars in a CanPlace all n points in 3D inside one cylinder of any orientation, with at least three stars on one base, and print the minimum possible volume.Hard8GeometryBrute force+2No attempts yet2s512 MBJudgeable
Modern Art (Platinum)Given the final N x N canvas painted by N^2 nested rectangles, count how many colors could have been painted first.Hard8ImplementationPrefix sum+1No attempts yet2s512 MBJudgeable
COWBASICInterpret a tiny language of assignments, nested fixed-count MOO loops, and one RETURN, all additions taken modulo 10^9+7, and print the returned value.Hard8ImplementationSimulation+2No attempts yet2s512 MBJudgeable
The Rabbit's Escape RouteCount self-avoiding walks on a 3 by N grid from the top left cell to the bottom right cell, modulo 1e9+9.Hard8Dynamic programmingCombinatorics+2No attempts yet1s256 MBJudgeable
Scoreboard TamperingGiven the frozen scoreboard and all remaining submission logs, decide whether B can share or reassign them to end strictly ahead of A, and output the lexicographically smallest plan.Hard8GreedyImplementation+2No attempts yet1s128 MBJudgeable
AI Tetris (Large)Given a fixed 20 by 10 board, find the most rows a single auto-placed tetromino can clear, allowing it to slide sideways and tuck under overhangs before it settles.Hard8BFSSimulation+2No attempts yet1s512 MBJudgeable
Monday BluesGiven an N by M grid with costly buildable cells and blocked or unbuildable cells, find the minimum total cost to cut every path from (1,1) to (N,M), or report that no placement can do it.Hard8GraphMinimum spanning tree+2No attempts yet1s512 MBJudgeable
Airport ConstructionGiven a simple polygon with up to 200 vertices, find the longest line segment that lies entirely inside it.Hard8GeometryBrute force+1No attempts yet2s512 MBJudgeable
Get a Clue!Given your Cluedo hand and a log of suggestions with evidence responses, deduce which of the murderer, weapon, and room cards you can be certain of.Hard8GreedySimulation+1No attempts yet4s512 MBJudgeable
Visual Python++Match n top-left corners to n bottom-right corners so the rectangles form properly nested or disjoint blocks, or report a syntax error.Hard8SortingStack+2No attempts yet5s512 MBJudgeable
Yeongjeong's Big CleanupMold spreads diagonally every hour on an N x M grid, moving to the four diagonal neighbors and leaving its old cell; decide whether it ever covers the entire floor.Hard8MathImplementation+1No attempts yet1s512 MBJudgeable
RMT Subway Load TestEach subway line is a cycle of stations; line operations rotate passenger counts around the cycle, and range-sum surveys must be answered online.Hard8Segment treePrefix sum+2No attempts yet5s512 MBJudgeable
Cartesian ConquestA rectangle N by M must be tiled by rectangles with side ratio 2:1, added one at a time so the union stays a rectangle; find the min and max tile counts.Hard8MathNumber theory+2No attempts yet2s512 MBJudgeable
Vera and Modern ArtEach of N paint drops covers a lattice of points with power-of-two steps; answer Q queries for the total colour sum at a given point.Hard8MathBit manipulation+2No attempts yet4s1024 MBJudgeable
Electronic devicesAssign distinct power supplies to components so every device i gets at least Y_i working components, with a supply's chosen power matching the component's exact requirement, and output the lexicographically smallest connection list.Hard8GreedySorting+2No attempts yet1s512 MBJudgeable
Tile Flipping (Hard)Fill the free tiles so that flipping every black tile once leaves the whole board white, choosing the lexicographically smallest result or reporting impossibility.Hard8MathGreedy+2No attempts yet1s512 MBJudgeable
Aztec DiamondGiven a domino tiling of an Aztec diamond, find the shortest sequence of 2x2 rotations that turns all bricks vertical, lexicographically smallest.Hard8GreedySimulation+2No attempts yet1s128 MBJudgeable
Jerry and TomDecide whether every mouse can be assigned to a visible hole on the polygon boundary, with each hole holding at most k mice.Hard8GeometryGraph+2No attempts yet1s512 MBJudgeable
Leftmost SegmentGiven n segments spanning two horizontal lines, answer m queries asking which segment meets a horizontal line at the leftmost point, breaking ties by the upper endpoint.Hard8SortingBinary search+2No attempts yet1s512 MBJudgeable
Studying for ExamsDistribute up to T hours among N subjects to maximize the average of concave quadratic grade functions, with continuous time and exact rounding.Hard8MathGreedy+2No attempts yet3s512 MBJudgeable
Stable NeighborsPlace given counts of six mane colors around a ring so that no two neighbors share a base hair color, and output the lexicographically smallest valid arrangement.Hard8GreedyImplementation+2No attempts yet5s512 MBJudgeable
Beaming With JoyDecide which beam shooters to rotate 90 degrees so every empty cell is lit and no shooter is destroyed, outputting the lexicographically smallest valid grid.Hard8SimulationImplementation+2No attempts yet5s512 MBJudgeable
Shoot the Turrets (Large)Soldiers on a grid with buildings each get one bullet and a move budget; find the maximum number of turrets that can be destroyed, accounting for turrets that block cells until destroyed.Hard8BFSGraph+2No attempts yet5s512 MBJudgeable
Good News and Bad News (Large)Assign a nonzero integer to each directed edge so every vertex's outgoing sum equals its incoming sum, exactly as built by a prescribed DFS cycle-circulation procedure.Hard8GraphDFS+2No attempts yet5s512 MBJudgeable
Mountain Tour (Large)Given a directed graph where each camp has exactly two departing and two arriving tours with daily departure hours and durations, find the fastest route that uses every tour once and returns to camp 1.Hard8GraphDynamic programming+2No attempts yet5s512 MBJudgeable
Operation (Small)Given a start value S and up to 15 operation cards, order all cards to maximize the final rational result, printed as an irreducible fraction with positive denominator.Hard8Brute forceBacktracking+2No attempts yet5s512 MBJudgeable
Omnicircumnavigation (Small)Given points on a sphere visited in order, decide whether the closed path along shortest arcs meets every great circle (every hemisphere) on the sphere.Hard8GeometryMath+1No attempts yet5s512 MBJudgeable
Cups and MarblesAfter m range-sort spells (ascending or descending) on a permutation, report the marble in the middle cup.Hard8Binary searchSorting+2No attempts yet4s256 MBJudgeable
Coin Combinations and QueriesFor each query, count the multisets of at most d_i coins of denomination c_i (i=1..4) that sum to exactly v; answers fit in 64-bit.Hard8Dynamic programmingCombinatorics+2No attempts yet3s512 MBJudgeable
GCD table and a contiguous subsequenceGiven n, m, k and a sequence a, decide whether some row i of the GCD matrix G[i][j] = gcd(i, j) contains a as a contiguous run of columns.Hard8Number theoryMath+2No attempts yet2s512 MBJudgeable
The Restless CatIn a connected, planar, simple graph with a guaranteed cycle, find rooms whose single-vertex deletion leaves the graph acyclic (a forest), summing their indices.Hard8GraphDFS+1No attempts yet2s512 MBJudgeable
Horse tied outside the castleGiven a convex polygon and an exterior point with rope length L, compute the area reachable when the rope bends around polygon vertices and the two wrapping directions do not overlap.Hard8GeometryMath+1No attempts yet0.1s16 MBJudgeable
Rectilinear RegionsGiven two unbounded staircase polylines L and U, count the closed regions they enclose with L below and U above, and sum their areas.Hard8GeometryTwo pointers+2No attempts yet0.5s512 MBJudgeable
Period of a Slot MachineGiven a sequence of n outcomes, find k and p minimizing k+p (ties by smaller p) such that T[i+p]=T[i] for all i>k with i+p<=n.Hard8String matchingImplementation+1No attempts yet2s512 MBJudgeable
Ice cream samplesGiven a circular sequence of sample boxes, find the shortest consecutive run whose multiset union covers all brands 1 to K, and report its total sample count.Hard8Sliding windowTwo pointers+2No attempts yet3s512 MBJudgeable
Flatland Fidget SpinnerGiven the pixel colors a camera recorded of a three-armed spinner, recover the camera's position and rotation angle.Hard8GeometryBinary search+2No attempts yet2s512 MBJudgeable
Hoarse HorsesGiven line segments in the plane, count the maximum number of faces enclosed by them, i.e. bounded regions of their arrangement.Hard8GeometryGraph+2No attempts yet2s512 MBJudgeable
Compass Card SalesRepeatedly remove the remaining card with the smallest uniqueness score, breaking ties by larger ID, and print the removal order.Hard8SimulationSorting+2No attempts yet6s512 MBJudgeable
Hiker SafetyHikers on markers along a route must take turns stepping forward so that neighbours stay within distance B and everyone keeps their personal space; output the lexicographically smallest order in which all reach the end, or impossible.Hard8GreedySimulation+1No attempts yet4s512 MBJudgeable
Intergalactic ChordsMaintain an array of N notes (0 to 8); for each chord [a,b] find the most frequent note in the range, break ties by largest, then add it modulo 9 to every note in the range.Hard8Segment treeImplementation+2No attempts yet1s1024 MBJudgeable
Daunting deviceApply N range-recolor operations whose endpoints depend on the current count of a query color, then report the highest cell frequency.Hard8Segment treeImplementation+2No attempts yet1s1024 MBJudgeable
Jumping FrogGiven a circular string of rocks and ponds, count the step sizes K (1 to N-1) for which some rock's K-step cycle stays entirely on rocks.Hard8Number theoryMath+2No attempts yet1s1024 MBJudgeable
Abstract ArtGiven up to 100 simple polygons with 3 to 20 vertices each, compute the sum of their areas and the area of their union, each rounded to six decimals.Hard8GeometryImplementation+1No attempts yet2s512 MBJudgeable
Rainbow RoadsGiven a tree whose edges are colored, find every node v such that all simple paths starting at v have no two consecutive edges of the same color.Hard8TreeDFS+2No attempts yet2s512 MBJudgeable
Long Long StringsDecide whether two sequences of insertions and deletions, applied to any sufficiently long string, produce identical results.Hard8StringMath+2No attempts yet1s512 MBJudgeable
Spinning Up PalindromesGiven a digit string of up to 40 wheels, find the minimum number of single-digit advances (with cascading carries) to reach a palindrome.Hard8Dynamic programmingGreedy+2No attempts yet1s512 MBJudgeable
Extra Judicial OperationGiven a connected undirected graph, find the minimum number of vertices beyond one that must hold servers so every vertex still reaches a server after any single edge is removed.Hard8GraphDFS+2No attempts yet2s512 MBJudgeable
Balloon WarehouseSimulate repeated insertions into an infinite balloon line, then report the colors at positions l to r-1 after all instructions.Hard8TreeDFS+2No attempts yet7s512 MBJudgeable