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,405 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Circle of FriendsFor each queried node in an undirected graph, find the largest k-core containing it, then output the largest connected component of that core with its members sorted.Hard8GraphImplementation+2No attempts yet1s128 MBJudgeable
Floating Mountain StabilityGiven up to 49 surviving terms, decide whether they can be a subsequence of a generalized Fibonacci sequence with at most 8 skipped terms between consecutive survivors, and output a valid witness.Hard8MathNumber theory+2No attempts yet1s128 MBJudgeable
Prefix MediansGiven the prefix medians B of an unknown permutation of 1 to 2N-1, reconstruct the lexicographically smallest permutation that produces exactly those medians.Hard8GreedyImplementation+2No attempts yet1s128 MBJudgeable
Puzzle AssemblyGiven four n x n pieces with cut corners, rotate and mirror them to tile a (2n-1) x (2n-1) square with no gaps or overlaps, printing the lexicographically smallest result.Hard8BacktrackingImplementation+2No attempts yet0.5s64 MBJudgeable
CipherFind the a x b subarray that occurs exactly k times (k >= 3) in an n x m character grid and list all its top-left positions in row-major order.Hard8Hash mapString+2No attempts yet1s128 MBJudgeable
BlackjackGiven the exact order of the remaining deck, decide which hands to play, how much to bet, and when to hit or stand, to maximize total profit.Hard8Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Shepherds and EngineersGiven s sheep needed in town after b bridges whose tolls follow a strict divisibility rule, find the minimum starting number of sheep.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
RNGGiven y and a, b, c, n, find all x in [0, 2^n) with a x^2 + b x + c = y mod 2^n, printing x only when exactly one solution exists.Hard8Number theoryMath+2No attempts yet1s128 MBJudgeable
IslandsEach island has one undirected weighted edge; find the maximum-weight walk choosing one edge per component/tree path structure respecting ferry reachability rules.Hard8GraphGreedy+2No attempts yet2s128 MBJudgeable
Pyramid BaseGiven up to 1000 weighted rectangles on a grid up to 10^6 by 10^6, find the largest axis-aligned square whose total cost of intersected rectangles is at most B.Hard8Binary searchGeometry+2No attempts yet5s128 MBJudgeable
Polish FlagThree children grow regions of blocks from three fixed edges with priority rules and simultaneous expansion each turn; count each child's white (top) and red (bottom) cells.Hard8SimulationGeometry+2No attempts yet2s128 MBJudgeable
GardenPlace two non-overlapping rectangles, each holding exactly k roses, and minimize the sum of their perimeters over an l by w grid with n roses.Hard8ArrayPrefix sum+2No attempts yet1s128 MBJudgeable
BirthdayChildren sit around a round table in order 1..n; reseat them into a given cyclic order while minimizing the largest distance anyone walks along the circle.Hard8Binary searchSorting+2No attempts yet2s64 MBJudgeable
EmpodiaGiven a permutation biosequence, find every minimal framed interval: a segment whose endpoints are its min and max and that contains no shorter framed interval.Hard8StackArray+2No attempts yet1s128 MBJudgeable
DepotGiven the final row placement produced by the depot insertion rule, count how many arrival orders of the containers could have produced it.Hard8Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
PolygonRemove one edge of a polygon, then repeatedly merge adjacent vertices by the intervening + or *, and report the maximum final value plus every edge whose removal reaches it.Hard8Dynamic programmingIntervals+2No attempts yet1s128 MBJudgeable
The CircleChoose n positive sector values (each at least k) so that consecutive circular block sums cover every integer from m to i, maximizing i.Hard8Brute forceCombinatorics+2No attempts yet1s128 MBJudgeable
IciclesIcicles grow each hour when strictly longer than both neighbors and snap at length L; find the hour when all have broken.Hard8SimulationImplementation+2No attempts yet1s128 MBJudgeable
Ladder GameGiven a ladder with n lines and m rungs, erase at most one rung to minimize the sum of scores reached from the leftmost k starting lines.Hard8ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Moving Cups Across Three TraysCups of sizes 1..n sit stacked (largest on top) on three trays; with moves allowed only between A-B and B-C, find the minimum number of moves to gather every cup onto A or C, or report -1 if more than m are needed.Hard8BFSDynamic programming+2No attempts yet1s128 MBJudgeable
AltarCount the sequences of nonnegative column heights reachable by repeatedly raising the interior of any equal-height range by 1, matching known heights where not stolen (-1).Hard8Dynamic programmingCombinatorics+2No attempts yet1s256 MBJudgeable
Fence MakingFor each integer radius and spacing pair, count holes drilled through repeated remelting of the strip, then sum C(d,r,S) over all pairs.Hard8MathImplementation+2No attempts yet1s128 MBJudgeable
Hexagonal SticksGiven at most 8 unit sticks on an infinite hexagonal grid with blocked cells, find the minimum number of moves (rotate, push, or discard) so the sticks form one closed regular hexagon.Hard8BFSBrute force+2No attempts yet1s128 MBJudgeable
Environment ProtectionGiven rational function boundaries of two underground layers, find the digging depth d so the exposed middle-layer area equals a target A, printed to five decimals.Hard8Binary searchMath+2No attempts yet1s128 MBJudgeable
Fix the PondGiven a grid of rotatable barriers in a 2N by 2N+1 pond, find the minimum number of barriers to rotate so a path visits every cell once from top-left to bottom-left.Hard8GraphBFS+2No attempts yet1s128 MBJudgeable
Candy's CandyCount the ways to split F flavors' counts into equal-size packs, some single-flavor and at least one containing all flavors, with each flavor having a flavored pack.Hard8Number theoryMath+2No attempts yet1s128 MBJudgeable
Hedge MazesFor each query (S,T) decide whether the undirected graph has exactly one simple path between S and T, and print Y or N per query.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Code LockGiven a target lowercase string starting from all 'a', find the minimum number of moves where each move shifts a contiguous block of wheels up or down by one.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
HooliganGiven partial results of a round-robin tournament where each pair plays M times, decide whether team 0 can finish alone in first place.Hard8GraphGreedy+2No attempts yet1s128 MBJudgeable
AbwordsGiven N, find the minimum word length over A/B words (starting with A, length at least 2) that admits an N-step cycle of the two given transformations.Hard8MathCombinatorics+2No attempts yet1s128 MBJudgeable
Higgs BosonGiven two particles whose polar radius and angle move linearly in time, find the earliest rational time t >= 0 when their positions coincide, or report that they never do.Hard8MathGeometry+2No attempts yet1s128 MBJudgeable
Mission ImpossibleGiven a simple polygon border, radar disks that block movement, and informers inside, decide which reachable informer lies farthest from the border, starting from (2000, 2000).Hard8GeometryUnion-find+2No attempts yet3s128 MBJudgeable
Light UpOn a board up to 7 by 7 with numbered barriers, find the minimum number of lamps that light every empty square, where no two lamps see each other and each numbered barrier has an exact count of adjacent lamps, or report no solution.Hard8BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
PetanqueSimulate seven petanque throws where a moving ball travels along its direction, possibly striking other balls and transferring its remaining roll, then decide who owns the closest boule to the coche and count points.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
Zing Zhu's Oyster FarmGiven horizontal and vertical fence segments with heights, find the total area of land enclosed by cycles of segments that all stand at least as tall as the tide.Hard8GeometryGraph+2No attempts yet1s128 MBJudgeable
Cutting EdgeGiven non-overlapping rectangles that tile a big pane, output the sequence of edge-to-edge cuts (smallest X1, then smallest Y1 first) that separates every rectangle.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
MoversFor each box in order, decide whether it can be slid from the open left side to its destination without overlapping placed boxes or walls, and list the rejects.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
Slithering SerpentGiven a self-avoiding snake path of at most 37 steps, find the minimum number of moves to steer it into a position that is doomed to crash.Hard8BFSGraph+2No attempts yet1s128 MBJudgeable
Numbers GameGiven 4 to 7 integers, combine each at most once with +, -, *, or truncated integer division to reach a value as close as possible to a target, printing the smaller value on ties.Hard8BacktrackingBrute force+2No attempts yet5s128 MBJudgeable
The Crayfish ScrivenerProcess type and undo commands, including nested undos, and answer queries for the character at a given position.Hard8StackTree+2No attempts yet2s512 MBJudgeable
Rotation ParityDecide the parity of the number of 2x2 clockwise rotations needed to sort a permutation of an R x C grid into row-major order.Hard8MathCombinatorics+2No attempts yet5s256 MBJudgeable
Figure EightFind two axis-aligned rectangles sharing one horizontal edge row, outlines all flawless, maximizing the product of the two interior areas.Hard8Prefix sumImplementation+2No attempts yet1s128 MBJudgeable
TaxiBessie drives one cow at a time along a fence of length M, may drop cows short of their goals, starts at 0 and ends at M; find the minimum total driving distance.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Gangs of CowstantinopleGiven gang sizes, decide if gang 1 can control the field at the end, and find the lexicographically earliest arrival order maximizing the surviving gang-1 cows.Hard8GreedyImplementation+2No attempts yet1s128 MBJudgeable
Crazy FencesFences form disjoint closed polygons; find the largest set of cows that can reach each other without crossing a fence.Hard8GeometryGraph+2No attempts yet1s128 MBJudgeable
Delivery RouteFind the shortest 4-directional grid path that visits farms 1..N in order and back to farm 1, never stepping on any other farm's cell; output -1 if impossible.Hard8BFSShortest path+2No attempts yet1s128 MBJudgeable
Buying FeedBuy at least K pounds of feed from stores along a 1D route, paying purchase cost plus K^2 cents per mile for the load carried, and minimize the total.Hard8Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
The Continental CowngressEach of M cows casts yes/no votes on two distinct bills, and every cow must win at least one vote; decide for each bill whether it passes in all valid outcomes, fails in all, or varies.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
The Lost CowsGiven a synchronizing automaton over N states with M shared input letters, compute the maximum over all pairs of the shortest synchronizing word length for that pair.Hard8BFSGraph+2No attempts yet1s128 MBJudgeable
Cow TreatsSimulate a greedy process on a W by H grid where rows and columns may be swapped to place the highest remaining value in the earliest reachable slot.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
AllowanceGiven coin denominations where each divides the next and bounded supplies, find the maximum number of weeks you can pay at least C each week.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Who Brings the Cookies?Assign one cookie-bringing cow per study group so each cow's meeting count stays within a ceiling-of-reciprocals limit, choosing the lexicographically smallest assignment.Hard8MathGreedy+2No attempts yet1s128 MBJudgeable
Shipping Around an IslandFind the shortest closed loop of grid cells that encloses the main island of A cells but encloses no x cell, where paths may revisit cells.Hard8BFSShortest path+2No attempts yet1s128 MBJudgeable
StarCowraftGiven test battle outcomes and the constraint that no unit strength exceeds 100 times another, determine for each new battle whether one army must win or the result is undecidable.Hard8GeometryMath+2No attempts yet1s128 MBJudgeable
Test TakingGiven N questions and a set of possible true-counts, choose a true/false answer key maximizing the worst-case number of correct answers.Hard8MathGreedy+2No attempts yet1s128 MBJudgeable
Rocks and TreesRocks sit on the non-root nodes of a rooted tree; players alternately push up to L rocks from a node to its parent, and after each point update you decide if the first player wins.Hard8Game theoryTree+2No attempts yet1s128 MBJudgeable
Holedox MovingFind the minimum number of moves for a snake of length up to 8 to slide its head to the exit at (1,1) on a grid with stones, where the tail cell counts as blocked during a move.Hard8BFSSimulation+2No attempts yet1s128 MBJudgeable
Winning CheckersFind the lexicographically smallest sequence of diagonal jumps by which a single king captures every opponent checker on an N x N board, or report that none exists.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
Jigsaw PuzzlesPlace every piece into an R by C grid, rotating but not flipping, so touching edges match and the outer boundary is all borders; print the lexicographically smallest assembly.Hard8BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
CheckersOn an N x N board, decide whether one king can capture every opponent checker in a single move of consecutive diagonal jumps, and print the unique landing sequence if so.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
Earthquake DamageGiven a graph and reports that certain damaged pastures cannot reach the barn, find the minimum total number of pastures that cannot return to the barn.Hard8GraphUnion-find+2No attempts yet1s128 MBJudgeable
Pink FloydGiven the all-pairs shortest-distance matrix of a weighted tree, reconstruct any tree that produces these distances and print its adjacency list.Hard8TreeGraph+2No attempts yet1s128 MBJudgeable
Surround the Islands with FenceGiven N edges that form disjoint polygon islands and a symmetric vertex-to-vertex boat cost matrix, find the minimum total cost of round trips needed to fence every island, starting anywhere.Hard8GraphMinimum spanning tree+2No attempts yet1s128 MBJudgeable
Earthquake Damage 2Given an undirected graph and a set of vertices that cannot reach the barn, find the minimum number of other vertices to remove so that exactly those vertices are separated from vertex 1.Hard8GraphBFS+2No attempts yet1s128 MBJudgeable
Holiday PaintingPaint rectangle updates on an R x C grid, R up to 50000 and C up to 15, and after each of Q updates report how many cells equal a fixed target pattern.Hard8Segment treeBit manipulation+2No attempts yet2s128 MBJudgeable
Haybale GuessingGiven interval minimum queries with distinct values, find the earliest query that makes the whole set of answers inconsistent.Hard8Binary searchSorting+2No attempts yet1s128 MBJudgeable
Harvesting a FarmGiven a grid of crops 1 and 2 with no 2x2 checkerboard, find the minimum number of cutter changes (including the first attachment) to harvest every cell, moving freely only on matching or empty cells.Hard8GraphBFS+2No attempts yet1s128 MBJudgeable
Rectangular PaintingGiven a nesting tree of rectangles and photo leaf sizes, orient each sibling group horizontally or vertically to minimize the root rectangle area.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
New IslandGiven a graph whose edge i costs 2^i, delete the cheapest set of edges so the graph stays connected and every pairwise distance at most doubles.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
Sharif Super ComputerChoose distinct positive slave heights between 0 and a top master height H so that all red cable lengths match exactly and every slave pair distance is an allowed blue length, minimizing the output sequence lexicographically.Hard8Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Circle ArtworkGiven up to 100 colored points, count how many colors have a circle through two of their points that contains no point of another color.Hard8GeometryBrute force+2No attempts yet1s128 MBJudgeable
NurikabeSolve Nurikabe puzzles on grids up to 9x9 by coloring cells black or white so all six connectivity and counting rules hold.Hard8BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Triangle PizzaCount the number of distinct connected polyiamonds with N cells, where shapes that match under rotation or translation count as one and reflections are distinct.Hard8BacktrackingImplementation+2No attempts yet1s128 MBJudgeable
Triangles and QuadrangleGiven two triangles and a quadrangle, decide whether the triangles can be joined along a full edge, without overlap, to form the quadrangle up to translation, rotation, and reflection.Hard8GeometryImplementation+2No attempts yet1s128 MBJudgeable
Ball MachineSimulate a ball machine on a rooted tree: dropping balls follows a fixed priority path, and removing a ball makes balls above roll down; report resting node or number of moves.Hard8TreeSimulation+2No attempts yet1s128 MBJudgeable
Tracks in the SnowGiven a grid where each tracked cell shows the most recent animal (R or F), find the minimum number of animals that crossed from the top-left to the bottom-right.Hard8GraphGreedy+2No attempts yet2s1300 MBJudgeable
Optimal ProgramsFor each set of input/output pairs, find the shortest stack-machine program of at most 10 commands made of ADD, SUB, MUL, DIV, and DUP, with lexicographically smallest ties.Hard8Brute forceDFS+2No attempts yet1s128 MBJudgeable
Video SurveillanceGiven a rectilinear simple polygon, decide whether one point exists from which the whole interior is visible.Hard8GeometryImplementation+2No attempts yet1s128 MBJudgeable
Ouroboros SnakeGiven n and k, find the n-bit number starting at position k in the de Bruijn circle built from the smallest Ouroboros number of size n.Hard8CombinatoricsBit manipulation+2No attempts yet1s128 MBJudgeable
AppendGiven an LZ-style encoding as a list of (back-reference, length) pairs, count how many prefix positions split it into two valid non-empty encodings whose concatenation reproduces the original string.Hard8StringImplementation+2No attempts yet1s128 MBJudgeable
Tin CutterGiven up to 100 axis-parallel cuts inside a plate, count how many holes (closed regions not touching the plate border) remain after all cuts are made.Hard8GeometryGraph+2No attempts yet1s128 MBJudgeable
L-system SubstringGiven a D0L system over {a,b} and a query z, decide whether z appears as a contiguous substring of some word derivable from the start word.Hard8StringSimulation+2No attempts yet1s128 MBJudgeable
IntervalsGiven a point light above the x-axis and non-overlapping circular pipes below it, find the shadowed intervals on the x-axis, sorted and rounded to two decimals.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
Strictly Inscribed Similar TrianglesFor each triangle and angle theta, count how many strictly inscribed triangles similar in order to the given triangle exist with a chosen edge at that angle.Hard8GeometryMath+2No attempts yet1s128 MBJudgeable
XenosemanticsFind words over lowercase letters delimited by varying spacer letters in a bit stream, then report the distinct true words that repeat and overlap another true word.Hard8StringHash map+2No attempts yet1s128 MBJudgeable
Doing WindowsGiven a screen and four windows with fixed aspect ratios, decide whether the windows can be resized and placed to tile the screen with no gaps or overlaps.Hard8GeometryMath+2No attempts yet1s128 MBJudgeable
ShipsGiven partial knowledge of seven non-overlapping tetromino ships on a grid, decide if all 28 ship squares can be uncovered with at most one miss against every consistent arrangement.Hard8BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Perfect HashFor each line of up to 13 short words, find the smallest positive integer C so the hash floor(C/w) mod n is collision free, and print C after echoing the input line.Hard8Hash mapMath+2No attempts yet1s128 MBJudgeable
Lisa the Ladybug and the Broken CalculatorGiven a set of working calculator buttons, find the shortest sequence of presses that leaves target N on a display limited to 0..999.Hard8BFSImplementation+2No attempts yet2s128 MBJudgeable
Domino TilingCover a grid with pre-placed tiles and all given dominoes, then output the lexicographically smallest valid tiling and the count of other tilings.Hard8BacktrackingDynamic programming+2No attempts yet1s128 MBJudgeable
No SmokingGiven up to 200 disjoint rectangles in a town rectangle, decide whether some point in the town lies at distance at least D minus 0.1 from every building.Hard8GeometryUnion-find+2No attempts yet3s128 MBJudgeable
Pyramid GuardsTwo guards walk opposite closed quadrilateral loops on a square pyramid's surface; find the minimum straight-line distance between them while they share a face.Hard8GeometryMath+2No attempts yet1s128 MBJudgeable
Letter LiesCount the number of length-L paths from a greeting sentence to a closing sentence in a directed graph whose successor rules guarantee no sentence repeats.Hard8Dynamic programmingGraph+2No attempts yet3s128 MBJudgeable
Robotic RailsGiven up to 100 line segments in the plane, find the shortest path from a fixed start point and heading to a fixed target point and heading, where turns at intersections may not exceed 90 degrees.Hard8GraphGeometry+2No attempts yet10s128 MBJudgeable
International Collegiate Programming ContestGiven the exact output of a banking simulator, rebuild the canonical input: map each result line to a fixed request and choose the smallest initial balance B that keeps every request valid.Hard8SimulationImplementation+2No attempts yet1s128 MBJudgeable
Careful DeclarationMerge two word sequences into the shortest common supersequence, breaking ties by choosing the lexicographically smallest result.Hard8Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Catch the Bus!Given bus routes with hourly timetables and two students' start times and stops, find the earliest moment they can meet at any shared stop, considering 2-minute transfer times.Hard8Shortest pathGraph+2No attempts yet1s128 MBJudgeable
Failing RoadsGiven an expression tree of merge and complement operations, compute the maximum independent set of the resulting graph.Hard8TreeDynamic programming+2No attempts yet1s128 MBJudgeable
Base NumbersFor each digit string, count the ways to insert parentheses and dashes so it decodes to a valid decimal-encoded number in some base greater than 1.Hard8Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Paper CuttingFor each test case, decide whether an A by B grid of C by D cards fits on an E by F sheet in some rotation, then report the minimum number of straight cuts needed to separate the cards.Hard8MathGreedy+2No attempts yet1s128 MBJudgeable