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 |
|---|---|---|---|---|---|---|
| Non-Decreasing SubsequencesGiven an array of values from 1 to K, answer queries counting non-decreasing subsequences within a subarray, including the empty one, modulo 1e9+7. | Hard8 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Farmer John Solves 3SUMCount, for each of Q queries, the number of unordered index triples in the subarray A[a..b] whose values sum to zero. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Movie-goerChoose a contiguous block of days maximizing the sum of weights of movies that appear exactly once in the block. | Hard8 | ArrayTwo pointers+2 | No attempts yet | 5s | 512 MB | Judgeable |
| SealGiven a binary document grid and a binary seal stamp, decide whether the document is exactly the union of non-overlapping (and non-rotated) placements of the stamp. | Hard8 | ImplementationSimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| VisitsGiven a tree, a visiting order, fuel prices, and tank capacities, compute the refueling cost of each trip in the order. | Hard8 | TreePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Copy Shop SchedulingGiven deadlines and page counts for orders arriving one by one, after each addition report the smallest possible maximum lateness when preemptive scheduling is allowed on one machine. | Hard8 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Bad DoctorEach doctor prescribes a set of medicines over a day interval; ignoring one doctor, compute the total cost of distinct medicines needed per day summed over all days. | Hard8 | Segment treeSorting+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Snowy SmileGiven up to 2000 weighted points, find an axis-aligned rectangle maximizing the sum of weights of points inside or on its border, allowing an empty rectangle for zero. | Hard8 | Dynamic programmingSorting+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Awesome ShawarmaGiven a tree, count the unordered pairs of nodes whose added edge leaves the number of bridges in [L, R]. | Hard8 | TreeDFS+2 | No attempts yet | 14s | 512 MB | Judgeable |
| Dull ChocolatesCount prefix rectangles of a huge grid whose parity of white cells is odd versus even, given at most 1000 white cells. | Hard8 | Prefix sumSorting+2 | No attempts yet | 9s | 512 MB | Judgeable |
| KhoshafCount arrays of length N with entries in [L, R] that have exactly K contiguous subarrays whose sum is divisible by 3, modulo 1e9+7. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 12s | 512 MB | Judgeable |
| ExpEach of n independent monsters grants i experience (0 to k) with probability p_i, totals are capped at x, and the expected capped total must be computed modulo 998244353. | Hard8 | ProbabilityDynamic programming+2 | No attempts yet | 5s | 512 MB | Judgeable |
| HaircutFor each threshold j from 0 to N-1, clip every value above j down to j and count the resulting inversions. | Hard8 | SortingPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| New Year and ConferenceGiven n lectures, each with one time interval at venue a and another at venue b, decide whether every subset that is conflict-free at one venue is also conflict-free at the other. | Hard8 | IntervalsSorting+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Tree HullMaintain a set of tree vertices under insertions and deletions, and after each query report the total edge weight of the minimal subtree spanning the current set. | Hard8 | TreeDFS+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Wavel SequenceCount pairs of increasing index sequences from two arrays whose selected values are equal and form a strictly alternating up-down wave, modulo 998244353. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Anna and Lucky TicketsCount n-digit palindromes that are lucky under neither the alternating-position sum test nor the first-half-versus-second-half sum test, modulo 1e9+7. | Hard8 | CombinatoricsDynamic programming+2 | No attempts yet | 2s | 256 MB | Judgeable |
| FaintSum the absolute differences between consecutive rows of a fixed column in the lexicographically ordered list of k-subsets of {1,...,n}, modulo 1e9+7. | Hard8 | CombinatoricsMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| PrimesAnswer online queries that ask for the sum of shared distinct prime counts over all pairs in a range [a, b] up to 10^6. | Hard8 | Number theoryPrefix sum+2 | No attempts yet | 8s | 256 MB | Judgeable |
| Master Zhu and Math ProblemCount quadruples (a,b,c,d) within given bounds that satisfy two linear inequalities, modulo 1e9+7, with bounds up to 1e18. | Hard8 | MathCombinatorics+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Game of ChairsChoose a starting chair to minimize the expected distance to the nearest chair of a uniformly random color, and output the expectation as a reduced fraction. | Hard8 | MathPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Donut-shaped EnclosurePlace a Chebyshev-distance donut with inner radius L and outer radius R at a lattice center to maximize the total weight of covered points. | Hard8 | GeometryPrefix sum+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Value of the ArrayFor each k from 1 to n, sum over all non-empty subsequences the sum of their min(size, k) largest elements, modulo 998244353. | Hard8 | CombinatoricsSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Best DivisionGiven a pseudorandom array, find the largest K such that A can be split into K nonempty intervals of length at most L, each with XOR sum at most X. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Intersection is Not Allowed!Count the ways to route K non-crossing monotone paths from fixed top squares to fixed bottom squares on an N by N board, modulo 1e9+7. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Voucher PreparationGiven members with distinct skills and names, answer many queries: remove the b highest-skilled members, then partition the best M*a remaining into a teams to maximize the summed product of skills, and output the XOR of the names of all chosen members. | Hard8 | GreedySorting+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| A Game with GrundyFor each i from 0 to N, count integer x positions with L <= x <= R that lie strictly inside at most i of N triangular visibility wedges. | Hard8 | GeometrySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| FeastChoose at most K disjoint non-empty subarrays of A so that the total sum of their elements is as large as possible. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| LinearizationFor each query substring whose length is a power of two, find the minimum number of contiguous flips that make it a parity-of-AND pattern; the answer reduces to half the number of adjacent differing pairs after an XOR derivative. | Hard8 | Bit manipulationPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| SpeedingGiven n road segments with speed limits and lengths, plus m speeding ranges with fines, find for each car the maximum fine guaranteed from its entry and exit times. | Hard8 | Binary searchGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| District PartitioningPick X horizontal and Y vertical dividing roads from an (n+1)x(m+1) population grid so the maximum population of any resulting block is minimized. | Hard9 | Binary searchGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Hard MatchingGiven a text sequence and two number patterns, count positions where consecutive-sum grouping matches each pattern, then find the smallest glue value x maximizing matches of the concatenated pattern with x inserted between them and report that match count. | Hard9 | String matchingPrefix sum+2 | No attempts yet | 30s | 1536 MB | Judgeable |
| DNA SequencesGiven a DNA pattern with wildcards and a rank R, find the R-th lexicographic matching string that decomposes into at most K non-decreasing runs. | Hard9 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Planning Rolling BlackoutsPartition an h by w grid by recursive guillotine cuts so that the heaviest set of groups left powered stays within capacity, maximizing the group count and then the reserve. | Hard9 | Dynamic programmingPrefix sum+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Yin and YangOn a tree with each edge colored black or white, count paths that split at an internal vertex into two legs each having equal numbers of black and white edges. | Hard9 | TreeDivide and conquer+2 | No attempts yet | 2s | 128 MB | Judgeable |
| BottleneckGiven a tree of one-way paths toward field 1, each with a per-time-unit cow capacity, answer K queries for the most cows that can reach field 1 by time T. | Hard9 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A Romantic Movie OutingMaintain a dynamic set of occupied seats across a huge theatre, answer queries for the combined field-of-vision inconvenience of two seats, and at the end find the minimum over far unoccupied seat pairs. | Hard9 | Segment treeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PeriodicityFor each name, find the lexicographically smallest bit string of the same length whose set of periods equals the name's set of periods, or XXX if none exists. | Hard9 | StringPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Army TrainingGiven n points with no three collinear, answer m queries, each a simple clockwise polygon on those points, counting the points strictly inside it. | Hard9 | GeometryCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Quasi-templateCount the distinct words that, as substrings of v with possibly overhanging copies, can tile across the whole input; report the count and the shortest, lexicographically smallest such word. | Hard9 | String matchingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Prefix-SuffixesCount proper borders summed over all substrings of a given lowercase word of length up to 10^5. | Hard9 | String matchingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| HighwaysGiven a tree plus extra highway edges, count for each query (x,y) the main tree path plus alternative single-highway paths that touch the main path only at x and y. | Hard9 | TreeDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| The Most Valuable TowerFind the largest sum any single tower can reach by swapping top segments between towers of different heights. | Hard9 | Number theorySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Land TaxChoose a non-empty contiguous row and column range that maximizes combined row and column payments weighted by heights and widths. | Hard9 | Divide and conquerGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CrystalSum the signed charges of all three-colored unit triangles in a hexagonal crystal filled row by row from a modular generator. | Hard9 | MathGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AdriaticOn a 2500 by 2500 grid, islands ordered alike from northwest to southeast connect in one hop, and each island needs the sum of fewest hops from all others. | Hard9 | GraphPrefix sum+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Covering postersFor each new axis-aligned rectangle, compute the total area of the given union of rectangles that it covers. | Hard9 | Segment treePrefix sum+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| XOR QueriesMaintain an array under appends, rollbacks of the last k elements, and range queries for max XOR, count <= x, and k-th smallest. | Hard9 | TrieSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 0For each query range [i,j] of a ±1 sequence, report the length of the longest contiguous subarray inside it whose sum is 0, or 0 if none exists. | Hard9 | Segment treePrefix sum+2 | No attempts yet | 2.5s | 512 MB | Judgeable |
| Sequence and Queries 6For each query range [i, j], report the highest number of occurrences of any single value inside that range. | Hard9 | Segment treeDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| EggscavationGiven up to 100000 shell species (each in at most 4 cells) and egg insertions, answer queries for the probability that a random K x K scoop covers at least V species and no egg. | Hard9 | GeometryPrefix sum+2 | No attempts yet | 10s | 512 MB | Judgeable |
| MinerFor each lamp position above a polyline mine floor, find the reachable floor interval lit without crossing the floor. | Hard9 | GeometryBinary search+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Bracket PathsGiven a tree with '(' or ')' on each node, count ordered pairs (a,b) whose path string w_{a,b} is a properly matched bracket expression. | Hard9 | TreeDivide and conquer+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| The Enormous SequenceDefine a_n by summing every nonempty subset sum of the first n-1 terms, then answer queries about gcd, 2-adic valuation of lcm, prefix sums, or a single term for various starting values. | Hard9 | MathNumber theory+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Rolling the BottleGiven a convex polygon as a bottle base and a water volume, find the minimum and maximum number of sides of the water region as the bottle rolls. | Hard9 | GeometrySorting+2 | No attempts yet | 2.5s | 512 MB | Judgeable |
| 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. | Hard9 | GreedyPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Intrinsic IntervalFor each query range in a permutation, find the smallest subarray containing it whose values form a set of consecutive integers. | Hard9 | Segment treeStack+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Laminar FamilyGiven an undirected tree and f vertex sets, each a simple path, decide whether the family of paths is laminar. | Hard9 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| L-th K-th numberGiven N cards, take the K-th smallest value of every contiguous block of length at least K, then report the L-th smallest of all those values. | Hard9 | Binary searchArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard9 | MathGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| In honor of Taekhee's graduationDeer bounce on a line segment [0,T], each with strength; a statue at x falls when the net force of deer that have reached it exceeds W. Maximize the fall time over x. | Hard9 | MathSimulation+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Pia's Atelier: The Alchemist of Mysterious LifeGiven 2x2 parity constraints on an n by n binary grid, decide for each day whether a grid exists satisfying all interval cell-fixing conditions active that day. | Hard9 | Union-findPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| International Cow Lineup Photo ContestGiven a 0/1 array and up to 1e5 adjacent swaps, after each swap report the longest subarray with equal numbers of 0s and 1s. | Hard9 | Segment treePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard9 | GreedyPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fruit TreeGiven a tree whose vertices hold fruit types, answer queries asking whether one type is a strict majority on the path between two vertices, and which type it is. | Hard9 | TreeBinary search+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Historical ResearchFor each query range, report the maximum over event types t of t times the count of t inside the range. | Hard9 | Divide and conquerArray+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Sequence and Queries 32Maintain a sequence under point updates and answer whether it can be split into contiguous blocks whose xors all lie in a small given set. | Hard9 | Dynamic programmingPrefix sum+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Dance CircleCount, modulo 1e9+7, the binary assignments to n children around a circle matching n parity constraints, each covering a contiguous arc centered at some child. | Hard9 | MathPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Colored Paper and QueriesGiven N axis-aligned rectangles and M axis-aligned query rectangles, report for each query the maximum number of input rectangles covering any single point inside it. | Hard9 | Segment treeDivide and conquer+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Speed Reading CourseCount how many positions i where c contains the given m-bit word w, with c defined by an arithmetic progression modulo n against threshold p. | Hard9 | Number theoryString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Rooted SubtreesFor each query with two roots r and p, count the distinct non-empty sets that are the intersection of a subtree of the tree rooted at r and a subtree of the tree rooted at p. | Hard9 | TreeDFS+2 | No attempts yet | 11s | 512 MB | Judgeable |
| Linear Congruential GeneratorGiven a linear congruential generator and two index ranges, sum X_i mod (X_j+1) over all pairs i in the first range and j in the second. | Hard9 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Greatest Chicken DishCount, for each query range [L, R] and value D, the number of contiguous subarrays inside [L, R] whose GCD equals D. | Hard9 | Dynamic programmingNumber theory+2 | No attempts yet | 15s | 512 MB | Judgeable |
| Sprinklers 2: Return of the AlfalfaCount the ways to place sweet corn and alfalfa sprinklers on an N by N grid, with some blocked squares, so that every square is covered by exactly one sprinkler type. | Hard9 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Dirt RatioChoose a contiguous subarray to minimize (number of distinct values)/(subarray length); print the minimum ratio. | Hard9 | Binary searchPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Unseen SegmentsGiven n vertical segments and queries of (west power, east power), find the total length of parts no observer sees through at most that many segments. | Hard9 | GeometrySorting+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Master Zhu and RikkaGiven a rooted tree with values on vertices, answer queries that ask for the GCD of sums of values occurring exactly a times and exactly b times in a subtree or on a path. | Hard9 | TreeDFS+2 | No attempts yet | 3s | 512 MB | Judgeable |
| GCD vs LCMFor each of q queries with n, m, a up to 1e5, sum lcm(i,j) over all i<=n, j<=m with gcd(i,j)<=a, modulo 1e9+7. | Hard9 | Number theoryMath+2 | No attempts yet | 2.5s | 512 MB | Judgeable |