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 results2,997 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Stacking BooksGiven masses of stacked unit-length rectangles placed in fixed order, maximize the rightmost x-coordinate while keeping every prefix's center of mass within distance 1 of the block beneath it.Medium7GreedyMath+1No attempts yet1s128 MBJudgeable
Function Return ValueGiven N nested loops whose bounds are either fixed integers or an outer loop variable, compute the total iteration count modulo 1e9+7.Medium7Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Descending-Run SortingGiven a permutation whose minimal slope decomposition always has even-length decreasing runs, simulate/derive how many reversal operations the described repeated slope-reversal sort performs until the array is sorted.Medium7ArraySimulation+1No attempts yet1s128 MBJudgeable
Alien Guitar PerformanceSimulate finger presses and releases on a 6-string guitar to play a melody in order with minimum total finger movements, keeping only pressed frets that could still be the highest useful one.Medium7StackGreedy+1No attempts yet1s256 MBJudgeable
Donggyu's Keyboard Paint ProgramSimulate up to 100000 paint, save, and load commands on an N by N grid with checkerboard rectangle fills and version rollback, then output the final grid.Medium7SimulationImplementation+1No attempts yet2s128 MBJudgeable
Prime CycleSimulate a circle of N people where the square-chair holder repeatedly swaps rightward by successive prime counts over K rounds, then report the neighbours of person A, with N up to 5,000,000 and K up to 500,000 requiring an efficient model of the swapping process rather than direct simulation.Medium7SimulationMath+1No attempts yet1s128 MBJudgeable
Explosion-Safe FoldingCount ways to fold N tape pieces at seams (straight or 180 degree) so coated faces never touch, given coating patterns from both ends, modulo 10301.Medium7Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
Donghyuk Astronomical ObservatoryGiven observation windows spanning possibly multiple years and event type counts per telescope, determine a consistent duration (1 to 365 days) for each of the M event types satisfying all telescopes' total observed days, or report -1.Medium7MathSimulation+1No attempts yet1s128 MBJudgeable
Mineral ClustersSimulate sticks destroying minerals in a grid cave, splitting and dropping clusters under gravity after each hit, and print the final grid.Medium7SimulationMatrix+1No attempts yet1s128 MBJudgeable
LRH PlantsGiven plants added over time with increasing heights, count for each new plant how many crossing points appear where its stems cross earlier plants' horizontal segments or vice versa, avoiding duplicate points.Medium7Segment treeGeometry+2No attempts yet1s128 MBJudgeable
Aladdin and the LampSimulate a grid walker whose turns depend on cell wizards and day of week, and find the day count when exactly K direction changes have occurred, using cycle detection since K can reach one billion.Medium7SimulationMath+1No attempts yet1s128 MBJudgeable
Symmetric MatrixConstruct the lexicographically smallest symmetric NxN matrix from given character counts and output selected columns, or report impossibility.Medium7GreedyMath+2No attempts yet1s128 MBJudgeable
Zoo ExpansionFind the switch time X within [0,T] so the total coconuts picked by monkeys of the first kind by time X matches what the second kind can open in the remaining T-X seconds, using binary search over count-producing step functions.Medium7Binary searchMath+1No attempts yet1s128 MBJudgeable
MessengersFind the minimum time for a spreading news to reach all messengers on a line, where informed messengers can move up to speed 1 and hear within distance K, typically via binary search plus greedy feasibility check.Medium7Binary searchGreedy+1No attempts yet1s128 MBJudgeable
Playlist Display IntervalsGiven a sequence of distinct requested songs, choose a length-K window covering each request to minimize the total number of distinct songs ever shown across all windows.Medium7GreedyIntervals+1No attempts yet1s128 MBJudgeable
The King's VisitCompute the delivery vehicle's shortest travel time from A to B given that certain roads are temporarily closed during time windows determined by the king's earlier route.Medium7Shortest pathGraph+1No attempts yet1s128 MBJudgeable
VictoryCount first moves in a circular pick-up game with adjacency constraints that force a win for the first player against an optimal second player counting odd numbers picked.Medium7Dynamic programmingGame theory+1No attempts yet1s128 MBJudgeable
CookiesCount, modulo 10007, the number of orders of choosing cookies on a circle so that each chosen cookie's two current neighbors always match in flavor, until 1 or 2 remain.Medium7Dynamic programmingCombinatorics+1No attempts yet5s128 MBJudgeable
Floor PlanGiven a pen path on an integer grid moving in 8 directions, count the number of enclosed rooms formed by the drawn lines.Medium7GeometrySimulation+1No attempts yet1s128 MBJudgeable
Exploding BallsGiven N balls moving in one of four axis directions at unit speed, find which balls never collide with another ball at the same point and time.Medium7SimulationMath+1No attempts yet1s128 MBJudgeable
Tower DefenseAssign one of four right-angle firing directions to each tower on a grid so simultaneous shots destroy every clone without hitting any other tower.Medium7SimulationGraph+1No attempts yet1s128 MBJudgeable
TunnelGiven a tunnel's ceiling and floor y-coordinates over N columns, construct the shortest axis-aligned path from (0,0) to (N,0) that never touches either boundary.Medium7GreedyGeometry+1No attempts yet1s128 MBJudgeable
Sierpinski TriangleGiven a Sierpinski-triangle sub-triangle's name string, output the names of all triangles it leans against based on the fractal's midpoint-subdivision structure.Medium7StringRecursion+2No attempts yet1s128 MBJudgeable
KidnappingGiven a grid of building heights and a sequence of left/right building heights seen while driving with turns allowed at each step, find a valid ending intersection consistent with some starting point and direction.Medium7SimulationBrute force+1No attempts yet1s128 MBJudgeable
Interval GroupsGiven a permutation of 1..N arranged on a board, decide if adjacent groups can be merged repeatedly into intervals until one group remains, and output the merge sequence if possible.Medium7GreedyStack+2No attempts yet1s128 MBJudgeable
ElevatorsFind the minimum time for Mirko to travel from floor 1 to floor K by transferring between periodically oscillating elevators only at their endpoint floors.Medium7Shortest pathGraph+1No attempts yet1s128 MBJudgeable
ColaGiven final cola levels after N people each drank from the fullest (W) or emptiest nonempty (E) bottle in turn, reconstruct the lexicographically smallest sequence of bottle choices.Medium7SimulationGreedy+1No attempts yet1s128 MBJudgeable
Job SchedulingFind the minimum number of identical machines needed to schedule M jobs, each submitted on a day and requiring one day of processing within D days, over N days.Medium7GreedyBinary search+1No attempts yet1s32 MBJudgeable
QueueSimulate people repeatedly leaving a queue and reinserting before another person, then answer position and label lookup queries efficiently using a balanced structure like a Fenwick tree or order-statistics tree.Medium7Segment treeBinary search+2No attempts yet2s32 MBJudgeable
HandshakesGiven a row of L/R facing people who flip and shake hands each second when an R stands left of an L, compute total seconds until stabilization and total handshakes, or report it never ends.Medium7SimulationGreedy+1No attempts yet1s128 MBJudgeable
Coin CollectorGiven coin denominations and a bill of K, find the purchase price whose greedy change contains the maximum number of not-yet-owned denominations, breaking ties by highest price.Medium7GreedyBinary search+1No attempts yet1s128 MBJudgeable
SubmarinesMaintain a sequence under adjacent swaps and repeatedly report the maximum in-degree in the 'nearest deeper element behind' functional graph.Medium7StackSegment tree+1No attempts yet3s128 MBJudgeable
MutexesGiven up to 5 threads each executing LOCK/UNLOCK instructions on mutexes, determine if a deadlock state is reachable via some interleaving and if so output the lexicographically smallest deadlock state description.Medium7BFSSimulation+2No attempts yet1s128 MBJudgeable
Bankrupt KingdomsDetermine, given pairwise debts among n kingdoms and a bankruptcy elimination rule based on negative balances, which kingdoms can be the sole survivor.Medium7GraphSimulation+1No attempts yet5s128 MBJudgeable
Boring Card GameSimulate a deterministic card dealing and collecting process to find which player first collects cards 1-5, or detect an infinite cycle, with game counts up to 2^63.Medium7SimulationMath+1No attempts yet1s128 MBJudgeable
The Most Stable Water LevelGiven a solid-of-revolution cup with expression-defined radius and wall thickness, compute the water fill level that minimizes the combined center of mass, requiring expression parsing, integration, and numerical optimization.Medium7MathBinary search+2No attempts yet1s128 MBJudgeable
Dice ContestFind the minimum total cost of rolling a labeled die across an infinite 4-row strip from a start square to a target square, tracking die orientation as state.Medium7Shortest pathBFS+1No attempts yet1s128 MBJudgeable
The Proper KeySimulate how deep a rigid connected key can descend into a grid lock, moving only down or sideways, and report the maximum depth or whether it falls through entirely.Medium7SimulationMatrix+1No attempts yet1s128 MBJudgeable
Hares and FoxesGiven a linear recurrence matrix for hare and fox population differences, classify the long-term limiting behavior of the system into one of six fixed outcomes based on eigenvalue analysis.Medium7MathMatrix+1No attempts yet1s128 MBJudgeable
Mitochondrial EveGiven birth and death events tracking maternal lineage and some sequenced mitochondrial DNA samples, determine whether all currently living individuals must share, might share, or must not share the same mitochondrial DNA.Medium7Union-findTree+2No attempts yet1s128 MBJudgeable
DiverGiven a diver moving along a vertical rope avoiding oscillating sharks whose horizontal distance follows a triangle wave, find the minimum time to reach the surface without ever coming within radius r of a shark, or report impossibility.Medium7Binary searchSimulation+2No attempts yet3s128 MBJudgeable
Digital ClockDetermine every plausible starting real time for a broken seven-segment clock, given a sequence of minute-by-minute observed displays where some segments are permanently dead.Medium7Bit manipulationSimulation+2No attempts yet1s128 MBJudgeable
Mountain RoadSchedule two queues of cars crossing a one-lane road with direction-blocking and same-direction spacing rules to minimize the last car's exit time.Medium7Dynamic programmingGreedy+1No attempts yet2s128 MBJudgeable
Up the StairsSimulate people passing boxes up a narrow staircase and determine the minimum time until all remaining boxes reach the top floor.Medium7SimulationGreedy+1No attempts yet1s128 MBJudgeable
Multiprocessor SchedulingGiven two sequences of N processor-bound procedures each, find the minimum makespan when a shared processor forces ordering constraints between the two applications.Medium7Dynamic programmingGreedy+1No attempts yet3s128 MBJudgeable
Cave ExplorationSimulate a maze-runner who always turns left when possible on a grid of horizontal and vertical corridors until he returns to the start, then count unvisited corridors.Medium7SimulationGeometry+1No attempts yet1s128 MBJudgeable
StylishDetermine unknown bracket-indentation weights from a correctly indented program and use them to compute (or mark unsolvable) indentation for each line of another program.Medium7MathSimulation+1No attempts yet1s128 MBJudgeable
Locks and KeysDetermine reachability on a tree with colored locks and single-use keys held one at a time, requiring a search over reachable key/room states.Medium7DFSGraph+1No attempts yet2s128 MBJudgeable
DartsCompute win probabilities up to score 501 for two darts players with different throw distributions, where B optimizes target section each turn.Medium7Dynamic programmingProbability+2No attempts yet1s128 MBJudgeable
Swimming JamSimulate multiple swimmers sharing two lanes with blocking and end-of-lane reordering rules to compute the total time until everyone finishes their assigned laps.Medium7SimulationQueue+1No attempts yet1s128 MBJudgeable
Traveling CubeSimulate a color-coded rolling cube on a grid that must visit six colored squares in a given order while avoiding black squares, and find the minimum number of rolls.Medium7BFSSimulation+1No attempts yet1s128 MBJudgeable
BingoFind the shortest number sequence a gamemaster can announce so bingo cards complete in non-decreasing order of their fixed index, or report impossibility.Medium7Brute forceCombinatorics+1No attempts yet1s128 MBJudgeable
Dice PuzzleGiven partial top and front faces of a 3x3x3 cube of standard dice with fixed chirality and opposite-face contact constraints, enumerate all valid orientations and report every possible sum of the right-side faces.Medium7BacktrackingSimulation+2No attempts yet1s128 MBJudgeable
BattleshipGiven two ship maps and a list of unlabeled shots, decide which admiral won under the hit-and-shoot-again turn rules.Medium7SimulationBrute force+2No attempts yet1s128 MBJudgeable
Trip the Lights FantasticFind the fastest car route through a town whose traffic lights cycle through green, yellow and red, where arriving on red costs a 5 second stop.Medium7GraphShortest path+2No attempts yet1s128 MBJudgeable
Bordering on MadnessFor each of several offsets, compute the total length and the newly painted area of the rectilinear polygon offset outward by a fixed distance.Medium7GeometryImplementation+2No attempts yet1s128 MBJudgeable
The Worm TurnsFind a start cell and first direction that maximize how many food pieces a self-avoiding worm eats, turning only when blocked.Medium7DFSBrute force+2No attempts yet3s128 MBJudgeable
Mastermind: The Best Next GuessGiven prior Mastermind guesses and their black/white peg counts, find the guess that minimizes the largest group of codes still consistent with each possible response.Medium7Brute forceSimulation+2No attempts yet3s128 MBJudgeable
Robot NavigationGiven a grid with craters and a robot that moves and turns, find the shortest command sequence to reach the goal and count how many such sequences exist modulo 1,000,000.Medium7BFSGraph+1No attempts yet1s128 MBJudgeable
BurnoutGiven a nested repeating on/off pattern and a target on-time N, find the elapsed time when total on-time first reaches N.Medium7RecursionSimulation+2No attempts yet1s128 MBJudgeable
Zerg Rush!!!Simulate a grid battle of two Zergling armies over t turns following detailed attack, death, movement, and regeneration rules.Medium7SimulationImplementation+2No attempts yet1s128 MBJudgeable
ClassifiedGiven a partial order with listed A -> B rules and guaranteed pairwise greatest lower bounds, simulate read and write actions that lower a user or document level to the glb of two current levels, printing each result.Medium7GraphTopological sort+2No attempts yet1s128 MBJudgeable
Hot SpotOn a 4 by 4 board, robots jump over one or two adjacent robots into an empty square; find the fewest jumps that bring the red robot to the top-left corner without violating the blue-robot adjacency rule.Medium7BFSGraph+2No attempts yet1s128 MBJudgeable
Hit or MissSimulate a multi-player solitaire card game and either report the last card each player discarded or declare the position unwinnable.Medium7SimulationQueue+2No attempts yet1s128 MBJudgeable
Galactic BreakupGiven three dimensional grid cell labels and the cell lists of the monarchies seceding in a fixed order, count the months after which the remaining cells form two or more pieces.Medium7Union-findGraph+1No attempts yet1s128 MBJudgeable
Eventually Periodic SequenceGiven N, a start n, and a function f written in postfix, follow the iteration x -> f(x) mod N and report the length of its eventual cycle.Medium7MathSimulation+2No attempts yet1s128 MBJudgeable
GoGiven a sequence of legal Go stone placements on an odd n x n board, apply capture and territory rules to compute each player's final score.Medium7SimulationImplementation+2No attempts yet1s128 MBJudgeable
Tango Tango InsurrectionGiven a sequence of required taps or rests, find the minimum total energy for the two feet under per-foot cost and crossover rules.Medium7Dynamic programmingSimulation+2No attempts yet1s128 MBJudgeable
TrainsGiven daily train schedules over at most 20 stations, list every Pareto-optimal departure time and travel time from an origin to a destination.Medium7GraphShortest path+2No attempts yet1s128 MBJudgeable
Faucet FlowWater pours at 1 cubic unit per second into a 1-wide tank with vertical dividers of given heights; find the time when it first overflows the outermost divider.Medium7SimulationImplementation+2No attempts yet1s128 MBJudgeable
OrigamiGiven up to 8 folds of a square sheet, count how many layers of paper a query point pierces, ignoring points on edges.Medium7GeometrySimulation+2No attempts yet1s128 MBJudgeable
Rings and RunesValidate the runes for several gates, report the highest-priority error, then decide if the resulting 3-CNF formula is satisfiable.Medium7SimulationImplementation+2No attempts yet1s128 MBJudgeable
Save the Python Programmers!Six labeled teams on a graph must swap houses, moving one team per night into an adjacent empty house while strictly alternating team type; find the minimum number of nights or report impossibility.Medium7BFSGraph+2No attempts yet1s128 MBJudgeable
Blenjeel Sand Worms and Color WrigglesA snake of n cells starts filling the left column of an n by m colored grid and must reach the right column, moving one end per wriggle, always keeping n distinct-colored cells; find the minimum number of wriggles.Medium7BFSSimulation+2No attempts yet1s128 MBJudgeable
FroggerOn a wrapping grid with moving cars, find the least number of seconds Phil spends standing on road cells before reaching water, or report the route impossible.Medium7BFSGraph+2No attempts yet1s128 MBJudgeable
Lightbulb TestingGiven a bulb life n and a periodic on/off pattern (with nested repeating groups), find the real time elapsed when total on-time reaches n.Medium7ImplementationMath+2No attempts yet1s128 MBJudgeable
Rank and FileGiven a pawnless chess position and the side to move, decide whether that side's king is safe, in check, or checkmated.Medium7SimulationBrute force+2No attempts yet1s128 MBJudgeable
The Screen Behind the MirrorSimulate a laser beam in a square region bouncing off mirrors and splitting at splitters, and list every detector that absorbs a beam.Medium7GeometrySimulationNo attempts yet1s128 MBJudgeable
Know When to Hold 'emGiven seven visible cards, find the best five-card poker hand an opponent holding two unknown hole cards could make, and print it with wildcard suits for ties.Medium7Brute forceImplementation+2No attempts yet1s128 MBJudgeable
Laser TagFind every firing angle from the origin whose laser beam returns to the origin after at most 7 reflections off flat mirrors, and print the angles in order.Medium7GeometrySimulation+1No attempts yet1s128 MBJudgeable
Cell TowersWalk a polyline road at every mile marker, compute each tower's signal p/d^2 rounded to nearest integer, and report only markers where the best tower (ties by alphabetical label) changes.Medium7GeometrySimulation+2No attempts yet1s128 MBJudgeable
Hex Tile EquationsFind the unique Hamiltonian path through a small hex grid of digit and operator tiles that spells a valid left-to-right equation with both sides equal.Medium7BacktrackingDFS+2No attempts yet1s128 MBJudgeable
The Law of the JungleGiven up to 20 bridges with capacity and crossing time, simulate the two rules to find the minimum total time for all people to cross.Medium7SimulationGreedy+2No attempts yet1s128 MBJudgeable
Falling IceSimulate disks falling one at a time into a box, each settling at the lowest reachable resting spot, and report the final pile height.Medium7GeometrySimulation+2No attempts yet1s128 MBJudgeable
ConnectDetermine whether the last of alternating Twixt pegs placed on a bounded board completes a connected path joining the placing player's two opposing endzones.Medium7GraphUnion-find+2No attempts yet1s128 MBJudgeable
Get Them AllSimulate the vehicle dispatch and routing rules to find when all contestants reach the contest site, or how many arrive by the time limit.Medium7SimulationImplementation+1No attempts yet1s128 MBJudgeable
Data Mining?Given a small Minesweeper board and one initial click, simulate the two deterministic clearing rules and find the starting cell that leaves the fewest covered safe cells.Medium7SimulationBrute force+2No attempts yet1s128 MBJudgeable
Tournament BracketsGiven team pairings listed in column-major order and the champion, reconstruct the tournament bracket and render it with slashes, backslashes, and underscores.Medium7ImplementationSimulation+2No attempts yet1s128 MBJudgeable
The Triangle GameGiven six triangles with numbered edges, rotate and arrange them into a hexagon where touching edges match, maximizing the sum of the six outer edges.Medium7BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Find the Winning MoveGiven a 4x4 tic-tac-toe position with x to move, find the earliest cell in row-major order where x has a forced win, or report none.Medium7Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
Collision DetectionGiven two recent position/time/speed readings per car, decide whether the cars pass within 18 ft at any moment in the next 30 seconds.Medium7MathGeometry+2No attempts yet1s128 MBJudgeable
Stems SellApply ordered pattern-to-replacement rewrite rules, which support *, V, C, and back-references, to every word in each paragraph.Medium7StringString matching+2No attempts yet1s128 MBJudgeable
Right-Hand RuleSimulate the right-hand wall-following rule from each entrance in a maze and count how many entrances let the walker see or step on the single goal.Medium7SimulationImplementation+2No attempts yet1s128 MBJudgeable
Chambers Ceramic ConundrumGiven nine tetromino-like tiles with fixed shapes and a strict placement order, decide whether the forced backtracking rule can cover a 6x6 grid and print the layout.Medium7BacktrackingSimulation+2No attempts yet1s128 MBJudgeable
Double DealingSimulate dealing and gathering the deck to find the number of repetitions after which the card order returns to the start.Medium7SimulationMath+1No attempts yet15s32 MBJudgeable
Chain CodeGiven the chain code of a hole-free pixel region, compute its area in pixels using the shoelace formula on the boundary walk.Medium7GeometryMath+2No attempts yet1s128 MBJudgeable
Walk in the ParkCount trees visible from at least one given horizontal or vertical path, where a tree is visible if no other tree blocks the line of sight.Medium7SortingHash map+2No attempts yet1s128 MBJudgeable
Jumping BeansTrack how beans in a row are rearranged after T seconds of a wrap-around swapping process, printing the final order for each test case.Medium7SimulationMath+2No attempts yet1s128 MBJudgeable
Hop — Don't Walk!Sliding-tile puzzle with walk and hop moves where hops flip the passed tile; find the fewest moves (depth under 10) to make all black tiles contiguous.Medium7BFSBacktracking+2No attempts yet1s128 MBJudgeable
Identically Colored Panels ConnectionOn a grid of up to 8 by 8 panels in six colors, the upper-left connected region changes color five times, absorbing same-colored neighbors; maximize the final region of the target color.Medium7DFSBFS+2No attempts yet1s128 MBJudgeable