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,741 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Consecutive OnesPermute the columns of a 0-1 matrix so that the 1s in every row are consecutive, with column 0 fixed as the first column.Hard8GraphImplementation+2No attempts yet2s1024 MBJudgeable
The K-th NumberGiven an array of distinct integers and m range queries, return the k-th smallest value inside each queried subarray.Hard8Binary searchDivide and conquer+2No attempts yet1s256 MBJudgeable
Destroying the GraphFind the minimum cost to cover every arc of a directed graph by choosing, for each vertex, to delete its incoming or outgoing arcs.Hard8GraphMinimum spanning tree+2No attempts yet1s512 MBJudgeable
PlatformsGiven points with distinct x, find the longest chain of flights where each next point has larger x and no larger y, then report every point lying on some longest chain.Hard8Dynamic programmingSorting+2No attempts yet2s128 MBJudgeable
Box ArtGiven a bounding box and up to 2000 axis-aligned boxes, compute the volume of their union clipped to the bounding box.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
FrogGiven axis-aligned non-touching squares in the first quadrant and a jump reach d, find the largest x+y over squares reachable from the square at the origin.Hard8GraphBFS+2No attempts yet1s128 MBJudgeable
Lattice Points in the Union of CirclesCount integer lattice points inside the union of up to 10,000 circles, restricted to the coordinate box from -16383 to 16384.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
Missing LettersReconstruct a space-free corrupted string into words from a known vocabulary, choosing the highest-scoring word segmentation and breaking ties alphabetically.Hard8Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Jury CompromisePick exactly m candidates minimizing the prosecution minus defence imbalance, breaking ties by the largest total value, then by lexicographically smallest candidate list.Hard8Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
The RaceCount all overtakes among spaceships with given starting positions and speeds, then list the first 10000 in time order.Hard8SortingGreedy+2No attempts yet1s128 MBJudgeable
RectanglesGiven N axis-aligned rectangles, compute the area of their union.Hard8Segment treeSorting+1No attempts yet3s128 MBJudgeable
Empty TrianglesGiven N lines with no three concurrent, count the triangles whose interior is not crossed by any other line.Hard8GeometryCombinatorics+1No attempts yet2s512 MBJudgeable
Game RiggingGiven a set of players, a subset of friends, and known guaranteed match-up outcomes, decide whether a friend can be made to win the elimination tournament.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Rectangles Too!Find the longest chain of rectangles where each rectangle lies strictly below and to the left of the next one.Hard8SortingDynamic programming+1No attempts yet3s128 MBJudgeable
2D MatrixSplit N points into two disjoint non-empty sets, each centrally symmetric, and print every division's two centres in lexicographic order.Hard8Hash mapSorting+2No attempts yet1s64 MBJudgeable
Cover All Points with Three SquaresFind the smallest integer side length d so that three axis-aligned d×d squares can cover all N given points.Hard8Binary searchGreedy+2No attempts yet2s64 MBJudgeable
Cyclic Rotation CipherReconstruct the original lowercase string from its Burrows-Wheeler transform index i and last column R.Hard8StringSorting+1No attempts yet1s32 MBJudgeable
Painting PatternsCount grid cells painted black by up to N rectangle operations, each applying one of three periodic patterns under OR overlap.Hard8GeometryPrefix sum+2No attempts yet2s64 MBJudgeable
Union Area of TrianglesGiven right isosceles triangles with axis-parallel legs and hypotenuse of slope -1, compute the area of their union.Hard8GeometrySegment tree+2No attempts yet1s32 MBJudgeable
CakesSchedule dough preparation and single-oven baking for N cakes so that all finish as early as possible.Hard8GreedySorting+1No attempts yet1s32 MBJudgeable
Knowledge for the MassesEach row's racks keep their order and can shift left or right at cost 1 per rack; find the cheapest passage position and all positions attaining it.Hard8GreedyPrefix sum+2No attempts yet1s512 MBJudgeable
Closest PointFor each of N points, output the squared distance to the nearest other point.Hard8Divide and conquerSorting+2No attempts yet3s128 MBJudgeable
The PicnicGiven up to 99 points, find the largest convex polygon whose vertices are points and whose interior contains no other point.Hard8GeometryDynamic programming+2No attempts yet1s128 MBJudgeable
Bytean Road RaceGiven a planar south/east DAG from node 1 to node n, answer queries asking whether some monotone path passes through both given crossings.Hard8GraphDFS+2No attempts yet3s64 MBJudgeable
Evaluation of an ExpressionCount assignments of values to variables modulo a prime that make a given sparse polynomial expression zero, output modulo 30011.Hard8MathNumber theory+2No attempts yet1s128 MBJudgeable
Fruit ChickenA tree has shops at one end and houses at the other, separated by a single bridge edge; assign each open shop a distinct house minimizing the time until all couriers arrive, with no two couriers sharing a road at once.Hard8TreeBinary search+2No attempts yet3s128 MBJudgeable
MotorwaysAssign each of k motorway chords to one of two sides so that no two chords on the same side interleave, choosing the lexicographically smallest assignment.Hard8GraphSorting+1No attempts yet1s128 MBJudgeable
B-Smooth NumbersCount B-smooth numbers (no prime factor above B) in the interval [n, n+m], with n up to 2e9, m up to 1e8, and B up to 1e6.Hard8Number theorySegment tree+2No attempts yet1s128 MBJudgeable
The Labyrinth of WellsGiven a colored DAG where each room has three outgoing wells, find the minimum number of rooms in a DAG producing the same color sequence for every path.Hard8GraphDynamic programming+1No attempts yet3s128 MBJudgeable
Empty CuboidsGiven up to 5000 integer points, find the largest axis-aligned box anchored at the origin whose strict interior contains none of the points, and output its volume.Hard8SortingTwo pointers+2No attempts yet3s128 MBJudgeable
RocketsMatch the n red points to the n white points with non-crossing segments so the total Euclidean length is minimum, and report the matching.Hard8Dynamic programmingDivide and conquer+2No attempts yet1s128 MBJudgeable
AltarsFor each rectangle temple, decide whether a ray from its center can exit through the half-wall entrance and escape to infinity without touching any rectangle.Hard8GeometryImplementation+1No attempts yet1s128 MBJudgeable
Flat Broken LinesGiven n points, find the minimum number of flat broken lines (each moving right with segment slopes between -1 and 1) needed to cover all points.Hard8GreedySorting+1No attempts yet1s128 MBJudgeable
RooksPlace n non-attacking rooks, one per given axis-aligned rectangle, or report that no placement exists; output the lexicographically smallest placement.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Disk OptimizationGiven disk sectors holding files split across blocks, find the minimum copy/swap cost to pack files into consecutive sorted blocks.Hard8SortingGreedy+1No attempts yet1s128 MBJudgeable
WarehouseFind a crossroads minimizing the weighted sum of Chebyshev distances to n shops.Hard8GeometryBinary search+2No attempts yet1s128 MBJudgeable
SchoolsAssign a distinct number 1..n to each school within its allowed interval, minimizing the total weighted movement cost.Hard8GreedyDynamic programming+2No attempts yet3s128 MBJudgeable
Rock GardenEach boulder may keep or swap its two coordinates; choose swaps so the axis-aligned bounding rectangle perimeter is minimal, then minimize total swapped weight.Hard8GreedySorting+1No attempts yet1s128 MBJudgeable
Gas PipelinesAssign each of n extraction points to a distinct station southeast of it, minimizing the total Manhattan distance.Hard8GreedySorting+1No attempts yet1s128 MBJudgeable
Mirror TrapGiven a rectilinear polygon, pair up its corners by tracing 45-degree laser beams that reflect off mirror walls until each beam lands in another corner.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
ElephantsGiven elephant masses and two permutations, find the minimum total cost of swaps (cost = sum of the two masses) to convert the first order into the second.Hard8GreedyGraph+2No attempts yet3s512 MBJudgeable
BeadsSplit the bead string into blocks of size k (leftover dropped) and find the k that maximizes the count of distinct blocks, where a block and its reversal are the same.Hard8StringHash map+2No attempts yet1s128 MBJudgeable
Tree Rotations 2Given a binary tree with distinct leaf labels, rotations swap children at any node; find the minimum possible inversion count of the leaf sequence.Hard8Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
SquarksGiven the n(n-1)/2 pairwise sums of n distinct positive integers, find and list all sets of n integers whose pairwise sums match these values, in lexicographic order.Hard8SortingBrute force+2No attempts yet2s128 MBJudgeable
Warehouse StoreGiven daily deliveries a_i and daily orders b_i, choose which orders to accept so that the warehouse never runs out of stock, maximizing accepted orders.Hard8GreedyHeap+2No attempts yet1s128 MBJudgeable
Painting the WallGiven n axis-aligned rectangles, find the total area of the plane covered by at least n-1 of them.Hard8SortingSegment tree+2No attempts yet1s128 MBJudgeable
FosaGiven horizontal and vertical segments, find the largest axis-aligned square whose entire perimeter lies on those segments, or report that none exists.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
VacationFind a permutation of n attractions minimizing the total capped positional distance to k given rankings (k at most 3).Hard8Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Byteland Worldbeat PublishersGiven a sparse matrix of pair efficiencies (some described by row-wise column ranges), decide whether all maximum-size matchings have the same total weight.Hard8GraphGreedy+2No attempts yet5s128 MBJudgeable
TelescopeChoose an order for the coins and insertion times so that the paid viewing windows cover as many meteor intervals as possible.Hard8Dynamic programmingSorting+1No attempts yet5s128 MBJudgeable
Map 2Count integer starting points (a,b) such that each of the four diagonal quadrants around (a,b) contains at least one of n marked points.Hard8SortingPrefix sum+2No attempts yet1s128 MBJudgeable
Byteball MatchGiven partial results of a round-robin group, list every team that can still finish first once all remaining matches are played, under points and goal-difference tiebreaks.Hard8GraphBrute force+2No attempts yet2s512 MBJudgeable
PermutationFor a sequence a and each of m point updates, report whether a permutation p with p_i <= a_i for all i exists.Hard8GreedySegment tree+1No attempts yet1s128 MBJudgeable
CakesSum, over every triangle in an undirected graph, of the maximum vertex weight in that triangle.Hard8GraphSorting+1No attempts yet2s512 MBJudgeable
TurnsFor each starting position, find how many turns must be observed before the position on the map becomes uniquely determined.Hard8StringString matching+2No attempts yet1s128 MBJudgeable
Near 2Given n tree points and m apple points, find the minimum over all apples of the Manhattan distance to the nearest tree.Hard8Divide and conquerGeometry+2No attempts yet1s128 MBJudgeable
CloudsGiven disjoint simple polygons and a fixed wind direction, place a point so the number of polygons that cross the vertical ray above it at some time is maximized.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
Sum of PolygonsAdd two convex polygons by Minkowski sum and print twice the area of the resulting polygon.Hard8GeometryTwo pointers+2No attempts yet1s128 MBJudgeable
TetrisEach block is a horizontal strip 1 unit tall; given its length and left offset, choose the drop order that minimizes the final stack height. Output that minimum.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
SupercomputerGiven jobs with arrival times and required processor-time, schedule them with preemption on a single 100% processor to minimize the sum of completion-minus-arrival times.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
ScreensaverA point moves diagonally and reflects off a set of disjoint horizontal and vertical wall segments; report its position after t seconds.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
Power of the ArrayGiven an array and t range queries, compute for each subarray the sum over values s of s times the square of s's frequency in the range.Hard8ArrayPrefix sum+2No attempts yet3s128 MBJudgeable
Creative AccountingGiven daily balances, pick a contiguous period whose sum modulo m (with nonnegative remainder) is as large as possible, and report that maximum remainder.Hard8Prefix sumMath+2No attempts yet2s128 MBJudgeable
Express DeliveryGiven a depot and clients with distinct x and y coordinates, find the fewest monotone (shortest-path) routes from the depot that cover all clients.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Spy SatellitesGiven a terrain polyline with some marked points, place satellites on the line y=H so their visibility segments cover all marked points, minimizing the count.Hard8GeometryGreedy+2No attempts yet1s128 MBJudgeable
BajtoriSelect a subset of squares to maximize the sum of the squared red total and squared green total.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
Fence In Godzilla!The task is to find the smallest nonzero area among triangles with vertices from n points.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
Untamed TreeThe task is to output for each leaf label the compressed subtree of its leaves and branching ancestors in preorder.Hard8TreeSorting+2No attempts yet1s128 MBJudgeable
VirusesGiven up to 24 virus sources with distinct daily hours, determine how many cells each one ends up occupying on an n by n board.Hard8GeometryBFS+2No attempts yet1s128 MBJudgeable
The Company ChoirGiven a rooted tree where each node has a pitch and a distinct ability score, answer queries that ask for the k highest-ability subordinates of a node whose pitch lies in a range [a,b].Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
MapsGiven up to a million arbitrarily rotated rectangles, find the number of edges of their common intersection polygon.Hard8GeometryImplementation+2No attempts yet1s128 MBJudgeable
BeetlesGiven n segments, find the smallest axis-aligned square that contains at least k of them entirely, with boundary counted as inside.Hard8Binary searchGeometry+2No attempts yet1s128 MBJudgeable
City WallDecide whether every segment of a polygonal city wall is visible from an interior church point without occlusion by other segments.Hard8GeometrySortingNo attempts yet1s512 MBJudgeable
ConductorsConductors with different speeds start at their own compartments and take the smallest unchecked one when free, and the goal is the last compartment of each.Hard8Binary searchMath+1No attempts yet1s128 MBJudgeable
DrzewaFor each node of a labeled rooted tree, find the leaf below it whose downward label string is lexicographically largest, breaking ties by smaller leaf number.Hard8TreeGreedy+2No attempts yet1s128 MBJudgeable
TrójmiastoPick three of up to one million points in the plane so the sum of their three pairwise distances is smallest.Hard8GeometryDivide and conquer+1No attempts yet10s128 MBJudgeable
The ChampionshipPair as many employees as possible so each team holds two people with neither managing the other.Hard8GreedyTree+2No attempts yet1s128 MBJudgeable
Contour MapGiven up to 20000 non-crossing convex orthogonal polygons, compute the maximum nesting depth where the outermost level is 1.Hard8GeometrySorting+2No attempts yet3s128 MBJudgeable
Sports Channel GSKGiven match start times, durations, and travel times, find the largest set of matches in which no reporter can cover any two.Hard8GraphSortingNo attempts yet2s128 MBJudgeable
Block CompactionRepeatedly drop axis-aligned rectangles down and then left until none moves, and report the width and height of the final bounding box.Hard8SimulationGeometry+2No attempts yet1s128 MBJudgeable
InstallationsOrder jobs with given service times and deadlines to minimize the sum of the two largest lateness penalties.Hard8Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Opening a RestaurantCount the grid intersections that beat every existing restaurant in distance to apartment A or to apartment B.Hard8GeometrySorting+1No attempts yet5s128 MBJudgeable
KTX Train DepotFind the smallest number of straight tracks on which trains entering from either end before midnight can all leave toward their fixed ends on time.Hard8GreedySorting+1No attempts yet5s128 MBJudgeable
A Lazy WorkerJobs have processing times with arrival times and deadlines, and the worker picks among available jobs without idling to minimize total executed work.Hard8Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
CastlesFind the minimum Manhattan distance between any west-bank castle and any east-bank castle from two monotone chains.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
StainsTaeyeon covers integer points off the x-axis with diamonds centered on the x-axis and minimizes the sum of their areas.Hard8Dynamic programmingGeometry+2No attempts yet1s128 MBJudgeable
Tree LabelingThe program counts labelings of a tree with up to 1000 vertices that preserve each label's neighbor label set.Hard8TreeCombinatorics+1No attempts yet1s128 MBJudgeable
BooksortGiven a permutation of 1 to n with n at most 15, find the fewest adjacent block swaps that sort it, reporting 5 or more when the minimum exceeds 4.Hard8BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
RingworldGiven n circular arcs on a ring of m cities, decide whether each arc can take a distinct city inside it.Hard8GreedyIntervals+1No attempts yet2s128 MBJudgeable
The Avaricious ISPChoose two disjoint disks over weighted points to maximize the product of the covered weight sums.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
Janeway's JourneyFind the single straight line that hits the greatest number of disjoint circular asteroids in the plane.Hard8GeometrySorting+1No attempts yet40s128 MBJudgeable
Inverting HuffmanGiven code lengths that some Huffman run can produce, find the smallest total character count that allows those lengths.Hard8GreedyTree+1No attempts yet1s128 MBJudgeable
Longest ChainFind the longest chain of triples with all three coordinates strictly increasing among up to 300,000 points per dataset.Hard8Divide and conquerDynamic programming+2No attempts yet10s128 MBJudgeable
TV TransmittersSome rooftops hold transmitters, buildings block their straight rays, and the total length of ground that sees one transmitter is printed as a reduced fraction.Hard8GeometryIntervals+1No attempts yet1s128 MBJudgeable
Increasing Shortest PathFind the cheapest A to B path using at most C edges whose weights strictly increase.Hard8Dynamic programmingShortest path+2No attempts yet15s256 MBJudgeable
Highway of the FutureGiven each car entry time and speed, compute the largest number of cars at the same spot at the same time on a 100-unit highway.Hard8GeometrySorting+2No attempts yet10s128 MBJudgeable
2D Solar SystemCircles tangent to one straight line glide with constant velocity, and the program reports when the first two touch.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
Wedding HallFind the largest L-shaped hall of three equal squares that fits inside a walled garden without enclosing any tree.Hard8GeometryBinary search+2No attempts yet1s128 MBJudgeable
FerriesCaptains at each island reassign fixed ferry fares among destinations to maximize the cheapest fare from island 1 to island N.Hard8Shortest pathGreedy+2No attempts yet2s512 MBJudgeable
Rent-A-PixelCompute the smallest row- and column-convex block set containing the given blocks and print its outline corners clockwise.Hard8GeometryIntervals+1No attempts yet3s128 MBJudgeable