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
Caravan RobbersGiven nested-free intervals, place equal-length disjoint subintervals inside them and output the maximum common length as an exact fraction.Hard8Binary searchGreedy+2No attempts yet1s128 MBJudgeable
Kingdom ReunionDecide whether three lists of points form simple polygons and whether the first two are disjoint with union equal to the third.Hard8GeometryImplementation+1No attempts yet1s128 MBJudgeable
KunaiNinjas on a huge grid throw kunai in four directions; kunai vanish when two arrive at the same point at the same instant, so count the squares any surviving kunai passes through.Hard8GeometryHash map+2No attempts yet3s256 MBJudgeable
SignalGiven n points with no three collinear and no four concyclic, average over all triples the number of points inside or on the circle through the triple.Hard8GeometryCombinatorics+2No attempts yet2s128 MBJudgeable
Recovering the Common Ratio of a Geometric SequenceGiven a shuffled, partially deleted integer geometric sequence, find the common ratio with the largest absolute value (positive on ties), or 0 if none exists.Hard8MathNumber theory+2No attempts yet1s128 MBJudgeable
New HorizonsGiven a spherical planet, a throne position and height, decide which object tops rise above Yertle's horizon and print their names sorted alphabetically.Hard8GeometryMath+2No attempts yet1s128 MBJudgeable
Takeover WarsTwo firms alternate merging their own subsidiaries or absorbing a strictly smaller rival one; decide who wins the takeover war with optimal play.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Machine WorksBuy and resell at most one machine at a time over D days, each machine usable from its sale day, to maximize final cash.Hard8Dynamic programmingSorting+2No attempts yet2s128 MBJudgeable
Brownie Points IIGiven points in the plane, Stan picks a vertical line and Ollie a horizontal line through it; find Stan's guaranteed score and the distinct best Ollie scores.Hard8SortingPrefix sum+2No attempts yet1s128 MBJudgeable
Advanced Causal Measurements (ACM)Given n observed events and m causes, place the m causes so all events are causally reachable and the earliest cause time is maximized.Hard8Binary searchGreedy+2No attempts yet1s128 MBJudgeable
A Brief GerrymanderChoose A avenue boundaries including 1 and 100 to maximize the number of vertical strips that contain at least one marked neighborhood, given fixed street boundaries.Hard8Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Intellectual PropertyGiven two code bases as raw strings, find the k longest maximal substrings of the JCN base that also occur in the TDP base, with exact positions and lengths.Hard8String matchingSorting+2No attempts yet1s128 MBJudgeable
CatenymsFind the lexicographically smallest ordering of dictionary words where each word's last letter equals the next word's first letter, using every word once.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
A Classic Myth: Flatland SuperheroFor each swarm of points, compute the minimum area of a parallelogram that contains all of them, using the rotating calipers method on the convex hull.Hard8GeometryDivide and conquer+2No attempts yet1s128 MBJudgeable
Collateral CleanupGiven a triangulated rectangle, find the lexicographically smallest order to lower triangles straight down so no placed piece blocks a later one.Hard8GeometryTopological sort+2No attempts yet3s128 MBJudgeable
Optimal Strategy for the ICPCGiven up to 15 problem solving times, schedule them on three parallel workers within 300 minutes to maximize solved count, then minimize total completion-time penalty, with lexicographically smallest order.Hard8Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Doors and PenguinsGiven axis-parallel rectangles labeled Doors or Penguins, decide whether one straight line avoiding all rectangles can separate the two groups.Hard8GeometryDivide and conquer+2No attempts yet1s128 MBJudgeable
Line of SightGiven a house segment, a property-line segment, and horizontal obstruction segments, find the length of the longest continuous stretch of the property line from which the whole house is visible.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
Sloppy SortGiven a possibly inconsistent comparison function as an n by n table, find the permutation of 0 to n-1 with the fewest inversions, breaking ties by the lexicographically smallest one.Hard8Dynamic programmingBit manipulation+2No attempts yet3s128 MBJudgeable
SoccerGiven a partial soccer schedule with at most 12 unplayed matches, find the best and worst final rank each team can still achieve. Ties share the same position.Hard8Brute forceImplementation+2No attempts yet2s128 MBJudgeable
Tighten Up!Given a polygonal string between two holes and a set of pins, compute the length of the taut chain that wraps around the pins when pulled tight.Hard8GeometryGreedy+2No attempts yet1s128 MBJudgeable
Dr. Podboq, or: How We Became AsymmetricRead a binary tree of cells, define each cell's left-right similarity by shared subtree shapes up to child swaps, then reorder children by asymmetry and print the normalized tree.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
Water TankSimulate water filling a 100 cm tank divided by partition boards of distinct heights, with faucets pouring into regions, and report the exact water level at given positions and times as integers or reduced fractions.Hard8SimulationSorting+2No attempts yet1s128 MBJudgeable
StatisticiansGiven a grid of counts, take the median of the mean densities over all axis-aligned subrectangles whose area lies in [a,b].Hard8Prefix sumBinary search+1No attempts yet1s128 MBJudgeable
DinnerGiven a complete graph on n vertices with edge years (default 2008), find the smallest year Y such that vertices split into two parts of size at most 2n/3, one with all edges before Y, the other with all edges at or after Y.Hard8GraphSorting+2No attempts yet1s128 MBJudgeable
Lecture ScreensGiven a simple polygon hall, a viewpoint, and directed screens, compute the total fraction of shared content visible across all screens after occlusion by the walls.Hard8GeometryImplementation+2No attempts yet1s128 MBJudgeable
Circle of FriendsFor each queried node in an undirected graph, find the largest k-core containing it, then output the largest connected component of that core with its members sorted.Hard8GraphImplementation+2No attempts yet1s128 MBJudgeable
The Best TeamsGiven N players each with an age and distinct skill, and forbidden pairs that are adjacent in skill order, answer T queries each asking the maximum sum of at most K players with age at most A.Hard8Dynamic programmingSorting+2No attempts yet2s128 MBJudgeable
Prefix MediansGiven the prefix medians B of an unknown permutation of 1 to 2N-1, reconstruct the lexicographically smallest permutation that produces exactly those medians.Hard8GreedyImplementation+2No attempts yet1s128 MBJudgeable
CipherFind the a x b subarray that occurs exactly k times (k >= 3) in an n x m character grid and list all its top-left positions in row-major order.Hard8Hash mapString+2No attempts yet1s128 MBJudgeable
The Stairways of SaharnaSplit a sequence into k disjoint non-decreasing subsequences to maximize the total number of chosen elements, and output this maximum for every k up to the point where all n elements are used.Hard8Dynamic programmingGreedy+2No attempts yet0.2s128 MBJudgeable
Hi! I'm Luffy! I'm the man who will become the Pirate King!Given island coordinates and left-of constraints per map, list every island that can be the viewpoint so all listed islands lie in a forward half-plane and constraints hold.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
ClockFind the largest empty circle fully inside a rectangular wall that avoids up to 50 non-overlapping discs, using a generalized Voronoi diagram of points, segments, and circles.Hard8GeometryDivide and conquer+2No attempts yet1s128 MBJudgeable
Pie DivisionCount the number of straight lines that split 2N labeled points (N of each of two colors, N even) so that each open half-plane holds N/2 points of each color, treating both sides as the same split.Hard8GeometryCombinatorics+2No attempts yet2s256 MBJudgeable
RobintronGiven planets orbiting a star at constant angular speeds, find the minimum time for the Robintron to hop between gravity wells from the first planet to the last, rounding up to whole days.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
HiringChoose a real wage coefficient k and a subset of workers so that each hired worker's pay Q_i*k meets their minimum S_i and the total pay stays within budget W, maximizing the subset size.Hard8SortingGreedy+2No attempts yet1s128 MBJudgeable
FishGiven fish lengths and gem kinds, count how many distinct gem-count combinations a single fish can ever hold, modulo M, where a fish can eat another only if at least twice as long.Hard8Dynamic programmingSorting+2No attempts yet3s128 MBJudgeable
Toy AnimalsCount pairs of points on a 1D, 2D, or 3D integer grid whose Manhattan distance is at most D.Hard8Divide and conquerSorting+2No attempts yet2s128 MBJudgeable
Joining PointsGiven two sets of colored points in general position inside a square, output a non-crossing spanning tree for each color separately.Hard8GeometryGreedy+2No attempts yet1s128 MBJudgeable
BirthdayChildren sit around a round table in order 1..n; reseat them into a given cyclic order while minimizing the largest distance anyone walks along the circle.Hard8Binary searchSorting+2No attempts yet2s64 MBJudgeable
ArtemisGiven N points with distinct x and y, find the axis-parallel rectangle with two opposite corners on points that contains at least T points and the fewest total points.Hard8Prefix sumBinary search+2No attempts yet2s128 MBJudgeable
Bubble SortSwap exactly one pair of elements in the array, then find the minimum number of swaps the given bubble sort performs on the result.Hard8SortingPrefix sum+1No attempts yet1s128 MBJudgeable
Habitat Range of FishGiven up to 50 axis-aligned boxes in 3D, compute the total volume covered by at least K of them.Hard8SortingDivide and conquer+1No attempts yet1s128 MBJudgeable
JOI National FestivalGiven a connected weighted graph with some festival cities, answer queries asking for the largest possible minimum distance-to-festival along any path between two cities.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
ExpositionSplit N points in the plane into two nonempty groups minimizing the largest Manhattan distance within any group.Hard8Binary searchGeometry+1No attempts yet1s128 MBJudgeable
Ladder GameGiven a ladder with n lines and m rungs, erase at most one rung to minimize the sum of scores reached from the leftmost k starting lines.Hard8ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Area and Perimeter of a Union of RectanglesGiven up to 10000 axis-parallel rectangles on an integer grid, compute the area of their union (and its perimeter when r=2), counting overlaps once.Hard8Segment treeSorting+2No attempts yet1s128 MBJudgeable
Garden FenceChoose a line through two boundary points splitting the field into two sides; minimize the total value of trees cut down.Hard8GeometrySorting+1No attempts yet5s128 MBJudgeable
File RecoverCount the distinct contiguous substrings that occur at least twice in a given string, for several test cases up to 100000 characters each.Hard8StringString matching+1No attempts yet5s128 MBJudgeable
PetanqueSimulate seven petanque throws where a moving ball travels along its direction, possibly striking other balls and transferring its remaining roll, then decide who owns the closest boule to the coche and count points.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
Cutting EdgeGiven non-overlapping rectangles that tile a big pane, output the sequence of edge-to-edge cuts (smallest X1, then smallest Y1 first) that separates every rectangle.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
Secure RegionGiven an axis-aligned field and up to 300 mines, find the axis-aligned mine-free rectangle with the largest shorter side, then the largest longer side.Hard8GeometryBinary search+2No attempts yet1s128 MBJudgeable
Detour BusterGiven a piecewise-linear track, find the shortest distance from the first point to the last while staying on the track, allowing travel in either direction.Hard8GeometryGraph+2No attempts yet1s128 MBJudgeable
Rotation ParityDecide the parity of the number of 2x2 clockwise rotations needed to sort a permutation of an R x C grid into row-major order.Hard8MathCombinatorics+2No attempts yet5s256 MBJudgeable
ElephantsAfter each of M moves that relocate one elephant, report the minimum number of length-L segments needed to cover all current positions.Hard8Segment treeDynamic programming+2No attempts yet12s256 MBJudgeable
Hill WalkGiven non-crossing slanted segments, simulate Bessie climbing each hill and falling straight down at its upper end, counting the distinct hills she touches.Hard8SortingBinary search+2No attempts yet1s128 MBJudgeable
TaxiBessie drives one cow at a time along a fence of length M, may drop cows short of their goals, starts at 0 and ends at M; find the minimum total driving distance.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Route DesignGiven two banks of valued sites and a set of non-crossing routes, find the maximum total value of a tour that alternates between banks without intersecting routes.Hard8Dynamic programmingSorting+2No attempts yet1s128 MBJudgeable
Scrambled LettersGiven N scrambled names, find for each the lowest and highest rank its original anagram could occupy in an alphabetical ordering of all cows.Hard8StringSorting+2No attempts yet1s128 MBJudgeable
Buying FeedBuy at least K pounds of feed from stores along a 1D route, paying purchase cost plus K^2 cents per mile for the load carried, and minimize the total.Hard8Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Cow TreatsSimulate a greedy process on a W by H grid where rows and columns may be swapped to place the highest remaining value in the earliest reachable slot.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
AllowanceGiven coin denominations where each divides the next and bounded supplies, find the maximum number of weeks you can pay at least C each week.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Cow Toll PathsFor each query, find the cheapest s-t trip where cost is the sum of edge tolls plus the single largest pasture toll on the route. N=250, K=10000.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
Barn AllocationGiven stall capacities and interval requests, find the maximum number of requests that can be granted without any stall exceeding its capacity.Hard8GreedySegment tree+2No attempts yet2s128 MBJudgeable
Test TakingGiven N questions and a set of possible true-counts, choose a true/false answer key maximizing the worst-case number of correct answers.Hard8MathGreedy+2No attempts yet1s128 MBJudgeable
Water SlidesOn a DAG where each node leading to the sink, Bessie maximizes her worst-case path sum when up to K times she is forced down the worst outgoing edge.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Triangle CountingCount how many triangles formed by triples of N integer points strictly contain the origin in their interior.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
Game PredictionGiven your n distinct cards in an m-player game where every card from 1 to n*m is dealt, find the most rounds you can guarantee to win against any opponent play.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
ExamsCount subsets of at most 36 positive exam scores whose sum is at least T, where each score can be as large as 10^13.Hard8Bit manipulationBinary search+2No attempts yet1s128 MBJudgeable
Haybale GuessingGiven interval minimum queries with distinct values, find the earliest query that makes the whole set of answers inconsistent.Hard8Binary searchSorting+2No attempts yet1s128 MBJudgeable
Grabbing LandSplit N rectangles into groups, each group costing the product of its max width and max height, minimizing the total cost.Hard8SortingDynamic programming+1No attempts yet1s128 MBJudgeable
Flood FillGiven M points and a threshold D, group points whose taxicab distance is at most D into connected components, then report the number of components and the largest component size.Hard8Union-findSorting+2No attempts yet2s128 MBJudgeable
Milk PatternsGiven N integers, find the length of the longest contiguous subsequence that repeats at least K times, counting overlapping occurrences.Hard8String matchingBinary search+2No attempts yet1s128 MBJudgeable
Circle ArtworkGiven up to 100 colored points, count how many colors have a circle through two of their points that contains no point of another color.Hard8GeometryBrute force+2No attempts yet1s128 MBJudgeable
Against MammothsAssign each human planet to at most one alien planet and pick a launch year so the fleet wins on arrival, minimizing the year the last alien falls.Hard8Binary searchGreedy+2No attempts yet1s128 MBJudgeable
Triangles and QuadrangleGiven two triangles and a quadrangle, decide whether the triangles can be joined along a full edge, without overlap, to form the quadrangle up to translation, rotation, and reflection.Hard8GeometryImplementation+2No attempts yet1s128 MBJudgeable
Quelling BladeGiven a tree of weapon prerequisites with costs and benefits, find a buying order that reaches the root in minimum time while maximizing the sum over time of owned benefit.Hard8GreedyDFS+2No attempts yet1s128 MBJudgeable
IntervalsGiven n integer intervals each needing at least c_i chosen points inside it, find the smallest set of integers satisfying all requirements.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
TimetableGiven a network of direct train legs, compute all Pareto-optimal journeys from city 1 to city n, where one journey dominates another if it departs no earlier and arrives no later.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
IntervalsGiven a point light above the x-axis and non-overlapping circular pipes below it, find the shadowed intervals on the x-axis, sorted and rounded to two decimals.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
XenosemanticsFind words over lowercase letters delimited by varying spacer letters in a bit stream, then report the distinct true words that repeat and overlap another true word.Hard8StringHash map+2No attempts yet1s128 MBJudgeable
StarsCount and find the brightest occurrence of each constellation pattern as a direct similarity transform of integer points within a star map.Hard8GeometryHash map+2No attempts yet1s128 MBJudgeable
Simon the SpiderPick a connected spanning subgraph minimizing total edge weight minus twice the heaviest chosen edge, or report that the graph is disconnected.Hard8Minimum spanning treeGraph+2No attempts yet2s128 MBJudgeable
Simple PolygonGiven up to 40,000 points defining a closed polygon, decide whether its edges only meet at shared endpoints (simple) or intersect anywhere (NO).Hard8GeometrySorting+2No attempts yet10s128 MBJudgeable
Go EndgameGiven starting scores, region values, and sente flags, compute the final scores when Alice and Bob alternately pick regions and respond until all are settled.Hard8Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
BoatherdsGiven a weighted tree and up to 100 queries, decide for each target value whether some pair of vertices has a path cost exactly equal to it.Hard8Divide and conquerTree+2No attempts yet1s128 MBJudgeable
Subway PlanningGiven points in the plane and a radius d, cover all points using the fewest rays from the origin, where a ray covers a point if some point on the ray is within distance d.Hard8GeometryGreedy+2No attempts yet1s128 MBJudgeable
Software CompanyAssign m subprojects of each of two projects to n employees, who work sequentially, to minimize the largest total working time.Hard8Binary searchGreedy+2No attempts yet1s128 MBJudgeable
The Winds of WarChoose a convex net containing the origin that covers as many enemy units as possible while covering as few friendly ones, and report the maximum difference.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
SnailsEach of N snails moves in a fixed direction at speed 1 and stops at the fence, at any point an earlier snail crossed, or when it meets another snail simultaneously; find when the last snail stops.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
CloudsEach cloud is a polygon moving with the same velocity; count the separate time intervals during which the vertical beam at the origin intersects at least one cloud.Hard8GeometrySorting+2No attempts yet2s128 MBJudgeable
Can of WormsFor each can, count how many cans explode when it is shot, following the chain reaction where each blast hits cans within its radius.Hard8SortingBinary search+2No attempts yet3s128 MBJudgeable
RobotsRobots on a circular track move clockwise for given durations, pushing each other and stopping at walls; find each final position.Hard8SimulationIntervals+2No attempts yet1s1024 MBJudgeable
Coat RackSort garments and targets; sliding garments keeps their order and may stack them, so assign each target to a position minimizing total distance under order constraints.Hard8Dynamic programmingDivide and conquer+2No attempts yet1s1024 MBJudgeable
KortosCount the distinct ordered piles a player can build from N distinct cards where each new card matches the top card's number, or matches its suit with a larger number, modulo 1e9+7.Hard8Dynamic programmingCombinatorics+2No attempts yet2s1024 MBJudgeable
Fortune at El DoradoGiven up to 1000 points on a 1000x1000 grid and a maximum area A, find an axis-parallel rectangle with positive integer area at most A containing the most points.Hard8Two pointersBinary search+2No attempts yet1s128 MBJudgeable
Intercepting MissilesGiven moving bombers and passenger planes plus fixed missile launchers, find the maximum number of bombers that can be shot down without hitting any passenger plane.Hard8GeometryBinary search+2No attempts yet1s128 MBJudgeable
University Entrance ExaminationGiven students with scores, home regions, and program preference lists, plus program capacities, assign students to programs under a local-region priority rule and a fairness rule.Hard8ImplementationGreedy+2No attempts yet1s128 MBJudgeable
Museum Heist: Area of the Shadowy RegionsGiven an axis-aligned rectangle with non-overlapping rectilinear polygonal obstacles and a gun at the upper-right corner, find the total area of points no monotone beam can reach.Hard8GeometrySimulation+2No attempts yet1s128 MBJudgeable
Farmer Bill's ProblemPlace non-overlapping, non-touching rectangles inside a rectangular field so all given circles lie within them, minimizing total rectangle area, and output the remaining harvestable area.Hard8GeometryDynamic programming+2No attempts yet2s128 MBJudgeable