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,373 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Hyperspace RoutesFor each query, find every possible value of the shortest A-to-B path length as the shared hyperspace edge weight x ranges over the positive integers, then report the count and sum, or inf when unbounded.Hard9Shortest pathGraph+2No attempts yet5s64 MBJudgeable
Taking TurnsTwo players alternately take bales from a line, skipping any number of earlier bales; each plays optimally and takes the leftmost optimal bale. Find each player's total.Hard9Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
CastingFor a convex polygon, count the vertex pairs whose connecting line splits it into two parts that can each be pulled out by translation.Hard9GeometryTwo pointers+2No attempts yet1s128 MBJudgeable
Watering the FieldsPlace 3-cell sprinklers on a fenced grid so every non-scarecrow cell is watered exactly once, choosing tracks and sprinklers by a fixed lexicographic rule.Hard9GreedySimulation+1No attempts yet1s128 MBJudgeable
Forgetful WaiterCustomers sit around a round table and pass pizzas left or right each turn; find the minimum number of turns until every pizza reaches the customer who ordered it.Hard9GraphGreedy+2No attempts yet1s128 MBJudgeable
Warez TestOn a grid of walls, boxes, and targets, find the shortest sequence of Jimmy's moves that pushes every box onto a target, breaking ties by the lexicographically smallest move string.Hard9BFSGraph+2No attempts yet1s128 MBJudgeable
Very Boring HomeworkInsert N keys into a BST, lay out its ASCII drawing, and report up to 5 small rectangular fragments of the picture.Hard9TreeImplementation+1No attempts yet2s128 MBJudgeable
City NavigationCompute the shortest legal right-hand-side driving distance between two driveways in a numbered grid city with some road segments missing.Hard9GraphShortest path+2No attempts yet1s128 MBJudgeable
PendulumSimulate an idealized pendulum swinging around point hooks on a wall and print the length of the periodic orbit it eventually settles into.Hard9GeometrySimulation+2No attempts yet1s128 MBJudgeable
Cyclic Antimonotonic PermutationsFor each n, output the lexicographically smallest permutation of 1 to n that is both antimonotonic (every middle element is a local min or max) and a single cycle when read as a pointer mapping.Hard9CombinatoricsMath+2No attempts yet2s128 MBJudgeable
Construct the Wall MazeGiven three wall lengths and a shortest-path string in a 6x6 grid, construct a valid maze consistent with it, choosing the lexicographically smallest answer.Hard9Brute forceBFS+2No attempts yet1s128 MBJudgeable
Mine the GradientGiven a grayscale grid, find the largest square subgrid whose values follow a vertical, horizontal, or diagonal uniform gradient, and report its area.Hard9Dynamic programmingImplementation+2No attempts yet10s128 MBJudgeable
The Herbalists' VillageGiven a friendship graph, decide whether it has a planar straight-line drawing where every vertex reaches infinity without crossing an edge.Hard9GraphGeometry+2No attempts yet1s128 MBJudgeable
A Romantic Movie OutingMaintain a dynamic set of occupied seats across a huge theatre, answer queries for the combined field-of-vision inconvenience of two seats, and at the end find the minimum over far unoccupied seat pairs.Hard9Segment treeDynamic programming+2No attempts yet2s512 MBJudgeable
Move that Mouse AGAINGiven up to 50,000 axis-aligned rectangles in a fixed bottom-to-top stacking order, process 50,000 point clicks, printing the topmost window at each point and moving it to the top of the stack.Hard9Segment treeGeometry+2No attempts yet3s128 MBJudgeable
Fast FoodGiven up to 50 points in a 10 by 10 square, compute for each point the area of its Voronoi cell within the square and report the percentage, rounded to nearest with halves up.Hard9GeometryDivide and conquer+2No attempts yet1s128 MBJudgeable
Phylogenetic TreeGiven the graph of organisms joined when their tree distance is at most 3, find the fewest edges in any phylogenetic tree that produces it.Hard9GraphTree+2No attempts yet1s128 MBJudgeable
Checker BoardEach row holds at most one checker per color; players slide their pieces along rows and the one who cannot move loses. Decide whether White wins, Black wins, or the game can run forever.Hard9Game theoryGreedy+2No attempts yet1s128 MBJudgeable
Prince of PersiaGiven a grid room, mirrors with fixed orientations and allowed cells, and plates on walls, decide whether the light ray can reach every plate.Hard9SimulationGraph+2No attempts yet1s128 MBJudgeable
Deformed WheelSimulate a convex polygon rolling down a piecewise-linear hill until it comes to rest, and print the final position of its center of gravity.Hard9GeometrySimulation+2No attempts yet1s128 MBJudgeable
Find the BorderGiven a closed self-intersecting polyline, count the vertices of the border of its interior, the outer boundary enclosing all bounded regions.Hard9GeometryImplementation+2No attempts yet2s128 MBJudgeable
Coloring mapsSimulate a greedy 5-coloring where each vertex takes the smallest color not used by already colored neighbors and report failure.Hard9GraphGreedy+1No attempts yet1s32 MBJudgeable
Accountant NotesFor each note, find every starting row in the summary file where a renamed transcription of the note appears as consecutive rows.Hard9String matchingHash map+2No attempts yet5s512 MBJudgeable
Suffix Array ReconstructionGiven a permutation p, decide whether it is the suffix array of some lowercase string and, if so, output the lexicographically smallest such string.Hard9StringGreedy+2No attempts yet1s512 MBJudgeable
Wandering Flea TrainersGiven two functional graphs on n labeled nodes, decide whether some vertex relabeling makes the graphs isomorphic, i.e. the fleas' dance is identical.Hard9GraphDFS+2No attempts yet3s128 MBJudgeable
BankFind the lexicographically smallest four-currency reserve vector that lets a bank serve all clients in some order, where serving client i requires its remaining need in all four currencies to be covered at once.Hard9GreedyMath+2No attempts yet1s128 MBJudgeable
Ice rinkA skater slides in straight lines across a square rink with rectilinear obstacles, stopping only at walls, and must reach the finish point in the fewest slides.Hard9BFSGraph+2No attempts yet1s128 MBJudgeable
Recursive AntOn a 2^n by 2^n board with at most 50 forbidden cells, find for each of the four borders a cell where a recursive quarter-by-quarter Hamiltonian tour can end, or report none.Hard9Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
MessengersGiven a 2-connected graph, output the lexicographically smallest pair of search plans from city 1 so that for any single occupied non-capital city, both messengers together warn every city.Hard9GraphDFS+2No attempts yet1s128 MBJudgeable
TreesFor each tree, find the smallest adjacent-difference sum reachable by either keeping the row or swapping that tree with one other tree.Hard9ArrayMath+2No attempts yet1s128 MBJudgeable
Axes of SymmetryFor each simple polygon, count its axes of symmetry; n can reach 100000, so the check must run in near-linear time.Hard9String matchingGeometry+2No attempts yet1s128 MBJudgeable
Isles in a Triangular GridEnumerate all non-congruent triangular-grid isles of up to ten triangles, canonicalizing each by the lexicographically smallest clockwise boundary-turn word.Hard9GeometryBrute force+2No attempts yet1s128 MBJudgeable
The CodeGiven a prefix code entered via button presses, find the code words that resynchronize decoding after any loss of leading bits.Hard9TrieString+2No attempts yet1s128 MBJudgeable
OnesGiven run lengths of n in binary, output run lengths of the binary form of sks(n), the total UFO count over 1 to n.Hard9MathCombinatorics+2No attempts yet3s512 MBJudgeable
SpiderA walk on an infinite regular seven-legged web is given as turn directions; count the web nodes strictly inside the closed polygon it traces.Hard9GeometryImplementation+1No attempts yet1s128 MBJudgeable
FragmentsCount how many times each digit string appears as a contiguous substring across the decimal forms of all numbers in a union of disjoint integer intervals up to 10^18.Hard9String matchingDynamic programming+2No attempts yet1s128 MBJudgeable
DiamondGiven a convex polyhedron, choose one plane cut so that the two resulting pieces have the largest combined number of faces.Hard9GeometryBrute force+1No attempts yet2s512 MBJudgeable
FishesGroup recorded closed routes into the fewest fish, where two routes can follow on consecutive days if the start cells touch and every point is visible 24 hours earlier.Hard9GraphGeometry+2No attempts yet2s512 MBJudgeable
Programming ContestGiven each participant's skill per topic, decide whether we can choose n tasks (topic and difficulty) so Byteman is the unique winner under solve-count then points ranking.Hard9GreedyMath+2No attempts yet2s512 MBJudgeable
WatchmenCount, for each city gutter, how many Palace gutters a walker can reach while dodging rotating watchers' lines of sight.Hard9GeometryGraph+2No attempts yet2s512 MBJudgeable
QuestionsSimulate a logic puzzle where princes and a sorcerer reason about a system of variable constraints over time; answer what each prince or the sorcerer knows.Hard9Brute forceSimulation+2No attempts yet1s128 MBJudgeable
Dragon MilkdrinkerCompute the probability that the sum of n independent uniform [m, M] yields is strictly less than h, printed truncated to d decimals.Hard9ProbabilityMath+2No attempts yet1s128 MBJudgeable
Reconstructing the Convex PolygonGiven all edges and non-crossing diagonals of a convex polygon with shuffled vertex labels, recover the cyclic boundary order, with vertex 1 first and the smallest possible second vertex.Hard9GraphImplementation+1No attempts yet1s128 MBJudgeable
Minimum bracketsGiven an arithmetic template with holes, delete as many brackets as possible while keeping the same value for every valid assignment of real numbers to the holes.Hard9StringImplementation+2No attempts yet1s128 MBJudgeable
BARMANGiven orders m_i of hidden values modulo a hidden n, choose up to 2k range-multiply operations to maximize the worst-case guaranteed order of the final sum.Hard9Number theoryMath+2No attempts yet1s128 MBJudgeable
Asynchronous ExceptionsSimulate a multithreaded scheduler with yields, kills, fork modes, loops, and semaphores, then report each thread's finishing time and the final state.Hard9SimulationHeap+2No attempts yet5s512 MBJudgeable
Clock BreakingGiven several consecutive LCD clock displays, find segments that are always burnt out, burnt in, working, or unknown across all consistent start times and fault assignments.Hard9ImplementationBrute force+1No attempts yet5s512 MBJudgeable
Polygonal PuzzleGiven two simple polygons, translate and rotate them without reflection so their interiors stay disjoint and their shared boundary is as long as possible; print that maximum length.Hard9GeometryBrute force+2No attempts yet20s512 MBJudgeable
Road TimesGiven a unique shortest route for each ordered city pair, recorded delivery times constrain 30 to 60 km/h road speeds; for each query find the minimum and maximum travel time consistent with all records.Hard9Shortest pathMath+2No attempts yet5s512 MBJudgeable
Archaeological ResearchGiven the surviving shuffled entries of a table of next occurrences for an unknown alphabet size, recover the lexicographically smallest original sequence or report that none exists.Hard9GreedyGraph+2No attempts yet2s512 MBJudgeable
DinnerGiven ages, decide whether all people can be split into round tables of size at least 3 so that every pair of adjacent ages sums to a prime.Hard9GraphMath+2No attempts yet2s512 MBJudgeable
New TrackConstruct a fixed alternating axis-parallel polyline through a formula that encodes exactly k crossings, using a zigzag permutation of y coordinates to place them.Hard9ImplementationCombinatorics+2No attempts yet2s512 MBJudgeable
Reverse a Road IIEach directed road carries at most one truck; find whether reversing one road increases the max number of edge-disjoint S-to-T paths, the new maximum, and how many roads achieve it.Hard9GraphBFS+2No attempts yet8s512 MBJudgeable
ArrayStart with array a_i = i, apply up to 300000 queries that reverse or rotate subarrays and ask for range min, max, sum, value at index, or index of a value, then print the final array.Hard9ArrayImplementation+2No attempts yet1s512 MBJudgeable
Distant StarsEach star moves at constant integer velocity; for each day 0 to T find the maximum pairwise squared distance, and report the earliest day attaining the minimum of that maximum.Hard9GeometryDivide and conquer+2No attempts yet2s512 MBJudgeable
One Pass ShortConstruct a directed graph with edge weights 1 or -1, no negative cycle, yet a Bellman-Ford variant that runs N-2 rounds then checks would falsely report a negative cycle; minimize the edge count and lexicographic order.Hard9GraphShortest path+2No attempts yet2s512 MBJudgeable
Three Kingdoms of BourdelotDecide whether some assignment of positive or negative polarity to each document is consistent with the hypothesis that person p is an ancestor of person q.Hard9GraphUnion-find+2No attempts yet4s512 MBJudgeable
Fencing off the darknessGiven a grid of bulb strengths and a ceiling height, compute each square's light level, mark the dark ones, then find the cheapest set of interior squares that contains all dark squares and minimizes the perimeter cost.Hard9GraphMinimum spanning tree+2No attempts yet2s512 MBJudgeable
Where are the bubbles?Given the per-turn swap counts of bubblesort, reconstruct the lexicographically largest permutation that produces exactly those swap counts.Hard9ImplementationGreedy+2No attempts yet2s512 MBJudgeable
Allowed swapsMaintain an array under swaps and union operations, answering whether it can be sorted and counting pairs of clouds whose merge would fix both.Hard9Union-findImplementation+2No attempts yet6s512 MBJudgeable
Mobile Network BandwidthGiven a graph whose edge capacities are polynomials in x, output the max-flow polynomial from node 1 to node N for large x.Hard9GraphGreedy+2No attempts yet8s512 MBJudgeable
Blue ForestGiven several planar floor maps that may be rigid-motion duplicates, unify matching maps, merge their warp gates, then find the shortest route from entrance to exit.Hard9GeometryGraph+2No attempts yet8s512 MBJudgeable
Magical Mystery Knight's TourFill the missing numbers so the 8x8 board becomes a semi-magical knight's tour with equal row and column sums, choosing the lexicographically smallest completion.Hard9BacktrackingBrute force+2No attempts yet2s512 MBJudgeable
Sequence and queries 12Maintain a dynamic sequence under point updates, deletions, and insertions, answering range queries for distinct count and the sum of triple products of distinct values.Hard9Segment treeHash map+2No attempts yet2s512 MBJudgeable
British MenuGiven a directed graph where every cycle witnesses a repeat within at most four intervening dishes, find the longest simple path (no repeated vertex).Hard9GraphDynamic programming+2No attempts yet5s1024 MBJudgeable
ConferenceGiven M daily pairwise meetings among N people (first K are scientists), find the latest creation day for each invention so a journalist still learns it, then report which journalists learn anything and each invention's first journalist.Hard9GraphUnion-find+2No attempts yet2s512 MBJudgeable
EggscavationGiven up to 100000 shell species (each in at most 4 cells) and egg insertions, answer queries for the probability that a random K x K scoop covers at least V species and no egg.Hard9GeometryPrefix sum+2No attempts yet10s512 MBJudgeable
LegendsGiven a connected graph, decide whether it can be built from one of five small starting graphs using edge additions, isolated-vertex additions, and vertex splits (each split adds a new vertex adjacent to the old one).Hard9GraphDivide and conquer+2No attempts yet2s512 MBJudgeable
Unlucky 89Average the circumferences of all integer right triangles whose hypotenuse is k*sqrt(89) with k up to n, printed as exact mixed numbers in an ASCII box.Hard9Number theoryMath+2No attempts yet2s512 MBJudgeable
The Gardener of Seville (Large)Fill an R by C grid with slash or backslash hedges so that paired border courtiers connect through disjoint corridors, choosing the lexicographically smallest valid maze or reporting IMPOSSIBLE.Hard9ImplementationSimulation+2No attempts yet5s512 MBJudgeable
The Kingdom of JOIOIPartition an H by W grid into two connected regions whose row and column slices are contiguous, minimizing the larger altitude range within either region.Hard9Binary searchGreedy+2No attempts yet4s256 MBJudgeable
Rides 2Each day one child grows by 1 or 2, and we must report how many of Q fixed child-pair and ride triples become valid that day.Hard9Segment treeSorting+2No attempts yet2s256 MBJudgeable
Shifty GridApply a fixed two-phase procedure of cyclic row and column shifts to sort a permutation grid into row-major order, following the exact TURN steps given.Hard9SimulationImplementation+2No attempts yet2s512 MBJudgeable
Slate Modern (Large)Fill a huge R by C grid with positive integers so adjacent cells differ by at most D, matching N fixed cells, maximizing the total sum or reporting impossibility.Hard9GraphShortest path+2No attempts yet80s512 MBJudgeable
Omnicircumnavigation (Large)Given points on a unit sphere joined in order by shortest arcs, decide whether the closed path meets every great circle.Hard9GeometryMath+2No attempts yet120s512 MBJudgeable
Sequence and TransformationCount length-n sequences with entries in [1,m] whose image after applying a min-based affine transformation k times has the given max-minus-min value.Hard9CombinatoricsMath+2No attempts yet2s512 MBJudgeable
Polynomial and QueriesEvaluate a degree-N polynomial with integer coefficients at K given points, all modulo the prime 786433, with N and K up to 250000.Hard9Number theoryDivide and conquer+2No attempts yet10s512 MBJudgeable
Equivalent DeformationGiven two equal-area triangles, find the minimum number of vertex-sliding operations that map the first exactly onto the second.Hard9GeometryImplementation+2No attempts yet2s512 MBJudgeable
Jupiter Rock Paper ScissorsEach player crops a length-k substring, Alice morphs one block, then the play phase awards 2/1/1 points by who reaches m round wins first; report the optimal outcome.Hard9Game theoryImplementation+2No attempts yet2s512 MBJudgeable
SkiingFind the shortest polygonal path from S down to F that crosses n horizontal gates in top-to-bottom order, and output its breakpoints.Hard9GeometryGreedy+2No attempts yet1s1024 MBJudgeable
Restaurant BribesGiven a friendship graph and a list of k people to bribe, choose a real bribe for each so the total restaurant revenue minus bribe money is maximized, and print the answer as an exact reduced fraction.Hard9GraphMath+2No attempts yet2s512 MBJudgeable
One-Way StreetsGiven an undirected multigraph and required reachable pairs, decide for each edge whether every valid orientation matches the input direction (R), the reverse (L), or both are possible (B).Hard9GraphDFS+2No attempts yet3s256 MBJudgeable
Lunar LandscapeCompute the total area covered by axis-aligned squares and 45-degree rotated squares, counting overlaps once.Hard9GeometrySorting+1No attempts yet2s512 MBJudgeable
Counting CyclesA connected undirected graph with n vertices and at most n+15 edges is given; count all simple cycles, where a simple cycle is a connected subgraph with every degree exactly two.Hard9GraphDFS+2No attempts yet4s512 MBJudgeable
LeadersAnimals in a circle alternately raise a running number by 1 to K; whoever is forced to say M loses, and we find the winner of every start position.Hard9Game theoryDynamic programming+2No attempts yet3s512 MBJudgeable
Disco Dance DebacleGiven a grid where some cells are unlit (unions of rectangles), find the fewest cell states to flip so that a set of alternating row-column dances can cover all lit cells, each dance starting and ending on the same cell with different first and last feet.Hard9GraphGreedy+2No attempts yet5s512 MBJudgeable
Imelda's Shopping SpreeMaintain a sequence of prices under range-add and range-reverse, and after each update output the number of contiguous segments whose values are strictly increasing.Hard9Segment treeArray+2No attempts yet5s512 MBJudgeable
Majestic Gourmet UniversityGiven proposed FC and IC lab slots with teacher conflicts, seat limits, and timing rules, choose a valid set of labs using the fewest distinct starting days.Hard9GraphBFS+2No attempts yet2s512 MBJudgeable
Vera and Love TrianglesFor each pair of friends, a crush direction is set by the parity of the bit-count of a modular power expression; count cyclic triples.Hard9CombinatoricsNumber theory+2No attempts yet2s256 MBJudgeable
Push a BoxGiven a grid with Bessie and a pushable box, decide for each queried cell whether the box can reach it.Hard9GraphBFS+1No attempts yet2s512 MBJudgeable
GardenerMaintain N gardens under plantings, range deletions of plants taller than h, and range count queries, all with time-dependent growth.Hard9Segment treeBinary search+2No attempts yet3s128 MBJudgeable
Street TreesMaintain a minimum-cost coloring of N vertices with two colors under incremental equality/inequality constraints and point cost updates, reporting the optimum after each operation.Hard9Union-findGraph+2No attempts yet2s256 MBJudgeable
Uncrossed Knight's TourGiven an m by n board (m at most 8, n up to 1e15), find the maximum number of squares a closed knight tour can visit without crossing itself.Hard9GreedyDynamic programming+2No attempts yet2s1024 MBJudgeable
General graph matchingGiven an undirected graph with N vertices and M edges, print the size of a maximum matching.Hard9GraphGreedy+2No attempts yet1s128 MBJudgeable
Koala GameDetermine properties of a hidden permutation by bidding stones in a game where Koala optimally maximizes the sum of values she wins, using as few rounds as possible.Hard9Game theoryGreedy+2No attempts yet2s512 MBJudgeable
Growing TreesGiven a tree whose edge weights change linearly with the day, find the day in [0, D] that minimizes the diameter, and report that diameter.Hard9TreeGreedy+2No attempts yet5s768 MBJudgeable
Pia's Atelier: The Alchemist of Mysterious LifeGiven 2x2 parity constraints on an n by n binary grid, decide for each day whether a grid exists satisfying all interval cell-fixing conditions active that day.Hard9Union-findPrefix sum+2No attempts yet2s512 MBJudgeable
International Cow Lineup Photo ContestGiven a 0/1 array and up to 1e5 adjacent swaps, after each swap report the longest subarray with equal numbers of 0s and 1s.Hard9Segment treePrefix sum+2No attempts yet2s512 MBJudgeable
Team BuildingMaintain teams under merge, a split that separates members by their remainder mod P, and size queries, for up to 100000 commands.Hard9Union-findImplementation+1No attempts yet1s512 MBJudgeable
Growing MicroorganismsWith buy costs and production costs, buy microorganisms and make each kind produce others to reach x_i of every kind at minimum total cost.Hard9MathGreedy+2No attempts yet2s512 MBJudgeable