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 results2,732 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
IvoizationSum the Ivoization values of every K by K submatrix, where Ivoization is the pairwise absolute-difference sum of all K^2 entries, modulo 10007.Hard8SortingPrefix sum+2No attempts yet1.5s128 MBJudgeable
ZvonimirFind the minimum number of operations (type one letter, or copy a contiguous block of already typed text and append it) to produce string X.Hard8Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Median filterGiven a piecewise-linear integer signal by its corner points, output the corners of its median-filtered signal of width 2d+1.Hard8MathImplementation+2No attempts yet1s128 MBJudgeable
Triangle regionsGiven N points with no three collinear, count for each v how many triangles formed by three points contain exactly v other points strictly inside.Hard8GeometryCombinatorics+2No attempts yet2s512 MBJudgeable
Reconstruct the progressionsGiven K listed values in [A,B], find the smallest set of positive step sizes whose multiples in [A,B] hit exactly those values.Hard8Number theoryMath+2No attempts yet2s128 MBJudgeable
I Teach SweepingGiven segments in the first quadrant, find a line through the origin that intersects the most segments and report that count.Hard8GeometrySorting+1No attempts yet2s512 MBJudgeable
Cutting edges one at a timeDelete edges of a weighted undirected graph one by one so that the total weight removed before s and t get disconnected is as large as possible.Hard8GraphMinimum spanning tree+2No attempts yet2s512 MBJudgeable
Sorting Array (Large)Given a permutation of 1..N and a limit P, partition it into contiguous blocks, sort each, then reorder at most P blocks by swaps; maximize the number of blocks.Hard8GreedySorting+2No attempts yet30s512 MBJudgeable
Stretch Rope (Large)Given N rubber bands with stretch ranges [A_i, B_i] and prices, pick a subset whose summed range contains L at minimum total cost within budget M.Hard8Dynamic programmingGreedy+2No attempts yet30s512 MBJudgeable
Rides 1Each day one child grows by 1 cm; after each growth, count how many of Q given pairs (i,j) can ride their specified ride, where the pair's combined height meets the ride's limit.Hard8SortingBinary search+2No attempts yet2s256 MBJudgeable
Why Did the Cow Cross the Road 11Given a permutation of breeds on each side of a road, connect pairs whose breed numbers differ by at most 4 using non-crossing edges, maximizing the count.Hard8Dynamic programmingDivide and conquer+2No attempts yet2s512 MBJudgeable
Sequence and Queries 18Maintain an array under point updates and answer range queries counting elements greater than k.Hard8Segment treeSorting+2No attempts yet2s512 MBJudgeable
Pieces of ParenthesesGiven n pieces of parentheses, choose and order some pieces to build the longest balanced parenthesis string.Hard8Dynamic programmingGreedy+1No attempts yet2s512 MBJudgeable
Blazing New TrailsChoose a spanning tree of a graph whose edges each join a marked or unmarked vertex, with exactly w marked-unmarked edges, minimizing total cost.Hard8Minimum spanning treeGraph+2No attempts yet2s512 MBJudgeable
Taking Balls from Three BasketsCount triples of baskets (chosen from N) where the second player wins the subtraction game on three piles with move limit M.Hard8Game theoryCombinatorics+2No attempts yet2s256 MBJudgeable
Study GroupGiven students with skill values and sets of known algorithms, pick a group whose skill range is at most D to maximize (union size minus intersection size) times group size.Hard8Bit manipulationSliding window+2No attempts yet2s128 MBJudgeable
Heaven's KitchenChoose match order and winners so a knockout tournament maximizes summed floor((Ci+Cj)/|Pi-Pj|), then output the unique bracket fixed by the stated tie-breaking rules.Hard8Minimum spanning treeUnion-find+2No attempts yet1s128 MBJudgeable
Weather ForecastMaintain N snow depths under point increments and decrements, then answer range-count queries (depth between L and R) and T-th largest value queries online.Hard8Segment treeBinary search+2No attempts yet2s128 MBJudgeable
Toppling Dominoes (Small)Sort the dominoes by position and find the minimum number of manual pushes so that chains topple every domino.Hard8Dynamic programmingSorting+1No attempts yet1s512 MBJudgeable
Dominoes (Large)Find the fewest pushes (each a domino plus a direction) needed to topple every domino through chain reactions.Hard8GreedySorting+2No attempts yet1s512 MBJudgeable
Segment Friends (Large)Given N segments on a line, build the intersection graph and answer Q shortest-path queries between segment pairs, or report -1.Hard8GraphBFS+2No attempts yet2s256 MBJudgeable
Over Fitting (Large)Given N labeled points in the plane, find a line whose positive half-plane contains only LOVELYZ points and maximizes how many LOVELYZ points it captures.Hard8GeometrySorting+2No attempts yet3s512 MBJudgeable
Space ExplorationGiven N segment obstacles in the first quadrant and M rays from the origin, count how many segments no ray intersects, including exact endpoint touches.Hard8GeometrySorting+1No attempts yet2s256 MBJudgeable
Money for NothingPick one producer and one consumer to maximize (q-p)(e-d) over pairs where q>p and e>d, with up to 500000 of each.Hard8Divide and conquerGeometry+2No attempts yet5s512 MBJudgeable
Visual Python++Match n top-left corners to n bottom-right corners so the rectangles form properly nested or disjoint blocks, or report a syntax error.Hard8SortingStack+2No attempts yet5s512 MBJudgeable
Electronic devicesAssign distinct power supplies to components so every device i gets at least Y_i working components, with a supply's chosen power matching the component's exact requirement, and output the lexicographically smallest connection list.Hard8GreedySorting+2No attempts yet1s512 MBJudgeable
Strange Solutions at Jeong LabGiven a growing set of (A,B) pairs, decide each day whether the new pair is dominated by or lies on the segment between two existing points.Hard8GeometryBinary search+2No attempts yet1s512 MBJudgeable
Leftmost SegmentGiven n segments spanning two horizontal lines, answer m queries asking which segment meets a horizontal line at the leftmost point, breaking ties by the upper endpoint.Hard8SortingBinary search+2No attempts yet1s512 MBJudgeable
Map LabelingPlace disjoint unit-height labels on a line above given points and count the minimum number of connectors that cannot run straight down to their own label.Hard8Dynamic programmingSorting+2No attempts yet1s512 MBJudgeable
Card Operation (Large)Order a set of arithmetic cards applied to a starting value to maximize the final rational result, printed as a reduced fraction.Hard8GreedySorting+2No attempts yet5s512 MBJudgeable
Cups and MarblesAfter m range-sort spells (ascending or descending) on a permutation, report the marble in the middle cup.Hard8Binary searchSorting+2No attempts yet4s256 MBJudgeable
Standing in lineGiven a partial order of comparisons between students in line, recover a card permutation consistent with all pairs or print -1.Hard8Topological sortSorting+2No attempts yet2s512 MBJudgeable
Permutation SwapsFor each k from 1 to n-1, count permutations reachable from A in exactly k swaps, modulo 1e9+7.Hard8CombinatoricsDynamic programming+1No attempts yet2s512 MBJudgeable
Rectilinear RegionsGiven two unbounded staircase polylines L and U, count the closed regions they enclose with L below and U above, and sum their areas.Hard8GeometryTwo pointers+2No attempts yet0.5s512 MBJudgeable
Sheets and PaintballsGiven axis-aligned rectangles and colored points, count the distinct color labels that reach each rectangle along the vertical stacking order.Hard8SortingSegment tree+2No attempts yet2s512 MBJudgeable
Compass Card SalesRepeatedly remove the remaining card with the smallest uniqueness score, breaking ties by larger ID, and print the removal order.Hard8SimulationSorting+2No attempts yet6s512 MBJudgeable
HubtownAssign citizens to one of their two angularly nearest train rays, respecting each ray's capacity, and maximize the number assigned.Hard8GreedySorting+2No attempts yet10s512 MBJudgeable
Daunting deviceApply N range-recolor operations whose endpoints depend on the current count of a query color, then report the highest cell frequency.Hard8Segment treeImplementation+2No attempts yet1s1024 MBJudgeable
The Uncertainty of PoliticsEach hearing has a start time and a uniform integer length in [a,b]; pick hearings to attend fully so the expected count is maximized.Hard8Dynamic programmingProbability+2No attempts yet2s512 MBJudgeable
Avoiding AirportsFind a flight itinerary from country 1 to country n minimizing the sum of squared waiting times at airports.Hard8GraphShortest path+2No attempts yet3s512 MBJudgeable
Graphics DesignSimulate discrete events where students claim cameras, camcorders, and computers for subprojects in priority order and report each student's finish time.Hard8SimulationHeap+2No attempts yet4s512 MBJudgeable
Power plantsColor n points with two colors so the closest same-color pair is as far apart as possible, and output that squared distance plus the lexicographically smallest optimal coloring.Hard8GeometryDivide and conquer+2No attempts yet3s1024 MBJudgeable
Corporate life after a hostile takeoverGiven two rooted trees on the same n employees, count for each employee how many others are descendants in both trees.Hard8TreeDFS+2No attempts yet0.5s1024 MBJudgeable
Posters on the wallGiven up to 50000 non-overlapping axis-aligned rectangles, answer online queries that ask for the total rectangle area inside a query rectangle, with coordinates decoded from the previous answer.Hard8Segment treeSorting+2No attempts yet2s1024 MBJudgeable
RacetrackGiven ordered lap times and lap counts and the rule that passes happen only at the finish line, compute when each runner finishes the race.Hard8SimulationImplementation+2No attempts yet2s512 MBJudgeable
WolfGiven your n-card pile and the opponent's remaining 51... wait 52-n cards, decide whether reordering both piles can make you win the next turn.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Buffalo BarricadesFor each settler arriving in order, count the buffalos inside the region bounded by rivers and fences whose upper right corner is the settler's post.Hard8SortingPrefix sum+2No attempts yet5s512 MBJudgeable
Archery TournamentMaintain a dynamic set of non-overlapping circles tangent to the ground, support insertions and point queries that remove the hit circle, and report which circle each arrow hits.Hard8GeometryBinary search+2No attempts yet3s512 MBJudgeable
The Great WallEach design picks two length-r intervals whose overlap height adds extra cost; find the k-th smallest total wall height over all interval pairs.Hard8Binary searchPrefix sum+2No attempts yet3s512 MBJudgeable
Fence InvasionCount how many distinct convex polygons can be formed as the convex hull of some subset of at least 3 of the given points, modulo 1e9+7.Hard8GeometryCombinatorics+2No attempts yet5s512 MBJudgeable
The Infosci Pirate CrewGiven N islands with coordinates, treasure values, and safe hardness, choose a monotone northeast path and a hardness interval to maximize collected value minus interval length.Hard8Dynamic programmingSorting+2No attempts yet1s512 MBJudgeable
Making the Perimeter of the Convex Hull ShortestGiven n points, find the largest decrease in convex hull perimeter achievable by removing exactly two of the points.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Starting a Scenic Railroad ServiceFor n travel segments, compute the minimum seats needed under arbitrary online seat choices and under optimal offline assignment.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Border WallGiven two colored point sets and a width d, find the minimum number of points to delete so that a strip of width d separates the remaining points by color.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Homotopic PathsDecide whether two polygonal paths from s to t in a plane with point obstacles are homotopic, that is, deformable into each other without crossing any tree.Hard8GeometryImplementation+2No attempts yet2s512 MBJudgeable
Balloon DistributionRank all ratios P_i/j from largest to smallest and count, for each contestant, how many ratios fall at rank N or above, with ties at the cutoff all counted.Hard8Binary searchSorting+2No attempts yet6s512 MBJudgeable
Convex QuadrilateralGiven n points, find the smallest-area convex quadrilateral whose four sides each pass through at least two of the points and that contains every point.Hard8GeometryGreedy+2No attempts yet9s512 MBJudgeable
Christmas TreeGiven the final colours on a tree after M path-painting updates with distinct colours, reconstruct the unique valid update order and the endpoints of each colour's shortest covering path.Hard8TreeDFS+2No attempts yet0.7s512 MBJudgeable
Binary TransformationsGiven starting bits, target bits, and per-bit costs, flipping a bit i costs the sum of costs of all bits equal to 1 after the flip; find the minimum total price to reach the target.Hard8Dynamic programmingGreedy+2No attempts yet1s256 MBJudgeable
Blowing CandlesGiven up to 200,000 points inside a disk, find the minimum width of a strip that can cover all of them.Hard8GeometryBrute force+2No attempts yet4s512 MBJudgeable
Vera and the BanquetGiven a circular string S, count the number of distinct substrings appearing in any contiguous block read in either direction around the circle.Hard8StringString matching+2No attempts yet2s512 MBJudgeable
Vera and Canada DayAfter each laser is added, choose one of four L-shaped firing orientations per laser so that the total awe from lasers hit by beams is maximized.Hard8Dynamic programmingGraph+2No attempts yet2s512 MBJudgeable
Computer ScienceFind the smallest L such that for each a_i we can pick an interval [x_i, x_i+L] covering a_i and containing at least K of the given integers.Hard8Binary searchSorting+2No attempts yet2s512 MBJudgeable
Standing Out from the HerdFor each name in the herd, count its substrings that occur in no other name.Hard8StringString matching+2No attempts yet2s512 MBJudgeable
A Pie for a PieEach cow alternately returns a pie whose own tastiness is within D above the received pie; for each of Bessie's pies, find the fewest pies in an exchange ending with a zero-valued pie.Hard8GraphBFS+2No attempts yet2s512 MBJudgeable
Arranging game levelsCount rooted tree arrangements of N levels where each level's clear score S_i and the cumulative score K_i along the root-to-level path are given, and children must have larger S than parents.Hard8TreeCombinatorics+2No attempts yet1s256 MBJudgeable
Escape from HellChoose an order to use N energy drinks so the climber reaches length L on the earliest day without sinners catching up at night.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Share the Ruins PreservationSplit points by a vertical line that avoids all points, build the minimum-area enclosing convex hull of each side, and minimize the total area.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Frogs 2Assign one frog to each pad so that every frog sits on a preferred pad and each log joins two frogs with equal interest in the log's topic.Hard8GraphBacktracking+2No attempts yet1s256 MBJudgeable
Lifeguards (Platinum)Fire exactly K of N lifeguard shifts to maximize the total time covered by at least one remaining shift.Hard8Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Ascending PhotoGiven a sequence of n heights, find the minimum number of cuts so the pieces can be reordered into a nondecreasing sequence.Hard8GreedySorting+2No attempts yet3s512 MBJudgeable
PetrolGiven a weighted graph with some marked stations, answer queries asking whether a tanker of capacity b can travel from station x to station y, refuelling only at stations.Hard8GraphShortest path+2No attempts yet2s512 MBJudgeable
The StagingGiven n gangsters each aiming at a distinct target, count survivors after each of q updates to the shooting time of one gangster.Hard8GraphDynamic programming+2No attempts yet2s512 MBJudgeable
Spacetime StoneAssign Taekhee's cards to rounds and pick a strength-joker round so that Namgyu's best-case score (over his joker round) is minimized, ties broken lexicographically.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Catch the PlaneChoose an adaptive strategy of buses to maximize the probability of reaching station 1 by time k, where each bus runs independently with a known probability.Hard8Dynamic programmingProbability+2No attempts yet10s1024 MBJudgeable
Single Cut of FailureWires cross a rectangle between boundary sides; find the fewest straight cuts connecting different sides that cross every wire, and output the lexicographically smallest such cut.Hard8GeometrySorting+2No attempts yet6s1024 MBJudgeable
Wireless Instead of FiberGiven a connected multigraph, output a spanning tree minimizing the number of vertices whose degree differs from the original, following a prescribed construction procedure.Hard8GraphGreedy+2No attempts yet2s1024 MBJudgeable
SlingshotFor each of M queries (a, b), find the minimum time to move manure from a to b using the tractor (cost equals distance) plus at most one slingshot that flies from x to y in time t.Hard8Divide and conquerSorting+2No attempts yet2s512 MBJudgeable
Snow BootsFor each of B boots with limits on snow depth and step length, decide whether the farmer can walk from tile 1 to tile N, landing only on tiles whose snow is shallow enough.Hard8Binary searchSorting+2No attempts yet2s512 MBJudgeable
Out of SortsGiven an array, simulate a hybrid of quicksort and bubble sort that repeatedly bubbles until partition points appear, then splits, and report the total work counter.Hard8SortingSimulation+2No attempts yet2s512 MBJudgeable
DisruptionGiven a tree and extra weighted edges, for each tree edge report the minimum weight of a non-tree edge whose endpoints lie in different components after removing it.Hard8TreeDFS+2No attempts yet2s512 MBJudgeable
Out of SortsGiven an array, count how many times the outer loop of a forward-backward bubble sort variant runs before the array becomes sorted.Hard8SortingMath+2No attempts yet2s512 MBJudgeable
RecipeBuy ingredients on some days, hold each in the fridge until a later day, cook it there if freshness stays at least L_i, and maximize the total of F_i minus elapsed days times C_j; print Impossible if day N can't be a cooking day.Hard8Dynamic programmingGreedy+2No attempts yet1s1024 MBJudgeable
ParticlesGiven firing times and speeds of N particles from each of two facing accelerators, report the first K collisions between opposite kinds in chronological order.Hard8SortingTwo pointers+2No attempts yet2s512 MBJudgeable
Travelling Businessmen ProblemGiven a connected undirected graph with mutable node values, answer queries asking the minimum possible difference between the values of two walkers' end cities.Hard8GraphBFS+2No attempts yet2s512 MBJudgeable
Make a ForestGiven N weighted tuples (u,v,w) with distinct weights, build a forest realizing each tuple as a parent-child edge so that every internal node's parent edge is smaller than all its child edges, each node has at most M children, and the number of trees is minimized. Output that minimum tree count.Hard8GraphUnion-find+2No attempts yet2s512 MBJudgeable
XEN 3166Assign each country a length-K subsequence starting with its first letter so that code order matches name lexicographic order, or report impossible.Hard8GreedyString+1No attempts yet2s512 MBJudgeable
PermutationGiven a permutation P and queries K, find the exponent T such that P^T is the K-th smallest among P^1 through P^(M-1) in lexicographic order.Hard8MathCombinatorics+2No attempts yet2s512 MBJudgeable
CitationsOrder the reading of a citation tree rooted at book 1 so that the sum of all book return times is minimized.Hard8TreeGreedy+2No attempts yet1s1024 MBJudgeable
Mysterious ArrayCount permutations of 1..N consistent with Q range-minimum constraints, modulo 1e9+7, with contradictions giving 0.Hard8CombinatoricsSorting+2No attempts yet2s512 MBJudgeable
Pineapple PizzaGiven n points and a center Q, decide whether k rays from Q can split the plane so every sector holds exactly n/k points, with no point on a ray.Hard8GeometrySorting+2No attempts yet1s256 MBJudgeable
Matrix MultiplicationFor each prefix of n matrices, decide whether some multiplication order is valid, and if so report the largest possible area of the final product.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Harmonious MatrixGiven a 2xN or 3xN matrix of distinct integers, find the largest subset of columns whose orderings within each row are identical, and report its column count.Hard8SortingHash map+2No attempts yet5s768 MBJudgeable
Magnet ToyGiven a simple graph, decide whether its vertices can be removed one by one so that each removed vertex's remaining neighbors form a clique, and output the order if possible.Hard8GraphImplementation+2No attempts yet1.5s256 MBJudgeable
ShootingsGiven non-overlapping axis-aligned rectangles and shots that are vertical or 45-degree half-lines, compute for each shot the squared total length of its intersection with all rectangles.Hard8GeometrySorting+2No attempts yet1s512 MBJudgeable
Zoning HousesFor each query range of houses, find the side length of the smallest axis-aligned square covering all points in the range, with the option to drop one point.Hard8Segment treeDivide and conquer+2No attempts yet2s512 MBJudgeable
Монгол ардын үлгэрChoose a subset whose size is at most the total weight of the remaining stones, maximizing the value of that chosen subset.Hard8Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Fair ShareGiven n weighted points around the origin, choose a line through the origin that splits them into two half-planes, minimizing the absolute difference of the two half-plane weight sums.Hard8GeometrySorting+2No attempts yet5s512 MBJudgeable
Grievous Loss of DataGiven the clash graph of N interval lectures, find the minimum number of halls, which equals the chromatic number guaranteed realizable by intervals.Hard8GraphIntervals+2No attempts yet6s512 MBJudgeable
Injecting DNAFor every suffix of a string, compute its toxicity from the number of out-of-order suffix pairs, then output the length of the suffix with the largest effectiveness.Hard8StringSorting+2No attempts yet2s512 MBJudgeable