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,398 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Beware the GeoducksGiven two fixed walking routes on a weighted graph, decide whether the two travelers ever occupy the same point within t seconds, accounting for nodes with geoducks that make a traveler vanish.Hard8ImplementationSimulation+2No attempts yet1s128 MBJudgeable
A Weighty ProblemChoose which coins to hand over for a purchase so that the total weight of unspent coins plus the store's greedy change is minimized.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
JengaismSimulate Jenga moves (remove a block, place it on top) and report when any structure topples because its center of gravity leaves the convex hull of its supports.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
Concentration CardsGiven N cards of size W by H that can each be rotated, tile a filled rectangle with them and find the smallest possible perimeter.Hard8MathGeometry+2No attempts yet1s128 MBJudgeable
CubeGiven an n by n by n grid of letters, decide whether the connected same-letter pieces can be pulled apart without cutting, meaning no single piece separates the cube.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
PartitionsGiven k and a, output the a-th partition of k in lexicographic order, or Too big when a exceeds the partition count.Hard8Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Ransom NoteGiven a target note and a newspaper text, find the minimum number of contiguous clips (letters and spaces only, case-insensitive, reusable) needed to paste the note.Hard8Dynamic programmingString+2No attempts yet1s128 MBJudgeable
SnailsEach of N snails moves in a fixed direction at speed 1 and stops at the fence, at any point an earlier snail crossed, or when it meets another snail simultaneously; find when the last snail stops.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
Railway ConnectionFind the cheapest route from station s to g in a multigraph where each maximal run of same-company edges is priced by that company's piecewise linear, concave fare table.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
Generic PokerCount hands of L cards (ranks 1 to M, N copies each) that match a pattern of wildcards and variables shifted by pluses, then print the probability as an irreducible fraction.Hard8CombinatoricsBrute force+2No attempts yet1s128 MBJudgeable
Cow Ski AreaBuild the directed graph where each square has edges to same-or-lower neighbors, then find the minimum number of bidirectional edges to add so the whole graph becomes strongly connected.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
CloudsEach cloud is a polygon moving with the same velocity; count the separate time intervals during which the vertical beam at the origin intersects at least one cloud.Hard8GeometrySorting+2No attempts yet2s128 MBJudgeable
Similar PolygonsDecide whether two polygons are similar, and if so print the square of the similarity factor as a reduced fraction and the matching vertex index in the second polygon.Hard8GeometryString matching+2No attempts yet1s1024 MBJudgeable
Similar PolygonsDecide whether two polygons are similar under rotation, reflection, translation, and scaling, then output the exact squared similarity ratio and the smallest matching vertex index.Hard8GeometryString matching+2No attempts yet1s1024 MBJudgeable
Making test data 3Construct the lexicographically smallest SSSP test file (at most T integers) on which optimized Bellman-Ford finishes under C iterations but Floyd-Warshall exceeds C, or report that none exists.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
Conditional StatementsParse a small nested if language, then for each checkpoint decide which variable assignments can reach it and print the forced true/false variables or unreachable.Hard8SimulationImplementation+2No attempts yet10s128 MBJudgeable
Obstacle CourseFind the minimum number of seconds to steer a sliding puck to a target on an ice rink, accelerating per second while avoiding integer-coordinate obstacles.Hard8BFSSimulation+2No attempts yet1s1024 MBJudgeable
Obstacle CourseTap a sliding puck to change its velocity and reach a target point in the fewest seconds without touching any axis-aligned obstacle stick.Hard8BFSSimulation+2No attempts yet2s1024 MBJudgeable
Number SquareFill an N x N Latin square with 1..N given some pre-filled cells and inequalities between neighboring cells, choosing the lexicographically smallest valid board.Hard8BacktrackingImplementation+2No attempts yet1s1024 MBJudgeable
Changing Phone NumbersGiven area codes and a sequence of rules (digit duplication, digit swap, area-code change) applied over time, answer queries transforming a phone number from one year to another.Hard8StringSimulation+2No attempts yet1s128 MBJudgeable
Map LabelerGiven city points in the plane, find the largest square label size so that each label has its city at the midpoint of its top or bottom edge and no two label interiors overlap.Hard8Binary searchGeometry+2No attempts yet1s128 MBJudgeable
JaWsGiven two rows of equilateral triangles, drop the upper row onto the lower one and report where it settles or which side it slides off.Hard8GeometrySimulation+1No attempts yet1s128 MBJudgeable
The Bermuda TriangleGiven a regular hexagon of side s and allowed equilateral triangle sizes, decide whether the hexagon can be tiled exactly by triangles of those sizes.Hard8BacktrackingGeometry+2No attempts yet1s128 MBJudgeable
University Entrance ExaminationGiven students with scores, home regions, and program preference lists, plus program capacities, assign students to programs under a local-region priority rule and a fairness rule.Hard8ImplementationGreedy+2No attempts yet1s128 MBJudgeable
Museum Heist: Area of the Shadowy RegionsGiven an axis-aligned rectangle with non-overlapping rectilinear polygonal obstacles and a gun at the upper-right corner, find the total area of points no monotone beam can reach.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
Magazine DeliveryThree cars start at L1 and must deliver to locations in strict order 2,3,...,N, with only one car moving at a time; minimize the total completion time.Hard8Dynamic programmingShortest path+2No attempts yet1s128 MBJudgeable
FarmlandGiven a planar graph of farming regions, count the proper regions bounded by a simple cycle with no interior vertices or edges and exactly k boundary edges.Hard8GraphGeometry+2No attempts yet1s128 MBJudgeable
RobotsSimulate a 31x31 robot game where robots chase you, applying a tie-broken greedy movement and teleport strategy to report whether you win or lose.Hard8SimulationImplementation+2No attempts yet1s128 MBJudgeable
Word EncodingGiven up to 1000 forbidden substrings of length 1 to 3, rank valid words by length then alphabetically; answer queries converting a word to its index and an index to its word.Hard8Dynamic programmingString matching+2No attempts yet1s128 MBJudgeable
Pseudo-random NumbersGiven the first L digits of a pseudo-random sequence generated by repeatedly summing adjacent base-B digits, decide whether the T-th element is forced, or report impossible or unpredictable.Hard8MathImplementation+2No attempts yet1s128 MBJudgeable
Inlay CuttersCount all 45-degree right isosceles triangles formed by grid-aligned cuts and diagonals on an M by N plate after K straight cuts.Hard8GeometryImplementation+2No attempts yet1s128 MBJudgeable
Statistical TroubleOutput each cross table of two survey questions as raw counts and rounded row and column percentages in a fixed 6-character grid.Hard8ImplementationMatrix+2No attempts yet1s128 MBJudgeable
LibraryGiven shelf and peg geometry in a niche, find a redesign that seats a fixed tome on one shelf while minimizing pegs moved and plank cut.Hard8GeometryBrute force+2No attempts yet1s128 MBJudgeable
FenceCompute the total illumination reaching the lit parts of a polygonal fence from a point lamp, accounting for shadows and the cosine obliquity factor.Hard8GeometryImplementation+2No attempts yet1s128 MBJudgeable
Black BoxFind all 6x6 atom placements inside an 8x8 box that reproduce a set of laser entry and exit experiments, and report the layout if it is unique.Hard8SimulationBrute force+2No attempts yet2s1024 MBJudgeable
Consecutive OnesPermute the columns of a 0-1 matrix so that the 1s in every row are consecutive, with column 0 fixed as the first column.Hard8GraphImplementation+2No attempts yet2s1024 MBJudgeable
EllipseGiven five integer points, either report that no unique ellipse passes through them or compute that ellipse's area to six decimals.Hard8GeometryMath+2No attempts yet2s64 MBJudgeable
Incredible! Impossible!Count n by 3 tables of non-negative integers with given row sums and column sums, modulo 10 to the 17.Hard8Dynamic programmingCombinatorics+2No attempts yet2s64 MBJudgeable
HighwaysGiven N cities on a line with one-way roads only left to right, add two non-touching one-way roads to make the network strongly connected at minimum total length, or print 0.Hard8GreedyImplementation+2No attempts yet1s512 MBJudgeable
Key InsertionSimulate the recursive Insert operation on an infinite array for N keys and print the final occupancy up to the largest filled cell.Hard8Union-findImplementation+2No attempts yet1s512 MBJudgeable
PlatformsGiven points with distinct x, find the longest chain of flights where each next point has larger x and no larger y, then report every point lying on some longest chain.Hard8Dynamic programmingSorting+2No attempts yet2s128 MBJudgeable
Robotic InvasionEdit as few commands as possible in a movement string so the robot reaches a trap, breaking ties by earliest capture and then lexicographic order.Hard8BFSDynamic programming+2No attempts yet1s128 MBJudgeable
ExpressionsFor each range of digits and target, print every fully bracketed expression over the digits in order that evaluates to the target. (Note: summary must be one sentence, at most 160 chars.)Hard8BacktrackingRecursion+2No attempts yet1s128 MBJudgeable
Lattice Points in the Union of CirclesCount integer lattice points inside the union of up to 10,000 circles, restricted to the coordinate box from -16383 to 16384.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
The RaceCount all overtakes among spaceships with given starting positions and speeds, then list the first 10000 in time order.Hard8SortingGreedy+2No attempts yet1s128 MBJudgeable
Space BoomerangGiven M direction vectors in N-dimensional space, find every vector that cannot appear with a nonzero coefficient in any linear combination summing to zero.Hard8MathGeometry+1No attempts yet3s128 MBJudgeable
Identity CheckerEach test case gives a reverse Polish expression in x with sin, cos, and tan; decide whether it equals zero wherever defined.Hard8MathString+2No attempts yet1s128 MBJudgeable
Burns' RodsGiven the six colors on each of N slices plus both end caps, decide whether some sequence of 180-degree twists makes labels share a color exactly when they share a face.Hard8ImplementationSimulation+2No attempts yet1s128 MBJudgeable
The 2 x 2 x 2 Rubik's CubeGiven a scrambled 2x2x2 Rubik's cube, compute the minimum number of 90-degree turns needed to solve it.Hard8BFSSimulation+2No attempts yet10s1024 MBJudgeable
2D MatrixSplit N points into two disjoint non-empty sets, each centrally symmetric, and print every division's two centres in lexicographic order.Hard8Hash mapSorting+2No attempts yet1s64 MBJudgeable
Collision of AsteroidsGiven two moving convex hulls in 3D, decide whether they overlap at some past or future time.Hard8GeometryBinary search+1No attempts yet1s16 MBJudgeable
Union Area of TrianglesGiven right isosceles triangles with axis-parallel legs and hypotenuse of slope -1, compute the area of their union.Hard8GeometrySegment tree+2No attempts yet1s32 MBJudgeable
CakesSchedule dough preparation and single-oven baking for N cakes so that all finish as early as possible.Hard8GreedySorting+1No attempts yet1s32 MBJudgeable
BattleshipFire order over a 10x10 grid is given; place the ten standard ships without touching so the game lasts as long as possible.Hard8GreedyBacktracking+2No attempts yet2s256 MBJudgeable
GridGiven n points, decide whether there exist an axis-aligned grid of evenly spaced lines and a straight line whose intersection set is exactly those points.Hard8GeometryMath+2No attempts yet1s128 MBJudgeable
Log AnalysisMaintain a volatile log under insertions in the middle, block deletions, and queries asking how many distinct event types appear in a position range.Hard8ArraySegment tree+2No attempts yet2s256 MBJudgeable
Red Chips, Green ChipsWith r red and g green chips, players alternately remove k chips of one color where k divides the other color's count; decide the winner under optimal play.Hard8Game theoryMath+2No attempts yet1s128 MBJudgeable
Almost ClearGiven two disjoint convex polygons A and B and a point C outside both, decide whether B hides none, part, or all of A as seen from C.Hard8GeometryBinary search+2No attempts yet1s128 MBJudgeable
WalawehEach Walaweh list W_L is built from W_{L-1} by a fixed 8-step cycle of append/prepend and optional reversal operations; convert between (length, index) and the binary string. The recursion only needs O(log N) work per level, but the reversal and leading-zero handling make the index bit-mapping non-obvious.Hard8RecursionBit manipulation+2No attempts yet1s128 MBJudgeable
Worst LocationsGiven a perfect binary tree and two distance-from-leaf descriptions, decide whether some pair of matching vertices sits farther than Z apart.Hard8TreeGeometry+2No attempts yet1s128 MBJudgeable
Playing With StonesA subtraction game on piles where each move removes at most half a pile; decide if the first player wins, with pile sizes up to 2e18.Hard8Game theoryMath+2No attempts yet1s128 MBJudgeable
Road AccidentFind which quarter-part of each car (corner plus adjacent side halves) first touches the other car during straight-line motion before impact.Hard8GeometrySimulation+1No attempts yet1s128 MBJudgeable
Harder Sokoban ProblemChoose player and container start cells to maximize the minimum Sokoban moves needed to push the container onto the single destination cell.Hard8BFSGraph+2No attempts yet5s128 MBJudgeable
Fool GameGiven a trump suit and both hands, find the lowest-ranked opening card that forces the defender to take, assuming optimal defense.Hard8Game theoryDFS+2No attempts yet1s128 MBJudgeable
Museum TourGiven a connected graph with max degree 3 and a fixed cyclic door order per room, count starting rooms whose edge-following walk eventually traverses every corridor.Hard8GraphSimulation+2No attempts yet1s512 MBJudgeable
Arithmetic RectangleGiven an n by m grid of integers, find the largest rectangle in which every row and every column forms an arithmetic sequence, and output its area in unit squares.Hard8Dynamic programmingArray+2No attempts yet3s128 MBJudgeable
Bits GeneratorCount how many of the m possible seeds make a floor-mod pseudorandom generator output a given bit string of length n.Hard8MathNumber theory+2No attempts yet3s64 MBJudgeable
Intelligence QuotientGiven a bipartite acquaintance graph and IQ values, choose a clique (subsets of both sides where every cross pair is acquainted) maximizing total IQ.Hard8GraphCombinatorics+2No attempts yet3s128 MBJudgeable
Ternary TreesLabel the leaves of a complete ternary tree so that, given a fixed query order, the leaf values stay hidden until every leaf is asked.Hard8TreeRecursion+2No attempts yet1s128 MBJudgeable
Hallucinogenic CarnationsFor each of up to 10000 polygons, sum the carnations in grid parcels whose area at least half lies inside the polygon.Hard8GeometryPrefix sum+1No attempts yet1s128 MBJudgeable
TetrisCount ways to fully tile a 4-by-n board with seven Tetris pieces (long piece has 3 cells), given some cells of the first row already covered, modulo 10^6.Hard8Dynamic programmingMatrix+2No attempts yet1s128 MBJudgeable
Fibonacci SumsGiven two Zeckendorf representations of positive integers, compute the Zeckendorf representation of their sum.Hard8GreedyMath+2No attempts yet1s128 MBJudgeable
Special Forces ManoeuvresDiscs cover the plane; find the smallest prefix of the given order whose union already covers the entire plane, or report NIE if no prefix does.Hard8GeometryBinary search+2No attempts yet3s512 MBJudgeable
Evaluation of an ExpressionCount assignments of values to variables modulo a prime that make a given sparse polynomial expression zero, output modulo 30011.Hard8MathNumber theory+2No attempts yet1s128 MBJudgeable
Catching MolesChoose at most k holes to shoot on a circle; each shot removes the target's moles and pushes neighbors' moles outward, maximizing the total removed.Hard8Dynamic programmingGreedy+2No attempts yet1s256 MBJudgeable
GatesEach gate outputs the majority state of its inputs (0, 1/2, or 1); decide for every gate whether its state is the same across all valid circuit states.Hard8ImplementationGreedy+2No attempts yet3s128 MBJudgeable
Maximal Orders of PermutationsFor each n, find the smallest partition of n whose parts have the maximum possible LCM, then output the lexicographically smallest permutation with those cycle lengths.Hard8Number theoryGreedy+2No attempts yet3s512 MBJudgeable
Numerals of the PrzesmyksConvert numerals over {- , +} with at most m1 consecutive minuses into their rank-ordered representation under the bound m2.Hard8CombinatoricsMath+2No attempts yet1s128 MBJudgeable
SkiersGiven a planar DAG whose edges leave clearings in west-to-east order, find the minimum number of downhill paths that cover every edge.Hard8GraphDynamic programming+2No attempts yet1s128 MBJudgeable
PawnGiven horizontal and vertical step sizes, count lattice cells reachable from (1,1) inside an axis-aligned rectangle.Hard8Number theoryMath+2No attempts yet1s512 MBJudgeable
Green GameOn a bipartite board where Ann and Billy alternately move a pawn, find all starting fields from which Ann can force the first repeated field's cycle to contain a green field.Hard8Game theoryGraph+2No attempts yet1s128 MBJudgeable
Peaceful CommissionPick exactly one deputy from each of n pairs, avoiding forbidden deputy pairs, and print the lexicographically smallest valid choice or NIE.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
IslandGiven all pairwise shortest tolls among the n seaside triangles, recover the adjacency structure and edge weights of the underlying border tree.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
NecklacesDecide whether two run-length compressed string descriptions encode the same circular necklace up to rotation.Hard8StringString matching+2No attempts yet1s128 MBJudgeable
City TourGiven a connected 4-regular multigraph with an object on each edge, decide whether some closed Eulerian tour starting at an edge midpoint never lets accumulated interest drop below zero.Hard8GraphGreedy+2No attempts yet1s128 MBJudgeable
Triple-Arm CraneGiven p, q, n, find the lexicographically smallest sequence of triple placements (x, x+p or x+q, x+p+q) that covers wagons 1..n exactly once.Hard8GreedyMath+2No attempts yet1s128 MBJudgeable
P-Broken-LineFind the minimum number of axis-parallel unit-free segments in an orthogonal polyline from A to B that avoids all n given axis-parallel obstacles.Hard8BFSGraph+2No attempts yet3s512 MBJudgeable
AltarsFor each rectangle temple, decide whether a ray from its center can exit through the half-wall entrance and escape to infinity without touching any rectangle.Hard8GeometryImplementation+1No attempts yet1s128 MBJudgeable
PolygonGiven a convex polygon and its triangulation, find the maximum number of triangulation triangles a single elementary triangle can intersect.Hard8GeometryDynamic programming+1No attempts yet1s128 MBJudgeable
WindowGiven an orthogonal polygon and an axis-parallel window, count how many separate interior fragments of the polygon are visible through the window.Hard8GeometryImplementation+1No attempts yet1s128 MBJudgeable
Ali BabaGiven starting tokens and trade rules over three token types, find the minimum number of trades to reach at least the required counts per type, or NIE if impossible.Hard8BFSGraph+2No attempts yet1s128 MBJudgeable
RooksPlace n non-attacking rooks, one per given axis-aligned rectangle, or report that no placement exists; output the lexicographically smallest placement.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Disk OptimizationGiven disk sectors holding files split across blocks, find the minimum copy/swap cost to pack files into consecutive sorted blocks.Hard8SortingGreedy+1No attempts yet1s128 MBJudgeable
The PostmanDecide whether a directed graph has an Euler circuit from node 1 that contains each given sequence as a contiguous run of the route.Hard8GraphDFS+1No attempts yet1s128 MBJudgeable
Quaternary BalanceGiven n up to 1000 digits, count modulo 10^9 the distinct minimum-mass weighings of n grams with masses that are powers of four, placed on either pan or both.Hard8Dynamic programmingMath+2No attempts yet1s128 MBJudgeable
Plot purchaseGiven an n by n grid of non-negative prices, decide whether some axis-aligned subrectangle has a sum between k and 2k inclusive.Hard8Prefix sumGreedy+2No attempts yet1s128 MBJudgeable
Words 2Given exponents k1..kn, find the smallest m such that the concatenation of h_k(0) is a substring of h_m(0), or report NIE.Hard8StringRecursion+2No attempts yet1s128 MBJudgeable
King SejongGiven a graph where no path from 1 to 2 uses fewer than 4 edges, find the maximum number of edges that can be added while keeping the 1-to-2 distance at least 5.Hard8GraphGreedy+2No attempts yet3s512 MBJudgeable
LampGiven rectangular windows on two parallel walls 10 m apart and a lamp on one wall, count the windows of the lamp's building whose interior any reflected ray can reach.Hard8GeometryImplementation+2No attempts yet5s512 MBJudgeable
FrogFor each rock, find where a frog lands after exactly m leaps, where each leap goes to the k-th nearest rock with ties broken toward the spring.Hard8Two pointersBinary search+1No attempts yet3s512 MBJudgeable