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
Chain & Co.Decide whether axis-aligned square links split into two nonempty groups with every cross pair linked.Hard9GeometryGraph+1No attempts yet10s128 MBJudgeable
Cactus AutomorphismsCount the automorphisms of a given cactus graph with up to 50000 vertices and print the count as a prime factorization.Hard9TreeDynamic programming+2No attempts yet5s256 MBJudgeable
Green EnergyPlace towers of given heights on a polygonal terrain to maximize the total length lit by parallel sun rays blocked by terrain and other towers.Hard9GeometryGreedy+1No attempts yet1s128 MBJudgeable
Teaching HazardGiven n and x, count pairs of bases b1 < b2 where n! ends in the same number of trailing zeros p with p at least x.Hard9Number theoryMath+1No attempts yet5s128 MBJudgeable
RecurrenceCount the decrement orders that reduce the given partition to all zeros while staying nonincreasing, modulo 1,000,000,009.Hard9CombinatoricsNumber theory+1No attempts yet1s128 MBJudgeable
Strange GraphDecide whether a connected strange graph, where every high-degree vertex has a degree-2 neighbor and its other neighbors form a clique, has a Hamiltonian cycle.Hard9GraphNo attempts yet1s128 MBJudgeable
Even cycle partition of a planar graphGiven a vertex-biconnected planar graph with at most two odd faces, decide whether its edges partition into even simple cycles.Hard9GraphMathNo attempts yet1s128 MBJudgeable
GRADCities join the road network one by one with two roads each, and each query asks the shortest road distance between two cities.Hard9Shortest pathGraph+2No attempts yet2s256 MBJudgeable
Rail Station RecoveryRecover every station's block number and C or D type from the all-pairs shortest-route distances and station 0's block.Hard9GraphSorting+1No attempts yet3s512 MBJudgeable
Gondola replacement countCount the replacement orders that can produce the given circular gondola sequence, modulo 1000000009.Hard9CombinatoricsMathNo attempts yet1s256 MBJudgeable
FriendChoose a set of people with maximum total confidence so that no two chosen people are friends in the network grown by the three joining rules.Hard9GraphDynamic programming+1No attempts yet1s16 MBJudgeable
OrbitPlace two opposite sensors on the radius-R circle so their brightest-star readings match, and print the pair with the smallest angle.Hard9GeometryMath+1No attempts yet2s256 MBJudgeable
Maximum Transport ProfitPick two villages in the tree so the total profit of the given routes with both endpoints on the path between them is as large as possible.Hard9TreeDynamic programmingNo attempts yet3s256 MBJudgeable
Bisecting the IslandSplit an axis-parallel simple polygon into two congruent pieces with one axis-parallel cut on integer coordinates, or report that none exists.Hard9GeometryBrute forceNo attempts yet1s256 MBJudgeable
The Forest of FangornFind which border camps connect to the start by a path where no tree ever hides behind another tree.Hard9GeometryGraphNo attempts yet3s64 MBJudgeable
CakeStarting from piece a, Leopold always eats the less delicious piece next to the empty interval, and each query asks how many pieces are eaten before piece b.Hard9Segment treeDivide and conquer+2No attempts yet2s1024 MBJudgeable
Solar LampsCompute each lamp turn-on time from its place in the power-on order and the count of already lit lamps shining on it.Hard9GeometrySegment tree+1No attempts yet1s256 MBJudgeable
ParkingDecide whether axis-aligned cars in a strip of height w can be slid without overlap or rotation from the start layout to the target layout.Hard9GeometryGraph+2No attempts yet3s256 MBJudgeable
Sequence CenterGiven k integer sequences of length n, find an integer sequence that minimizes the maximum Manhattan distance to them.Hard9MathBinary searchNo attempts yet3s256 MBJudgeable
MuseumA burglar picks guards to bribe to maximize the value of exhibits no remaining guard sees minus bribe costs under downward cone views.Hard9GraphGeometry+1No attempts yet1s256 MBJudgeable
TollgateFind the road with the largest expected toll income when every resident visits every restaurant by a random shortest round trip.Hard9Shortest pathGraph+2No attempts yet2s256 MBJudgeable
Watering the Bean PlantsPlace at most one disk of radius R and cover the uncovered parts of N segments with unit-length sticks at minimum total cost.Hard9GeometryGreedy+1No attempts yet10s256 MBJudgeable
ExhibitionFind the cheapest linear-cost cuts to product 1's price, size and weight that put it in some k-set tying the best set without it.Hard9Dynamic programmingMath+1No attempts yet10s256 MBJudgeable
Combinator ExpressionCount the fewest BCKI rewrite steps that reduce the given expression to its normal form.Hard9Dynamic programmingTree+1No attempts yet1s256 MBJudgeable
Expression and SubstringFind the shortest string that matches the given regular expression and contains S as a substring, breaking ties by lexicographic order.Hard9Shortest pathGraph+1No attempts yet10s256 MBJudgeable
Growing Orthogonal SpiralDecide whether an orthogonal spiral whose segment lengths grow by at least 1 can end exactly at (x, y) and print the shortest such lengths.Hard9MathNumber theory+1No attempts yet1s256 MBJudgeable
Red and Black Stepping StonesFind the smallest lookahead queue size that lets the mover survive forever on a red-black directed graph against an adversarial color chooser.Hard9Game theoryGraph+1No attempts yet9s256 MBJudgeable
Pork barrelFor each query interval [l, h], build the cheapest forest using only roads with costs inside the interval that connects as many city pairs as possible.Hard9Minimum spanning treeDivide and conquer+2No attempts yet30s256 MBJudgeable
Hidden MazeCompute the expected median edge weight over all tree node pairs at odd distance, and print it as a reduced fraction.Hard9Divide and conquerTree+2No attempts yet2s256 MBJudgeable
Tokyo Olympics CenterAssign each lettered unit to one of K staff and order the visits to minimize the longest round trip from the start cell that checks every dead-end room.Hard9Dynamic programmingShortest path+1No attempts yet5s128 MBJudgeable
Revenge of Minimum Cost FlowSend f units of freight from city s to city t through directed carrier edges with two-piece linear costs and report the cheapest total.Hard9GraphShortest path+1No attempts yet3s256 MBJudgeable
Hashigo SamaCount black-white colorings of joined ladders where each monochrome block has size at most k, modulo 1,000,000,007.Hard9Dynamic programmingGraphNo attempts yet8s256 MBJudgeable
Overwriting GameYou repeat random prefix-rectangle repaints until the board matches the target, and report the expected total of painted cells as a reduced fraction.Hard9ProbabilityMatrix+1No attempts yet8s512 MBJudgeable
Slave to Achievements 2Repeatedly craft as many N-scrap daggers as possible and reclaim 0 to K scraps per dagger, then find the distribution of the final leftover under N scraps.Hard9ProbabilityDynamic programming+1No attempts yet3s256 MBJudgeable
Believer in I 2Over every ordering of A push, B add, and C multiply cards on an infinite stack of I, report the total of each of the top K stack values modulo 1,000,000,007.Hard9CombinatoricsDynamic programming+2No attempts yet3s256 MBJudgeable
Followers of I 3Sum, over every distinct order of the I, plus, and times cards run on an infinite I stack, the top K stack values modulo 1000000007.Hard9Dynamic programmingCombinatorics+1No attempts yet3s256 MBJudgeable
Same Suffix ArrayCount the strings that differ from the given length N string in exactly one position and keep the same suffix array.Hard9StringString matching+1No attempts yet2s256 MBJudgeable
Meeting in the Sierpinski LabyrinthTourists stand on cells of a grid that are free exactly when row and column share no binary 1 bit, and must meet in one cell with minimum total steps.Hard9TreeDivide and conquer+1No attempts yet3s512 MBJudgeable
Tile CuttingFor each query range, find the area with the largest count of inscribed parallelogram cuts and report that count, breaking ties by the smaller area.Hard9Number theoryMath+1No attempts yet15s256 MBJudgeable
Art GalleryFind the vertex sequence of the shortest interior path between two given vertices of a polygon lit from edge v0-v1.Hard9GeometryShortest pathNo attempts yet1s256 MBJudgeable
Dictionary SurveyFind how many leading pages of the integers from A to B in lexicographic order pin down both A and B.Hard9TrieMath+1No attempts yet3s256 MBJudgeable
Bulb PuzzleYou rotate every elbow and straight wire so all wires form one path that joins the two bulbs, and print the smallest such layout.Hard9GraphBacktracking+1No attempts yet1s256 MBJudgeable
PhibonacciGiven n and k, decide whether (P_n)^k equals A φ^k + B for integers A and B and print them modulo 1,000,000,007, or -1.Hard9Number theoryMathNo attempts yet1s256 MBJudgeable
Random signalsCompute the expected plane integral of the strongest covering signal when each of up to 20 stations draws an independent uniform power that activates its disks.Hard9GeometryProbability+1No attempts yet12s256 MBJudgeable
Sorting under interferenceFind the fewest rounds of one swap per round that sort a permutation despite known interfering swaps, with the smallest move list on ties.Hard9MathGreedyNo attempts yet1s512 MBJudgeable
Calvinball Championship, Again 2Split n players into the fewest teams so no pair who dislike each other shares a team.Hard9GraphBacktracking+1No attempts yet1s256 MBJudgeable
Card Rarity EncodingGiven N draws over four rarities with known probabilities, find the smallest possible expected length of a prefix-free binary code for the N-draw sequences.Hard9GreedyHeap+2No attempts yet3s128 MBJudgeable
Development of Small Flying RobotsEach robot moves sideways for 1 energy and rises through a hole for 100, and all must meet on one hole-free cell of the top floor for the least total energy.Hard9Shortest pathGraph+1No attempts yet1s256 MBJudgeable
FroggerFind the fewest frogs to place left of the y-axis so peg jumps can bring one frog to (X, 0), or print frogger when it is impossible.Hard9MathBFS+1No attempts yet1s256 MBJudgeable
Join My TeamPair N participants by ranked preference lists into the lexicographically smallest stable pairing with no blocking pair, or report NO SOLUTION.Hard9GraphGame theoryNo attempts yet1s256 MBJudgeable
Hogwarts staircasesFind the shortest sequence of red and green button presses that turns the current staircase layout into the desired one, breaking ties by lexicographic order.Hard9BFSShortest path+2No attempts yet1s256 MBJudgeable
Canyon MappingCover a simple polygon with k equal axis-aligned squares and print the smallest side length that covers it, rounded to two decimals.Hard9GeometryBinary search+1No attempts yet1s256 MBJudgeable
Nim with a Robot RefereeDecide each bag's winning first takes in a Nim variant where piles with forbidden divisor patterns vanish before every turn.Hard9Game theoryNumber theoryNo attempts yet2s512 MBJudgeable
Counting Distinct Suffix ArraysCount how many distinct suffix arrays length-N strings with at most M distinct letters produce, modulo 1e9+7.Hard9CombinatoricsString+1No attempts yet1s512 MBJudgeable
Quaternary ComputerGiven N base-4 variables, M add and xor commands, and one forbidden start value per variable, print each output total over all inputs modulo 4.Hard9Bit manipulationMath+2No attempts yet1s512 MBJudgeable
Balancing LineFind the shortest closed curve avoiding square lamp footprints that encloses a nonempty lamp group holding half the total energy.Hard9GeometryBrute force+1No attempts yet10s256 MBJudgeable
KernelDecide whether a rectilinear polygon contains a beacon point that attracts every other point under greedy distance-decreasing motion.Hard9GeometryNo attempts yet1s256 MBJudgeable
Tree Edit DistanceCompute the minimum leaf insertions, leaf deletions, and relabels that turn one ordered labeled tree into another.Hard9Dynamic programmingTreeNo attempts yet2s256 MBJudgeable
Radio WatchtowersKeep K of N towers on a line and raise their radio powers so each pair of kept towers can talk, minimizing raise cost minus sale income.Hard9GreedySorting+2No attempts yet1s256 MBJudgeable
Highways and CountiesFind the smallest road length limit so cities joined by shorter roads form a group whose populations hold a subset summing to a multiple of K.Hard9Minimum spanning treeDynamic programming+2No attempts yet2s64 MBJudgeable
Dungeon CreationCount the spanning trees of the obstacle-free grid graph for each test case, modulo 1,000,000,007.Hard9Dynamic programmingGraph+1No attempts yet3s512 MBJudgeable
CasinoWith m dollars, a goal of n dollars and win chance p percent per play, pick each stake to maximize the chance of reaching the goal.Hard9ProbabilityDynamic programming+1No attempts yet2s256 MBJudgeable
Runner and SniperYou give your start position and the gun's start angle and turn rate, then compute the fastest run speed at which the rotating gun still catches you.Hard9Game theoryGeometry+1No attempts yet2s256 MBJudgeable
Wall Making GameTwo players alternately pick an empty cell and turn its row and column lines into walls until blocked, and the player unable to move loses.Hard9Game theoryDivide and conquer+1No attempts yet2s256 MBJudgeable
Cactus edge moveCount the pairs of deleting one edge and inserting a different edge that keep the given graph a cactus.Hard9GraphCombinatoricsNo attempts yet1s256 MBJudgeable
Rotating Cutter BitsThe program counts interior lattice points of a polygonal workpiece that survive one full rotation against a second rotating polygonal cutter.Hard9GeometrySimulation+1No attempts yet3s256 MBJudgeable
FactoriesEach query gives two factory sets on a weighted tree and asks for the minimum distance between any factory in one set and any in the other.Hard9Divide and conquerTree+1No attempts yet6s512 MBJudgeable
Magical SubarraysEach query asks for the longest subarray inside [L,R] with every element between its first and last values.Hard9Divide and conquerSegment tree+1No attempts yet4s128 MBJudgeable
Lights Out in the BarnStarting at an unknown vertex of a rectilinear barn, walk the walls to identify the position and reach the exit with the smallest worst-case extra distance.Hard9Dynamic programmingGame theory+1No attempts yet2s512 MBJudgeable
CircusFind the smallest starting hold depth on a temporary rope at D that reaches distance M by hopping between ropes within swing range.Hard9Shortest pathSegment tree+1No attempts yet2s512 MBJudgeable
GaussStarting from A, pay divisor-based costs to shrink the number or stay on lucky numbers, and find the cheapest exact-move cost to end at B.Hard9Dynamic programmingShortest path+2No attempts yet2s256 MBJudgeable
WillowTwo players choose starting cities on a tree with coins and alternately collect cities, each road usable once, and Hanaa maximizes the final score difference.Hard9Game theoryTree+1No attempts yet5s512 MBJudgeable
Twirling Towards Freedom (Large)Each minute you stay put or rotate 90 degrees clockwise around a star, and must report the largest squared distance from the origin reachable in M minutes.Hard9GeometryNumber theory+2No attempts yet5s512 MBJudgeable
Lost Password (Large)Given string S and integer k, compute the length of the shortest string containing every l33tspeak variant of each substring of S with length 1 to k.Hard9GraphShortest path+1No attempts yet100s512 MBJudgeable
Children Wearing Hats (Large)Given B black and W white hats for k children, count color sequences where the i-th child from the back first deduces their hat color, modulo 32749.Hard9Dynamic programmingGame theory+1No attempts yet5s512 MBJudgeable
Ace in the HoleGiven Ben's examination order, restore the lexicographically greatest deck with no decreasing triple that makes his optimal search follow it.Hard9Game theoryGreedy+2No attempts yet60s512 MBJudgeable
Expensive Dinner (Large)Friends 1 to N arrive in any order and raise the shared bill to multiples of their numbers, and you report the gap between the most and fewest waiter calls.Hard9Number theoryMathNo attempts yet5s512 MBJudgeable
SheepwalkingTwo sheepdogs block two neighboring cells each turn to steer a randomly moving sheep home and minimize its expected number of moves there.Hard9ProbabilityGame theory+1No attempts yet20s1024 MBJudgeable
Ninjutsu (Large)Pick a starting rope length so the counterclockwise swing catches as many targets as possible before settling into orbit.Hard9GeometryDynamic programming+1No attempts yet60s512 MBJudgeable
Paths of Yin and Yang (Small)Count the black-and-white colorings of an N by M grid in which each color class forms a single path with two ends.Hard9CombinatoricsBacktracking+1No attempts yet30s512 MBJudgeable
The Paths of Yin Yang (Large)Count the black-and-white colorings of an N by M grid in which each color forms one edge-adjacent path.Hard9CombinatoricsGraphNo attempts yet120s512 MBJudgeable
Watering Plants (Large)Given non-overlapping plant disks, find the smallest radius R so that two disks of radius R together cover every plant disk completely.Hard9GeometryBinary search+2No attempts yet60s512 MBJudgeable
King GameOn a small board with burned squares, two players alternately move a king to an unvisited neighboring square; report who wins under optimal play.Hard9Game theoryGraph+2No attempts yet5s512 MBJudgeable
Coloring Practice (Large)Count colorings of a regular n-gon up to rotation, reflection, and arbitrary permutation of the k colors, modulo 1e9+7.Hard9CombinatoricsMath+2No attempts yet3s512 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
Spin DoctorGiven n points (a_i, b_i) labeled 1 or 0, choose a direction (S, T); with ties broken adversarially, minimize the span covering all label-1 points.Hard9GeometrySorting+2No attempts yet5s512 MBJudgeable
Connect HighwaysGiven two planar connected networks, find the Red-Blue junction pair allowed to be joined by a segment, following a fixed angular tie-breaking rule.Hard9GeometrySorting+2No attempts yet0.4s32 MBJudgeable
Covering postersFor each new axis-aligned rectangle, compute the total area of the given union of rectangles that it covers.Hard9Segment treePrefix sum+2No attempts yet2s1024 MBJudgeable
Half-plane land grab 2Maintain a dynamic set of lines under insertions and deletions and answer maximum-at-x queries online.Hard9Dynamic programmingDivide and conquer+2No attempts yet4s512 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
Counting StringsCount strings over the lowercase alphabet whose length lies between L*K and L*K+N and in which at most K non-overlapping copies of a given pattern S can be found.Hard9Dynamic programmingString matching+2No attempts yet2s512 MBJudgeable
Number of walksGiven a directed graph as an adjacency matrix, find the smallest K such that the number of walks of length L grows as O(L^K), or -1 if none exists.Hard9GraphDynamic programming+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
Clique on a LineGiven n points on a line with weights, two points are adjacent when their weights sum to at most their distance; find the largest clique.Hard9Dynamic programmingSorting+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
Growing a Binary TreeFor each tree, pick a root and count the fewest vertices to add so that the result becomes a complete binary tree (every internal vertex has exactly two children, all leaves equidistant from the root), minimizing that count and then the vertex index; output the count mod 1e9+7.Hard9TreeDFS+2No attempts yet4s512 MBJudgeable
Smallest Unpayable AmountFor each query interval, find the smallest positive amount that cannot be formed as a subset sum of the coins in that interval.Hard9GreedySorting+2No attempts yet4s512 MBJudgeable
YATPGiven a node-weighted, edge-weighted tree, for each node find the minimum of dist(u,v) + p_u*p_v over all v, and sum these minima over all nodes.Hard9TreeDivide and conquer+2No attempts yet5s512 MBJudgeable