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 results14,366 problems
TopicsJudge
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
TelecorpPlace one of M module types on any subset of N teleporters, each jump skipping ahead and multiplying speed, to minimize total travel time from 0 to L.Hard9Dynamic programmingGreedy+2No attempts yet1s1024 MBJudgeable
Longest Paths in a TreeA rooted tree has weighted edges. Handle point updates to edge weights and queries that ask for the maximum-weight downward path from a vertex inside its subtree.Hard9TreeSegment tree+2No attempts yet5s1024 MBJudgeable
Falling BallsGiven slanted platforms whose endpoints move over time, find the final x-coordinate reached by a ball dropped at a given x.Hard9Segment treeTree+2No attempts yet2s1024 MBJudgeable
Joy of Mobile RoutingGiven grid building heights and antennas, find the shortest path from a start to a destination intersection where every visited intersection has line-of-sight to some antenna.Hard9GraphShortest path+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
Parallel ExpectationsGiven two programs run by randomly interleaving their instructions, find the expected final value of every shared variable.Hard9ProbabilityDynamic programming+1No 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
IlluminationAssign N fixed angular directions to N sources so their wedges cover the plane and the sum of projections is minimized, tie-broken lexicographically.Hard9GeometryCombinatorics+2No attempts yet1s128 MBJudgeable
King's QuestFor each son, list every girl he likes such that a perfect matching still exists when he marries her.Hard9GraphDFS+2No attempts yet1s128 MBJudgeable
ExamGiven each student's distribution over exam scores, find the exact probability that the sequence of European marks from all students avoids every listed unpleasant string.Hard9Dynamic programmingString matching+2No attempts yet2s128 MBJudgeable
JoggerGiven the distance matrix of a tree with houses as leaves, find the leaf pair whose weighted travel time (distance times r plus internal nodes crossed times t) is largest.Hard9TreeGraph+2No attempts yet1s128 MBJudgeable
PurifyRepeatedly delete forbidden substrings from P, always choosing the earliest-ending occurrence and removing the shortest such forbidden word, then print what remains.Hard9StringTrie+2No attempts yet1s64 MBJudgeable
DuopolyGiven two sets of weighted bids on channels, where bids within one company are disjoint, pick a subset of non-conflicting bids to maximize total price.Hard9Dynamic programmingGreedy+1No attempts yet3s32 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
Structural IsomersCount the number of distinct alkane carbon skeletons (free trees in which every node has degree at most 4) with n carbon atoms.Hard9Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Juggle with CriteriaFor each of n five-symbol relation patterns (<, =, >) and a fixed length l, decide whether two permutations of length l exist whose inversion count, local inversions, LIS, longest increasing substring, and fixed points match that exact pattern.Hard9CombinatoricsDynamic programming+2No attempts yet1s128 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
Hypervisor MacrOSDecode an altered event log with a hidden reverse switch by maintaining reachability and answering whether A must precede B.Hard9GraphTopological sort+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
Markov TrainsFind the station list maximizing the chance of arriving by a deadline when each train may be cancelled and the traveler waits for the next one after a cancellation.Hard9Dynamic programmingProbability+1No attempts yet1s128 MBJudgeable
Mirror TrapFor each box [-x,x]x[-y,y]x[-z,z], find the maximum Manhattan distance a laser at the origin can travel before returning to the origin, avoiding edges and vertices.Hard9MathNumber theory+2No attempts yet3s512 MBJudgeable
Dextrogyrate CamelFind the longest closed camel route that starts at oasis 1 heading to oasis 2, always turns right by at most 180 degrees at each oasis, never crosses itself, and visits the most distinct oases.Hard9GeometryDynamic programming+2No attempts yet1s512 MBJudgeable
Bus TourChoose a sequence of attractions with strictly increasing construction times maximizing attractiveness collected plus Manhattan travel distance.Hard9Dynamic programmingSorting+2No attempts yet1s128 MBJudgeable
Save the DinosaursFor each vacant point, add it to the existing set and report the area protected by the soldiers (the region where every move gets closer to some soldier).Hard9GeometrySorting+2No attempts yet1s128 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
SleepwalkerA self-similar walk on a 3^k by 3^k grid is defined by a recursive rewrite; given a starting tile on the walk and a hole tile, find the number of steps until the walk reaches the hole.Hard9RecursionDivide and conquer+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
AB-wordsGiven up to 1000 nice ab-words (balanced parentheses words), count the maximum subset of pairwise non-similar words under a recursive similarity relation.Hard9TreeHash map+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
Driving ExamBuild at most k new horizontal one-way streets on a grid so that the number of streets whose southern end can reach every street's northern end is maximized.Hard9GraphDynamic programming+2No attempts yet1s128 MBJudgeable
TollEach selected town must charge on exactly one incident road, and no road may be charged by both endpoints. Maximize selected towns in a general graph, not necessarily the whole graph.Hard9GraphMathNo 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
IslandGiven a convex polygon with towns on its vertices, all diagonals and sides drawn, and some segments blocked, find the shortest path from vertex n to vertex 1 using roads and their crossings.Hard9GraphShortest path+1No 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
HamstersFind the shortest lowercase string containing at least m occurrences of the given hamster names, counted with multiplicity.Hard9String matchingDynamic programming+2No attempts yet3s512 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
GarbageEach street needs its state flipped or not; a route is a simple cycle, and driving a street flips it. Find the minimum total length of cycles whose symmetric difference equals the set of streets needing a flip.Hard9GraphDFS+2No attempts yet1s128 MBJudgeable
PeriodicityFor each name, find the lexicographically smallest bit string of the same length whose set of periods equals the name's set of periods, or XXX if none exists.Hard9StringPrefix sum+2No attempts yet1s128 MBJudgeable
Milk MultidrinkDecide whether a tree with n nodes has a Hamiltonian path from 1 to n where consecutive vertices stay within distance two.Hard9TreeDFS+2No attempts yet1s128 MBJudgeable
Ski RentalGiven daily snowfall amounts with point updates, answer queries asking for the maximum average snowfall over a consecutive run starting at a given day, reported as an irreducible fraction.Hard9Segment treeGeometry+1No attempts yet1s128 MBJudgeable
Binary KnockoutA coin game on a line: each coin may double its position or move one step right; the player unable to move loses. Find the k-th value of n where the second player wins.Hard9Game theoryMath+1No attempts yet1s128 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
JourneysGiven m batches, each joining every town in one interval to every town in a disjoint interval, find the shortest path in highway count from town p to all towns.Hard9GraphBFS+2No attempts yet1s128 MBJudgeable
Computational BiologyFor each query length m, find a length-m word whose every cyclic rotation appears in s, maximizing the total count of those rotations in s.Hard9StringSorting+2No attempts yet5s128 MBJudgeable
Hard ChoiceAfter streets are closed one by one offline, answer for each query whether two edge-disjoint paths still connect the given pair of junctions.Hard9GraphDFS+2No attempts yet5s128 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
Army TrainingGiven n points with no three collinear, answer m queries, each a simple clockwise polygon on those points, counting the points strictly inside it.Hard9GeometryCombinatorics+2No attempts yet2s512 MBJudgeable
Blindfold NimEach stack size is uniform on [0, a_i]; compute the probability that the first player wins a game of Nim with hidden positions where a player who overshoots a stack loses at once.Hard9Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Quasi-templateCount the distinct words that, as substrings of v with possibly overhanging copies, can tile across the whole input; report the count and the shortest, lexicographically smallest such word.Hard9String matchingString+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
Video PokerFor a given video poker payout table, count how many of the 2,598,960 dealt hands make the optimal expected-value strategy discard exactly 0, 1, 2, 3, 4, and 5 cards.Hard9Brute forceCombinatorics+2No attempts yet1s128 MBJudgeable
MicrochipsCount directed walks whose edge-impedance product equals I, allowing repeated vertices and edges, and report infinity when infinitely many such walks exist.Hard9GraphNumber theory+2No attempts yet1s128 MBJudgeable
Fibonacci WordCount occurrences of a given binary pattern in the Fibonacci word F_m and count distinct subwords occurring at least that many times, mod 20062006, with m up to 1e9.Hard9StringDynamic programming+2No attempts yet1s128 MBJudgeable
HighwaysMaintain a layered graph where each province has a few cities and highway lane counts change over time, answering route-count queries modulo d after each update.Hard9MatrixSegment tree+1No 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
ManhuntGiven a connected undirected graph where the bandit moves to a different city each night, find the minimum number of days for a search schedule that guarantees capture, or report impossibility.Hard9GraphBFS+2No attempts yet1s128 MBJudgeable
Prefix-SuffixesCount proper borders summed over all substrings of a given lowercase word of length up to 10^5.Hard9String matchingString+1No attempts yet1s128 MBJudgeable
PeaksFor each query, starting from a peak and using only edges up to a difficulty limit, report the k-th highest reachable peak height or -1.Hard9GraphUnion-find+2No attempts yet2s128 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
HighwaysGiven a tree plus extra highway edges, count for each query (x,y) the main tree path plus alternative single-highway paths that touch the main path only at x and y.Hard9TreeDFS+2No attempts yet3s128 MBJudgeable
Palindromic EquivalenceCount words of the same length that have palindromic substrings at exactly the same positions as the given word.Hard9StringString matching+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
GodzillaAfter each of k edge deletions in a directed graph, the task asks for the smallest number of start vertices that reach every vertex.Hard9GraphUnion-find+1No attempts yet1s128 MBJudgeable
SetsGiven n arithmetic-progression sets of multiples of d_i, count elements in their union that share no prime factor with m.Hard9MathNumber theory+2No attempts yet1s128 MBJudgeable
The Most Valuable TowerFind the largest sum any single tower can reach by swapping top segments between towers of different heights.Hard9Number theorySorting+2No attempts yet1s512 MBJudgeable
SequenceFind the nth term of the nondecreasing sequence where each k appears exactly as many times as the kth term.Hard9MathBinary search+1No attempts yet1s512 MBJudgeable
GenomeBuild the lexicographically smallest sequence that is l adjacent swaps from the first genome and k-l swaps from the second.Hard9GreedySegment tree+1No attempts yet1s128 MBJudgeable
Land TaxChoose a non-empty contiguous row and column range that maximizes combined row and column payments weighted by heights and widths.Hard9Divide and conquerGeometry+2No attempts yet1s128 MBJudgeable
Plot of LandGiven up to 3000 pine points and one million query rectangles, report the convex hull area of the points inside each rectangle.Hard9GeometryDivide and conquer+1No attempts yet1s128 MBJudgeable
CrystalSum the signed charges of all three-colored unit triangles in a hexagonal crystal filled row by row from a modular generator.Hard9MathGeometry+2No attempts yet1s128 MBJudgeable
Thirsty AntsAnts on a line walk at unit speed toward the nearest fallen dew drop, and the task asks for every ant's position when the last drop is drunk.Hard9SimulationSorting+2No attempts yet1s128 MBJudgeable
MultiplicationGiven prime p and each query pair a and b, find the smallest k with a to the k-th power congruent to b modulo p, or print -1 when b never appears.Hard9Number theoryMath+1No attempts yet5s128 MBJudgeable
DeliverySend as many trucks as possible from the top-left to the bottom-right corner of an n by n grid where each street has a daily usage limit.Hard9GraphShortest pathNo attempts yet10s128 MBJudgeable
WombatsFind the cheapest southbound path across a grid with free east-west moves and south-only vertical roads under weight updates and escape queries.Hard9Segment treeShortest path+1No attempts yet20s256 MBJudgeable
PuzzleBuild the longest string over the first n capital letters that avoids all forbidden substrings, or print No when no maximum exists.Hard9String matchingTrie+2No attempts yet1s128 MBJudgeable
RoofCompute the maximum height of the 45-degree straight-skeleton roof built over a rectilinear polygon.Hard9GeometryNo attempts yet1s128 MBJudgeable
Aquarium DrainageGiven an orthogonal aquarium floor with holes on its segments, compute the total drain time and the water left behind.Hard9GeometrySorting+2No attempts yet1s128 MBJudgeable
Aquarium 3Place K holes on distinct horizontal floor segments to maximize the area of water that drains out.Hard9TreeGreedy+2No attempts yet1s128 MBJudgeable
Möbius StripGiven m and n, compute the average graph distance over all ordered square pairs on the m by 2n Mobius grid.Hard9MathCombinatorics+2No attempts yet1s128 MBJudgeable
Fence WatchPlace the fewest sensors on a convex polygon boundary so every boundary point forms an angle from alpha to 360 degrees minus alpha with some sensor pair.Hard9GeometryGreedy+1No attempts yet1s128 MBJudgeable
MineshaftRun a pipe of straight segments up a winding polygonal shaft so each segment touches the walls in at least two places and the number of bends is minimal.Hard9GeometryGraph+1No attempts yet1s128 MBJudgeable
Anchored BalloonFind the greatest height a balloon tied to ground anchors by fixed-length ropes can reach while all ropes hold and none cross.Hard9GeometryBinary search+1No attempts yet1s128 MBJudgeable
Dragon PatternCount how many times pattern S appears as a contiguous block in the length 2^n direction string of the order-n left dragon curve.Hard9String matchingRecursion+2No attempts yet5s128 MBJudgeable
AdriaticOn a 2500 by 2500 grid, islands ordered alike from northwest to southeast connect in one hop, and each island needs the sum of fewest hops from all others.Hard9GraphPrefix sum+1No attempts yet2s256 MBJudgeable
Lonely MountainGiven two orthogonal mountain silhouettes, decide whether any solid casts both and print the largest possible volume modulo 1000000007.Hard9GeometryMath+2No attempts yet2s256 MBJudgeable
Largest and Smallest TriangleGiven n points in the plane, compute the largest and smallest areas among all triangles formed by triples of the points.Hard9GeometrySorting+1No attempts yet6s128 MBJudgeable
It Takes a VillageProcess online trading-post additions that spread through biconnected blocks and capital dominators, and answer revenue queries for single villages.Hard9GraphDFS+2No attempts yet20s128 MBJudgeable