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 results3,779 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
MinerFor each lamp position above a polyline mine floor, find the reachable floor interval lit without crossing the floor.Hard9GeometryBinary search+2No attempts yet1.5s512 MBJudgeable
Robotic Cow HerdEach robot picks one model per location, and all K robots must differ somewhere; find the minimum total cost of K distinct robots.Hard9HeapGreedy+2No attempts yet2s512 MBJudgeable
Find the SequenceGiven B, decide whether there exist distinct integers A_i > 1 such that A_i^{B_i} is divisible by the product of all the other A_j.Hard9Number theoryMath+2No attempts yet2s512 MBJudgeable
Clash Royale (Large)Pick 8 of N cards and spend at most M coins on upgrades to maximize the total attack power of the chosen deck.Hard9Dynamic programmingGreedy+1No attempts yet20s512 MBJudgeable
Map Reduce (Large)Each query asks whether walls can be removed so the shortest S-to-F path equals D, and if so reports the deterministic greedy removal order's final map.Hard9BFSGraph+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
RopeA rope of N unit cords with colors is repeatedly folded in half, paying the thickness of cords whose colors are changed, until length 2; for each color report the minimum total cost to end with a cord of that color.Hard9Dynamic programmingDivide and conquer+2No attempts yet2.5s256 MBJudgeable
Building a Tall BarnAssign K cows to N ordered floors, each with work a_i, so each floor gets at least one cow; minimize the sum of a_i/c_i over valid allocations, rounded to nearest integer.Hard9GreedyHeap+2No attempts yet2s512 MBJudgeable
Incremental Double Free StringsFind the nth string of length k(k+1)/2 that uses one letter j times for each j up to k and has no two equal adjacent letters, in alphabetical order.Hard9CombinatoricsDynamic programming+2No attempts yet2s512 MBJudgeable
Largest window sumFor every window length K, find the largest possible sum of a length-K window over all non-negative arrays that satisfy each given length bound.Hard9GreedyPrefix sum+2No attempts yet1s512 MBJudgeable
Fashion ShowPlace models on an N by N grid (or upgrade existing ones) so every shared row or column has a plus and every shared diagonal has an x, maximizing style points.Hard9GreedyGraph+2No attempts yet5s512 MBJudgeable
Smallest unreachable subsequence sumFor each subarray, find the smallest non-negative integer that no subsequence sums to.Hard9Segment treeGreedy+1No attempts yet2s512 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
Arranging tilesGiven up to 14 convex tiles of equal height with cut corners, find the ordering and horizontal placement that minimizes the total frame width when packed side by side.Hard9Dynamic programmingGeometry+2No attempts yet1s1024 MBJudgeable
CratersFind the shortest single closed fence that surrounds all circles at distance 10 or more, given each crater's center and radius.Hard9GeometryDynamic programming+2No attempts yet2s512 MBJudgeable
Treasure MapOn a weighted undirected graph, gold decays each day at every mine; starting at mine 1 with forced moves, maximize total gold collected before stopping.Hard9GraphDynamic programming+2No attempts yet2s512 MBJudgeable
IntuidiffFind the minimum number of blocks, each a substring of the first string or a single new character, whose concatenation equals the second string.Hard9String matchingGreedy+2No attempts yet7s512 MBJudgeable
GCD SumFor each k from 1 to n, split a multiset of n numbers into k nonempty groups to maximize the sum of the groups' gcds. n is up to 500000 and each value up to 10^12.Hard9Number theoryGreedy+2No attempts yet2s1024 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
Journey from Petersburg to MoscowFind the minimum cost path from city 1 to city n where only the k most expensive edges of the path are paid for, or all edges if the path has k or fewer.Hard9GraphShortest path+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
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
Revenge of the Broken DoorAn adversary hides one edge under construction; the traveler learns about an edge only upon reaching its endpoint and must minimize the worst-case distance from S to T.Hard9GraphShortest path+2No attempts yet10s512 MBJudgeable
Conveyor BeltAfter each of Q delivery requests (a, b, p) is added, report the minimum time to finish all tasks, given plates arrive one per second and each plate carries one product.Hard9MathGreedy+2No attempts yet2s512 MBJudgeable
Pipe Fitter and the Fierce DogsIn a grid where every odd row and column holds a house, cover all houses with downhill chains, minimizing the cost of pipes through dog blocks, using at most K chains.Hard9Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
Maximal polygon brightnessGiven a convex polygon and a sequence of vertex deletions, compute after each deletion the largest total length of edges that a single external light point can illuminate.Hard9GeometryDynamic programming+2No attempts yet3s1024 MBJudgeable
Want to solve a problem?For given K and C, choose A > 0 to maximize the characters saved by writing K+A repeated K+A times instead of K repeated K times, minus C times A.Hard9String matchingMath+2No attempts yet1s128 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
Maximum Weight Matching in a General GraphGiven a weighted undirected graph, find a matching with maximum total edge weight.Hard9GraphGreedy+1No attempts yet2s512 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
Cloud computingChoose a set of orders and a set of computers to buy so every accepted order gets enough cores at its minimum clock rate, maximizing payments minus computer costs.Hard9Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
BuildingsCount the distinct houses formed by placing m walls of n by n colored squares around an m-gon, up to rotation, modulo 1e9+7.Hard9CombinatoricsMath+2No attempts yet2s512 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
ConstellationChoose a subset of up to 2e5 points maximizing total brightness so that from any chosen point all others fall in the first or third quadrant, with the nearest point in each occupied quadrant within Chebyshev distance L.Hard9MathGeometry+2No attempts yet1.5s512 MBJudgeable
Black ChainGiven a chain of n rings (up to 10^18), find the fewest rings to open so the resulting pieces can be combined into every weight from 1 to n.Hard9GreedyCombinatorics+2No attempts yet0.1s512 MBJudgeable
In Case of an Invasion, Please. . .Place people from n city nodes, with at most 10 capacity-limited shelters on a weighted road network, to minimize the latest arrival time at any shelter.Hard9Binary searchBFS+2No attempts yet3.5s512 MBJudgeable
EscalatorsChoose unordered paths on a tree and pay V[u] plus every other endpoint's complemented value to maximize total tokens.Hard9TreeDynamic programming+2No attempts yet3s512 MBJudgeable
Prime Tree - 2This output-only task asks for labels 1 to n on a tree's vertices so that as few edges as possible join two labels sharing a common divisor greater than 1.Hard9Number theoryTree+2No attempts yet10s512 MBJudgeable
Prime Tree - 4Relabel every vertex of each tree with 1 to n so the edges whose two labels share a divisor exceed 1 are as few as possible.Hard9GreedyNumber theory+2No attempts yet10s512 MBJudgeable
Prime Tree - 6Assign labels 1 to n to tree vertices so that edges joining two numbers with a shared factor are as few as possible.Hard9GraphGreedy+2No attempts yet10s512 MBJudgeable
Prime Tree - 7Relabel the vertices of each given tree with 1..n so that the number of edges whose endpoints share a common divisor above 1 is minimized, and submit the answer file.Hard9GreedyNumber theory+2No attempts yet10s512 MBJudgeable
Prime Tree - 9Relabel the vertices of given trees so that the number of edges whose endpoints share a common divisor greater than 1 is as small as possible.Hard9GraphGreedy+2No attempts yet10s512 MBJudgeable
Prime Tree - 10Relabel the vertices of a given tree with 1..n so that as few edges as possible join two labels sharing a common divisor; this is an output-only optimization task.Hard9Number theoryGreedy+2No attempts yet10s512 MBJudgeable
Lexicographically Smallest Sign SequenceFill a sign sequence of -1 and 1 with some fixed entries so that every range [Ai,Bi] has sum at least Ci, and output the lexicographically smallest valid sequence or Impossible.Hard9GreedyPrefix sum+2No attempts yet1s512 MBJudgeable
Monitoring Ski PathsA DAG has at most one outgoing edge per junction and unique landing points; pick the fewest junctions met by all m registered s-to-t to-basement paths.Hard9GraphGreedy+2No attempts yet2s512 MBJudgeable
Decorator CubeloverArrange n decorations on an n^3-cycle so each window of three labels is unique and the positional-value sum is minimal; report the nth digit of p-1.Hard9CombinatoricsMath+2No attempts yet1s512 MBJudgeable
Halves Not EqualDivide s dinars among n wives so that every pair's shares match the given two-person fair split rule and the total equals s.Hard9MathGreedy+1No attempts yet3s512 MBJudgeable
Removing Magical TilesGiven trapezoid tiles above the x-axis, find the minimum number of groups where each group is a set of tiles that pairwise overlap.Hard9GreedyGeometry+2No attempts yet2s512 MBJudgeable
Black CompanyAssign positive salaries minimizing their sum so that every edge and every two edges sharing an endpoint order their endpoints consistently with contribution degrees.Hard9GraphTopological sort+2No attempts yet5s512 MBJudgeable
Sweet and SourChoose which Candy Country players drink a potion that randomizes their sweetness and sourness, maximizing Candy's expected match points under all random player orders and event coin flips.Hard9ProbabilityCombinatorics+2No attempts yet1s512 MBJudgeable
Query and QueryEach query swaps two sequence values; after every swap, pair up the M left-pocket indices and M right-pocket indices to minimize the largest range maximum. Output that minimized maximum.Hard9Segment treeGreedy+2No attempts yet2s512 MBJudgeable
The Tallest and Widest CastleChoose which signposts serve as vertices of each floor so the castle has the most floors, then the largest total floor area, then the fewest signposts used, and report each signpost's floor number.Hard9GeometryDynamic programming+2No attempts yet1s512 MBJudgeable
Gosu 2Given a tournament on N players, find a transitive subtournament (chain) of size exactly 1 + floor(log2 N).Hard9Divide and conquerCombinatorics+2No attempts yet2s1024 MBJudgeable
Two TransportationsTwo programs, each holding one set of weighted edges, exchange at most 58000 bits to compute single-source shortest path distances from city 0 in the union graph.Hard9Shortest pathGraph+2No attempts yet10s256 MBJudgeable
AsceticismCount permutations of 1..N such that an optimal daily reading schedule (reading consecutive sentences within each day's time slots) finishes the sutra in exactly K days.Hard9Dynamic programmingCombinatorics+2No attempts yet0.6s256 MBJudgeable
CandiesFor each j, find the maximum sum of j non-adjacent values chosen from N candies in a row.Hard9Dynamic programmingGreedy+2No attempts yet5s512 MBJudgeable
ConstellationCount the ways to assign each unlabeled point to constellation A or B so that the two vertex sets can be drawn connected with mutually non-crossing segments.Hard9GeometryCombinatorics+2No attempts yet1s512 MBJudgeable
Graph and CyclesGiven a weighted complete graph on an odd number of vertices, partition all edges into edge-disjoint cycles and minimize the sum over each cycle of the max weight on consecutive edge pairs.Hard9GraphGreedy+2No attempts yet2s256 MBJudgeable
Easy WinAfter each edge insertion, find the maximum total weight of a subset of edges such that no non-empty edge-disjoint union of cycles in it has Nim value (xor of stone counts) equal to zero.Hard9Game theoryUnion-find+2No attempts yet1.5s512 MBJudgeable
Six WordsGiven a connected graph whose vertex i has potential i and edge i has weight i, find the total weight of a minimum spanning tree of the line graph of the line graph.Hard9GraphMinimum spanning tree+2No attempts yet2s512 MBJudgeable
Seven NeversFor every window of k consecutive elements in a permutation, compute the LIS length after deleting that window.Hard9Dynamic programmingSegment tree+2No attempts yet2s512 MBJudgeable
Um_nik's AlgorithmGiven an undirected bipartite graph with up to 2e6 vertices and edges per side, output a matching whose size is at least 0.95 times the maximum matching size, with heavy constant-factor optimization required.Hard9GraphGreedy+2No attempts yet4s512 MBJudgeable
Bracket Euler TourFind an Euler tour of an undirected graph whose vertex bracket labels, read in traversal order, form a correct bracket sequence, or report that none exists.Hard9GraphDFS+2No attempts yet2s512 MBJudgeable
Long GamePlayers alternately cut a strip of a permutation while every cut must leave at least one strip containing an inversion; decide the winner with optimal play.Hard9Game theoryGreedy+2No attempts yet1s512 MBJudgeable
Karaoke MeetupIn a weighted tree, some vertices are marked as houses. For each vertex compute the ratio of the nearest marked vertex distance to the farthest, and output the maximum ratio as a reduced fraction.Hard9TreeDFS+2No attempts yet8s512 MBJudgeable
CerealGiven a queue of cows each with a favorite and second-favorite cereal, report for every prefix removal how many cows still get a box.Hard9GreedySimulation+2No attempts yet1s512 MBJudgeable
Deja VuMaintain an array under point updates and answer queries asking for the earliest position d that ends an increasing subsequence of length 4 starting at or after l.Hard9Segment treeDynamic programming+2No attempts yet5s512 MBJudgeable
AdditionDesign a short string-rewriting script in a custom language that reads two binary numbers joined by + and rewrites them into their binary sum.Hard9String matchingSimulation+2No attempts yet1s256 MBJudgeable
Rikka with Tree GameOn a rooted tree where players alternately move a token to a child and the score is the final depth, repeatedly attach leaves and find the limit of f(k)/k, where f(k) is the fewest additions making the optimal score exactly k.Hard9Game theoryTree+2No attempts yet2s512 MBJudgeable
JokeGiven a text and up to ten patterns with per-letter erasure costs, delete letters so that no pattern occurs, minimizing total cost.Hard9String matchingDynamic programming+2No attempts yet1s512 MBJudgeable
EarthquakeEach route is usable only if all its bridges survive; pick an adaptive inspection order of bridges to minimize the expected number of inspections before deciding whether any route connects the two lands.Hard9ProbabilityDynamic programming+2No attempts yet1s512 MBJudgeable
Maximum FlowGiven two paths of n vertices each plus 2n+1 cross edges with huge capacities, find the max flow from (0,0) to (1,n).Hard9GraphShortest path+2No attempts yet2s512 MBJudgeable
Less Time, More ProfitChoose a subset of plants to build; a shop pays off only when every plant it needs is built. Minimize the maximum build time, then maximize profit within that time.Hard9Dynamic programmingGraph+2No attempts yet1s256 MBJudgeable
Navigation GameConstruct a 100x100 arrangement of the numbers 1 to 10000 that maximizes a navigation score, where jumps off the current row or column cost points.Hard9GreedyImplementation+2No attempts yet1s256 MBJudgeable
Wrong AnswerConstruct a cost matrix that makes a greedy two-character solution as far from optimal as possible, maximizing the ratio of its output to the true minimum.Hard9GreedyDynamic programming+2No attempts yet1s512 MBJudgeable
Delightful (Easy)Write a program of at most 100 commands for a ternary computer with 26 40-trit registers that computes the length of the longest non-decreasing prefix of the input in register X and leaves the answer in Y.Hard10ImplementationSimulation+2No attempts yet1s512 MBJudgeable