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 results1,178 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Authentication LevelTwo grids each have a starting cell; pick a threshold per grid so the reachable cells sum to at least R, minimizing the sum of thresholds. | Hard8 | GraphBFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Bingo GameCount N x N grids with distinct values from 1 to M, columns increasing downward, each column larger than all columns to its left, and total sum S, modulo 100000. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Segment treeSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Boxes and StonesCount the initial distributions of S indistinguishable stones among the first B-1 boxes from which Carole, moving second each round, can force a win against Paul. | Hard8 | Game theoryCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Joining CouplesEach city has one directed outbound flight, forming a functional graph; for each query find the minimum combined distance from two starting cities to any common reachable city, or -1. | Hard8 | GraphTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sanghak LanguageCount the distinct strings formed by concatenating any nonempty prefix of a Namgyu word with any nonempty suffix of a Jaehyeok word, summing over several test cases. | Hard8 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GrapevineGiven a monotone matrix of heights and height-interval queries, find for each query the largest square submatrix whose heights all fall in the interval. | Hard8 | Binary searchDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DNA SubsequenceFind the longest common subsequence of two words where every maximal matched run must be a contiguous block of at least K characters in both words. | Hard8 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PhotoGiven intervals each containing exactly one marked point, find the maximum number of marked points, or -1 if no assignment is consistent. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Figure EightFind two axis-aligned rectangles sharing one horizontal edge row, outlines all flawless, maximizing the product of the two interior areas. | Hard8 | Prefix sumImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Partitioning the FarmPlace at most K full-width horizontal or vertical fences on an N x N grid to minimize the largest connected group of cows. | Hard8 | Brute forceBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Farm ManagementA tree of N farms gets path updates that add 1 to every edge on a path, plus path queries that sum edge values on a path; process M operations online. | Hard8 | TreeSegment tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The TriangleGiven a triangular grid of values, find the sub-triangle (either orientation, side at least K) whose truncated average is largest. | Hard8 | Binary searchPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Coin GameTwo players alternately take coins from the top of a pile, where each move may take between 1 and twice the previous move's count; find the maximum total value the first player can guarantee with optimal play from both sides. | Hard8 | Dynamic programmingGame theory+2 | No attempts yet | 1s | 32 MB | Judgeable |
| PaybackFriends stand at positions 1 to N with signed debts; Bessie starts at 0 holding nothing, must never go negative, and finishes at N. Find the minimum walking distance to settle all accounts. | Hard8 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| IntervalsGiven n integer intervals each needing at least c_i chosen points inside it, find the smallest set of integers satisfying all requirements. | Hard8 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Connected GheevesGiven two convex funnel-shaped containers joined at the bottom, find the water level reached after pouring a given area of water, capped at the lower rim. | Hard8 | GeometryBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GerrymanderingMerge adjacent ridings into blocks so Party 1 strictly wins a majority of the remaining ridings, minimizing the number of merges. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SweetsCount the ways to take up to m_i candies from each of n jars so the total is between a and b, modulo 2004. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FootballSplit a row of N player skills into K consecutive segments of at least M each so that the minimum segment average is maximized, and print that value as a reduced fraction. | Hard8 | Binary searchDynamic programming+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| UnterA connected graph with N houses and exactly N edges (one cycle) must answer up to 1e6 shortest distance queries. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| 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. | Hard8 | Two pointersBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| HypertransmissionGiven N points in 3D each labeled 0 or 1, choose a squared radius R^2 to maximize the number of points where opposite-label neighbors outnumber same-label ones, then report that maximum and the smallest R^2 achieving it. | Hard8 | SortingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Box ArtGiven a bounding box and up to 2000 axis-aligned boxes, compute the volume of their union clipped to the bounding box. | Hard8 | GeometrySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RectanglesGiven N axis-aligned rectangles, compute the area of their union. | Hard8 | Segment treeSorting+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Painting PatternsCount grid cells painted black by up to N rectangle operations, each applying one of three periodic patterns under OR overlap. | Hard8 | GeometryPrefix sum+2 | No attempts yet | 2s | 64 MB | Judgeable |
| GarlandsSplit a weighted sequence of n pieces into m segments of even length, each half-segment at most d pieces, minimizing the maximum half-segment weight. | Hard8 | Binary searchDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | GreedyPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| YAPTCHAFor each query n, compute the sum of floor(((3k+6)!+1)/(3k+7) - floor((3k+6)!/(3k+7))) over k from 1 to n. The sum equals the count of primes among 3k+7 for k=1..n, so precompute primes up to 3n+7 and prefix counts. | Hard8 | Number theoryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AntsGiven a tree tour as a 2n-bit sequence, compute the exact time when the two ants walking in opposite directions turn around for the second time, as a reduced fraction. | Hard8 | MathSimulation+2 | No attempts yet | 3s | 8 MB | Judgeable |
| Hallucinogenic CarnationsFor each of up to 10000 polygons, sum the carnations in grid parcels whose area at least half lies inside the polygon. | Hard8 | GeometryPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The InvasionGiven a convex polygon with n vertices and m weighted points, find three polygon vertices forming a triangle with the maximum total weight of points inside or on it. | Hard8 | GeometryTwo pointers+2 | No attempts yet | 3s | 64 MB | Judgeable |
| PloughingGiven an m by n grid of tile difficulties, repeatedly remove a full strip of width 1 from any edge as long as the strip sum is at most k, and minimize the number of strips that remove every tile. | Hard8 | Dynamic programmingTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Plot purchaseGiven an n by n grid of non-negative prices, decide whether some axis-aligned subrectangle has a sum between k and 2k inclusive. | Hard8 | Prefix sumGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ice SkatesAfter each of m membership events, decide whether every current member can be assigned skates, given k pairs of each size and foot sizes with tolerance d. | Hard8 | Segment treeGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| SheepCount triangulations of a convex n-gon by non-crossing diagonals such that no diagonal passes through a sheep's spot and every triangle holds an even number of spots, modulo m. | Hard8 | Dynamic programmingGeometry+2 | No attempts yet | 3s | 512 MB | Judgeable |
| MeteorsEach of N states owns sectors on a circle; given Q meteor showers that add a value to a sector range, find the earliest day each state's total reaches its target, or report it never does. | Hard8 | Binary searchPrefix sum+2 | No attempts yet | 5s | 256 MB | Judgeable |
| SalariesGiven a rooted tree with salaries a permutation of 1 to n increasing toward the root and some values revealed, print each value forced by the revealed ones or 0 otherwise. | Hard8 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GreedyHeap+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PrefixuffixGiven a string t, find the maximum length L, at most n/2, such that the length-L prefix and the length-L suffix of t are cyclic rotations of each other. | Hard8 | StringString matching+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Painting the WallGiven n axis-aligned rectangles, find the total area of the plane covered by at least n-1 of them. | Hard8 | SortingSegment tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cheap AirlinesChoose at most k non-overlapping contiguous segments of the array to maximize the total sum of their elements. | Hard8 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Coprime NumbersGiven up to a million integers, count pairs whose greatest common divisor is 1. | Hard8 | Number theoryCombinatorics+2 | No attempts yet | 5s | 128 MB | Judgeable |
| 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. | Hard8 | SortingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TurnsFor each starting position, find how many turns must be observed before the position on the map becomes uniquely determined. | Hard8 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | ArrayPrefix sum+2 | No attempts yet | 3s | 128 MB | Judgeable |
| 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. | Hard8 | Prefix sumMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| ExcursionSplit a path of n weighted roads into contiguous segments of total length at most D, minimizing the sum of squared segment impression sums. | Hard8 | Dynamic programmingSliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CiągBajtek needs the shortest string over the given alphabet that is not a subsequence of the word, and the lexicographically smallest among shortest such strings. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Settling SalariesWorkers on a ring compare contract pay to cash received and settle every balance with the fewest transfers between neighbors. | Hard8 | GreedyPrefix sum+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Punch CardsChoose the largest a by b stamp whose repeated presses punch exactly the marked cells without ever punching an intact cell. | Hard8 | Prefix sumMatrix+2 | No attempts yet | 1s | 256 MB | Judgeable |
| SlidesCount the non-empty slide subsets that keep slide-number order and rise in both rankings, modulo 1000000007. | Hard8 | Dynamic programmingDivide and conquer+1 | No attempts yet | 10s | 128 MB | Judgeable |
| Fine Dining RestaurantFor each banned serial number, count the digit comparisons the described naive left-to-right substring search performs against the concatenated string A. | Hard8 | String matchingTrie+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Beautiful LandscapeMove blocks between neighboring stacks at unit cost so occupied positions sit at pairwise prime distances using the fewest moves. | Hard8 | Dynamic programmingPrefix sum+1 | No attempts yet | 20s | 128 MB | Judgeable |
| The CarpenterCut two non-overlapping diagonal triangles from an n by m black-and-white board and glue them into the largest square with alternating colors. | Hard8 | Dynamic programmingMatrix+1 | No attempts yet | 2s | 128 MB | Judgeable |
| HistogramsGiven histogram H and point set S, build a valid histogram from S points that minimizes diffcount or abserror against H. | Hard8 | Dynamic programmingPrefix sum | No attempts yet | 1s | 256 MB | Judgeable |
| CriminalsFind every house where two given color sequences appear as subsequences on the left and right with both walkers sharing one home color outside. | Hard8 | String matchingGreedy+1 | No attempts yet | 2s | 256 MB | Judgeable |
| SupercomputerGiven a rooted tree of unit-time tasks and many processor counts, compute the fastest finishing time for each count. | Hard8 | TreePrefix sum+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Test Data AnalysisCount bounded arrays of length N whose maximum contiguous subarray sum equals D, modulo 1,000,000,007. | Hard8 | Dynamic programmingPrefix sum+1 | No attempts yet | 2s | 256 MB | Judgeable |
| MarblesPlace three pairwise disjoint axis-aligned rectangles to maximize red marbles in the first plus blue in the second plus green in the third. | Hard8 | GeometryPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Line SweepFind the tallest vertical broom that still reaches every empty cell by sliding sideways, then the fewest sideways sweeps that clean them all. | Hard8 | GreedyIntervals+2 | No attempts yet | 10s | 256 MB | Judgeable |
| NucleariaAdd up the linearly decaying king-move radiation from every plant in each grid cell, then answer each rectangle query with its rounded average. | Hard8 | Prefix sumMath | No attempts yet | 1s | 1024 MB | Judgeable |
| Marble MadnessMove marbles between adjacent bins to maximize the total absolute difference of neighbor counts, and report that maximum plus the fewest moves achieving it. | Hard8 | Dynamic programmingMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Call a CabPartition the ordered points into the fewest rides where each ride meets one type's minimum total distance and heading range limit. | Hard8 | Dynamic programmingSegment tree+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Book BordersFor each width m from a to b, wrap the words greedily into lines of at most m characters and report the length of the sentence made of each line's first word. | Hard8 | Divide and conquerPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Balanced PathsCount ordered node pairs whose labels along the tree path form a balanced parenthesis string. | Hard8 | Divide and conquerHash map+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Find the missing rankCount score assignments within given ranges where no person receives rank R under tied ranking. | Hard8 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 32 MB | Judgeable |
| Swapping the StonesMove stones along empty arcs of a circular shore so black and white stones exchange position sets with minimum total carry distance, or report impossibility. | Hard8 | GreedyString matching+1 | No attempts yet | 2s | 32 MB | Judgeable |
| Ticket SwappingPassengers riding one direction on a line pay a decreasing per-stop fare and may swap entry cards where trips overlap, so compute the maximum total fare loss. | Hard8 | GreedySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| BoatCount subsets of schools with an assigned boat count in [a_i, b_i], strictly increasing in school order, excluding the empty setup, modulo 1e9+7. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Spiral Rectangle SumsIn a counterclockwise spiral of numbers on a (2n+1)x(2n+1) grid centered at 1, answer q queries for the sum inside an axis-aligned rectangle modulo 1e9+7. | Hard8 | MathImplementation+2 | No attempts yet | 1.5s | 256 MB | Judgeable |
| Balanced DietGiven proportional target fractions and a balanced eating history, find how many more candies can be added with every prefix staying balanced, or report forever. | Hard8 | GreedyMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Longest RiversGiven a river network tree and source names, find for each name the best rank it can achieve over all valid downstream naming choices. | Hard8 | TreePrefix sum+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Bridge testingGiven a weighted tree and two timed walkers on their respective paths, decide for each query whether both occupy some bridge simultaneously over a positive-length interval. | Hard8 | TreeDynamic programming+2 | No attempts yet | 4s | 256 MB | Judgeable |
| Hongjun Likes StringsFor each of up to 100000 queries, find the shortest substring of a fixed string S that contains both given short patterns A and B, allowing overlap. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Favorite Arrays 2Count length-N arrays with entries in 1..K where no adjacent pair has A > B with A divisible by B, modulo 1e9+7. | Hard8 | Dynamic programmingNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hongjun's IntersectionSum the lengths of the intersections of all k-subsets of given segments, modulo 1e9+7. | Hard8 | SortingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Minho's WishFor each of Q range queries on an array, count how many distinct values occur at least three times within the queried index range. | Hard8 | Segment treePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hongjun and the TreeProcess subtree updates that add a distance-dependent value to each vertex, answering point-weight queries modulo 1e9+7. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| New Adventure of Marty and DocPlace a recycling plant on one grid cell so a robot carries every part to it with the fewest moves, picking up and dropping one part at a time. | Hard8 | MathPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WhiteboardGiven a path on a grid and a target pattern, find the smallest and largest drying timestep T so the final board matches the target. | Hard8 | SimulationImplementation+2 | No attempts yet | 5s | 512 MB | Judgeable |
| BillboardGiven a 0/1 matrix, find the largest all-1 sub-rectangle after flipping at most s zeros and clearing at most r rows entirely. | Hard8 | Sliding windowTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Counting Bow TiesCount 4-cycles in a bipartite graph defined by M rectangles over vertex ranges, with N up to 1e9. | Hard8 | GeometryCombinatorics+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Gambling and rectanglesCompute the expected score over all equally likely rectangles, where the score squares the count of each value 1 to 5, and print it as a reduced fraction. | Hard8 | CombinatoricsMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| PopealaPartition T weighted test cases into exactly K consecutive subtasks to minimize total scored points, for each K up to S. | Hard8 | Dynamic programmingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Counting rectangles by distinct numbersCount rectangles of every size by how many distinct numbers they contain, then output a product of those counts modulo 1e9+7. | Hard8 | ImplementationBit manipulation+2 | No attempts yet | 3s | 256 MB | Judgeable |
| JailbreakPartition L cells into at most G consecutive blocks, minimizing the sum over each cell of its escape power times its block length. | Hard8 | Dynamic programmingDivide and conquer+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Blue vertex distance sums on a treeProcess paint and distance-sum queries on a weighted tree, reporting for each query 2 the total distance from x to all blue vertices. | Hard8 | TreePrefix sum+2 | No attempts yet | 5s | 512 MB | Judgeable |
| K-th smallest weight on a tree pathFor each query, print the k-th smallest vertex weight on the unique tree path between two vertices. | Hard8 | TreeBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Weighted sum queries on a mutable sequenceMaintain a sequence under insert, delete, and replace, and answer weighted-sum range queries where each element is multiplied by its offset to the power k (k up to 10). | Hard8 | TreeBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 7For each query range, find the longest subarray whose sum is divisible by K. | Hard8 | Prefix sumDivide and conquer+1 | No attempts yet | 4s | 512 MB | Judgeable |
| Counting close pairs in a rangeGiven a sequence and K, each query asks how many index pairs inside a subarray have value difference at most K. | Hard8 | Divide and conquerPrefix sum+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Sequence and Queries 10For each query with ranges [x1,y1] and [x2,y2], find the maximum subarray sum A_i+...+A_j where i is in the first range and j is in the second. | Hard8 | Segment treePrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Largest Increasing SubmatrixGiven a matrix, find the largest rectangular submatrix whose row-by-row linearization is strictly increasing. | Hard8 | Dynamic programmingMatrix+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 11Given an array and integer K, answer queries counting subarrays within [l, r] whose XOR equals K. | Hard8 | Prefix sumHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Water TankGiven a daily repeating schedule of water usage, find the minimum constant pump rate that keeps the tank from ever running dry. | Hard8 | Binary searchSimulation+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Internet TroublePlace 1 to N stations on a line of towns to minimize station cost plus weighted cable cost, where each house connects to the nearest station. | Hard8 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ACM TaxFor each query path in a weighted tree, output the median edge length, rounded to one decimal. | Hard8 | TreeBinary search+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Sky TaxOn a tree with a moving capital, each vertex answers for all vertices whose path to the capital passes through it; move the capital or query a vertex's count. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Sequence and Queries 14For each query on a subarray, take the distinct values, sort them, and report the k-th smallest, with each query depending on the previous answer. | Hard8 | ArraySorting+2 | No attempts yet | 5s | 1536 MB | Judgeable |