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 results3,683 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| DramaCount the number of valid pyramid colourings of an H by N grid with exactly N black cells, modulo 10^9+7. | Hard9 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Revenge of the Endless BFSDecide whether a buggy BFS that forgets visited vertices ever terminates on a given directed graph, and if so output the loop count modulo 1e9+7. | Hard9 | GraphBFS+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 |
| Pipe Fitter and the Fierce DogsIn a grid where every odd row and column holds a house, cover all houses with downhill chains, minimizing the cost of pipes through dog blocks, using at most K chains. | Hard9 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Blocks 2Count the ways to tile an N x M rectangle with rotated k x N blocks (k=1..N), modulo 1999, where M can be as large as 10^10. | Hard9 | CombinatoricsDynamic programming+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Stamp PaintingCount the distinct colorings of an N-unit canvas obtainable by stamping K-wide colored stamps so every unit ends up painted, modulo 1e9+7. | Hard9 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Maximal polygon brightnessGiven a convex polygon and a sequence of vertex deletions, compute after each deletion the largest total length of edges that a single external light point can illuminate. | Hard9 | GeometryDynamic programming+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Street TreesMaintain a minimum-cost coloring of N vertices with two colors under incremental equality/inequality constraints and point cost updates, reporting the optimum after each operation. | Hard9 | Union-findGraph+2 | No attempts yet | 2s | 256 MB | Judgeable |
| The Number of SequencesFor a given N and C, find the lexicographically smallest triple (X, Y, Z) such that exactly C ordered N-tuples of 31-bit integers have OR X, AND Y, XOR Z, or report none exists. | Hard9 | Bit manipulationCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Uncrossed Knight's TourGiven an m by n board (m at most 8, n up to 1e15), find the maximum number of squares a closed knight tour can visit without crossing itself. | Hard9 | GreedyDynamic programming+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Maximum Weight Matching in a General GraphGiven a weighted undirected graph, find a matching with maximum total edge weight. | Hard9 | GraphGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| United States of EurasiaSplit N points sorted by x into at most K contiguous groups, minimizing the largest squared diameter within any group. | Hard9 | Binary searchDynamic programming+2 | No attempts yet | 20s | 1024 MB | Judgeable |
| Xtreme NP-hard Problem?!Find the minimum-weight simple path from vertex 1 to vertex n that uses exactly k edges, or report -1; with n, m, k up to 10^6 this is explicitly NP-hard. | Hard9 | GraphShortest path+2 | No attempts yet | 5s | 1024 MB | Judgeable |
| Travelling MerchantGiven a directed weighted graph and per-market buy/sell prices for K items, find the maximum profit-to-duration ratio of a closed walk trading at most one item at a time, floor it. | Hard9 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree EscapeOn a rooted tree where each leaf starts with one piece, players alternately move a piece to its parent and remove it at the root; decide if the first player wins. | Hard9 | Game theoryTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cloud computingChoose a set of orders and a set of computers to buy so every accepted order gets enough cores at its minimum clock rate, maximizing payments minus computer costs. | Hard9 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| SatellitesSatellites appear and disappear above a half-disc planet; for each query decide whether two satellites have a common coverage point outside the planet that no other live satellite covers. | Hard9 | GeometryDynamic programming+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Delivery DelaysCompute all-pairs shortest paths, then use dynamic programming over delivery-order subsets to find the delivery schedule that minimizes the worst order-to-delivery waiting time. | Hard9 | Shortest pathDynamic programming+2 | No attempts yet | 5s | 512 MB | Judgeable |
| EscalatorsChoose unordered paths on a tree and pay V[u] plus every other endpoint's complemented value to maximize total tokens. | Hard9 | TreeDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| GameChoose the order in which balls are manually removed so chain reactions of merging equal neighbors delete as many other balls as possible; output that maximum count. | Hard9 | Dynamic programmingStack+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CryptoCount permutations of 1..N whose window-product multiset, taken as the K smallest primes, has exactly P distinct values, modulo 1e9+7. | Hard9 | CombinatoricsNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Forgotten LandSum over all partitions of a tree's vertices into arbitrary sets of the total language difficulty, where a set's difficulty depends on the union of languages on its vertices and on paths between them. | Hard9 | Dynamic programmingTree+2 | No attempts yet | 3s | 512 MB | Judgeable |
| The Bridge on the River KawaiiMaintain a graph under bridge insertions and deletions, and for each query answer the minimum possible maximum edge weight on a path between two islands, where weights are single digits. | Hard9 | Dynamic programmingUnion-find+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Colored Tiles 2Place given 1x1 and 1x2 tiles on an H by W board without overlap to maximize the total score of edges between neighboring tiles, then output every tile's coordinates. | Hard9 | Dynamic programmingImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Low Range-Sum MatrixFlip signs of at most K cells in an N by M matrix (both at most 10) so that no horizontal or vertical contiguous segment sums to more than S. | Hard9 | Brute forceDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Nim Game Without RepeatsNim with piles of size up to 60, but each specific removal size can be used at most once per pile; decide the winner under optimal play. | Hard9 | Game theoryDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Moorio KartCount and sum the lengths of simple cycles (at least Y) formed by joining every tree in a forest with one X-length edge between consecutive trees and a chosen path inside each tree. | Hard9 | TreeDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Mowing MischiefGiven flowers on a grid, pick a longest chain of flowers both paths must visit, then find the minimum area the two monotone paths can sweep. | Hard9 | Dynamic programmingSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| MessageCount length-n lowercase strings that contain a given pattern p as a substring, modulo m, where n can reach 10^12 and p has length at most 50. | Hard9 | Dynamic programmingString matching+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Build a WorkbookMaintain a dynamic precedence relation among N problems under edge inserts and deletes, and answer whether the subgraph induced by problems x through y is acyclic. | Hard9 | GraphDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Overflowing UncertaintyFor each interval [i,j] compute the probability that the gcd of j-i+1 independent uniform values in [1,Y] is coprime with Y, sum over all intervals, and report the numerator modulo 1e9+9 with denominator Y^N. | Hard9 | Number theoryDynamic programming+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Maintaining a SequenceMaintain a sequence under insert, delete, range assign, reverse, range sum, and global maximum subarray queries. | Hard9 | Dynamic programmingImplementation+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Working CellsGiven T periodic N-vertex weighted digraphs, count modulo 1e9+7 the number of D-step walks from every hub i to every hub j. | Hard9 | MatrixDivide and conquer+2 | No attempts yet | 1s | 512 MB | Judgeable |
| The Tallest and Widest CastleChoose which signposts serve as vertices of each floor so the castle has the most floors, then the largest total floor area, then the fewest signposts used, and report each signpost's floor number. | Hard9 | GeometryDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Sequence and Queries 26Maintain a sequence under range chmin updates, range maximum queries, and range sum queries, with up to a million elements and queries. | Hard9 | Segment treeDynamic programming+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Dynamic DiameterMaintain a weighted tree under edge weight updates and report the diameter after each of q updates, decoding each query with the previous answer. | Hard9 | TreeDivide and conquer+2 | No attempts yet | 5s | 512 MB | Judgeable |
| AsceticismCount permutations of 1..N such that an optimal daily reading schedule (reading consecutive sentences within each day's time slots) finishes the sutra in exactly K days. | Hard9 | Dynamic programmingCombinatorics+2 | No attempts yet | 0.6s | 256 MB | Judgeable |
| CandiesFor each j, find the maximum sum of j non-adjacent values chosen from N candies in a row. | Hard9 | Dynamic programmingGreedy+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Road DevelopmentGiven N cities and Q plans, some carried out, find for each abandoned plan how many unpaved roads on shortest paths in the current graph it would have paved, or -1 if it builds a new road. | Hard9 | GraphUnion-find+2 | No attempts yet | 2s | 256 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 |
| Be Geeks!Sum gcd(a_i..a_j) * max(a_i..a_j) over all subarrays, modulo 1e9+7, with N up to 2e5. | Hard9 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Regarding How a Simple DFS Problem I Thought Was Problem A Became Problem E in This Contest (Easy)Given a perfect binary tree with N = 2^k - 1 weighted nodes numbered in heap order and an implied axis-aligned layout, find the maximum sum of weights inside any axis-parallel rectangle whose sides don't cross a node. | Hard9 | Divide and conquerDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree DepthFor each node i, sum its depth over all permutations of 1..N with exactly K inversions, using the Cartesian-tree BST built by recursively taking the minimum. Output each sum mod a large prime. | Hard9 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Chessboard MovementCount paths from row 1 to row N on an N x M chessboard where odd rows restrict moves to same-colored adjacent cells and even rows allow any adjacent move, modulo 1e9+7. | Hard9 | Dynamic programmingMatrix+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Patrol RouteFind the minimum closed walk covering every edge of a connected weighted undirected multigraph at least once, with at most 15 vertices. | Hard9 | GraphDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TenkeyFind the minimum number of keypad operations (cursor moves plus key presses) to type a positive integer congruent to R modulo M, starting from the 0 key. | Hard9 | GraphBFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| KnowledgeCount strings of length x reachable from s by inserting or deleting the blocks aa, bbb, and ababab, modulo 998244353. | Hard9 | StringCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Seven NeversFor every window of k consecutive elements in a permutation, compute the LIS length after deleting that window. | Hard9 | Dynamic programmingSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| One RootCount pairs (p, q) with |p|, |q| <= m for which x^n + px + q has exactly one real root. | Hard9 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Counting Edit DistancesCount the number of distinct strings over 'A' to 'Z' whose Levenshtein distance from a given string s is exactly d, modulo 998244353. | Hard9 | Dynamic programmingString+2 | No attempts yet | 10s | 512 MB | Judgeable |
| KaleidoscopeCount colorings of the 60 faces of a rhombic hexecontahedron with n colors, each color i used at least c_i times, where colorings are identified under the rotational symmetry group, modulo p. | Hard9 | CombinatoricsMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Expected CostPick a labeled tree on n vertices uniformly at random and find the expected value of the minimum sum of distances from any vertex to all others, modulo a prime. | Hard9 | CombinatoricsTree+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Count the GraphsCount labeled connected undirected graphs on N nodes with exactly K bridges, modulo a possibly composite M, for up to 100 test cases. | Hard9 | CombinatoricsDynamic programming+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 |
| The HalfwittersFor each start permutation, compute the minimum expected time to reach the identity order using adjacent swaps (cost a), a full reversal (cost b), or a random reshuffle (cost c). | Hard9 | Dynamic programmingGraph+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Help Yourself (Platinum)Sum the K-th power of the number of connected components of the union over all 2^N subsets of N intervals, modulo 1e9+7. | Hard9 | CombinatoricsDynamic programming+2 | No attempts yet | 2s | 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 |
| ExerciseGiven N and prime M, compute modulo M the product over all N! permutations of the order (number of iterations until identity) of each permutation. | Hard9 | CombinatoricsNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cow ExerciseGiven N and prime M, sum every positive integer K for which some permutation of length N has order K, then output the sum modulo M. | Hard9 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Deja VuMaintain an array under point updates and answer queries asking for the earliest position d that ends an increasing subsequence of length 4 starting at or after l. | Hard9 | Segment treeDynamic programming+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Yet Another Problem on EmpodiaCount, for each length i up to N, the number of equivalence classes of permutations of length i under the relation that agrees on which intervals are framed (max minus min equals length minus one), modulo a prime. | Hard9 | CombinatoricsDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree Average WeightGiven a degree sequence with some free entries, pick a labeled tree uniformly at random and find the integer part of its expected weight, where weight sums u*sz(u)+v*sz(v) over edges. | Hard9 | CombinatoricsTree+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Counting Different SummandsSum f(a) over all ordered partitions of n into m positive parts, where f counts distinct part values, modulo 998244353, with n up to 1e18 and m up to 500. | Hard9 | CombinatoricsMath+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Chiaki Sequence RevisitedSum the first n terms of the self-referential Chiaki sequence, where each term depends on earlier terms via a_{n-a_{n-1}} + a_{n-1-a_{n-2}}, modulo 1e9+7. | Hard9 | MathCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Good GameCount monotone lattice paths in n dimensions from the origin to a target, avoiding m forbidden points, modulo 1e9+7. | Hard9 | CombinatoricsDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| DoublindromesCount distinct substrings of s that are palindromes and split into two non-empty palindromes, with length at least k. | Hard9 | StringString matching+2 | No attempts yet | 3s | 512 MB | Judgeable |
| TaxiSum over all ways to place M taxis and M customers on a weighted tree of the maximum-weight perfect matching cost, modulo 1e9+7. | Hard9 | TreeDynamic programming+2 | No attempts yet | 1.5s | 256 MB | Judgeable |
| Nice NumbersCount numbers in [L, R] that are pandigital (a permutation of all digits) in some base d, modulo 998244353, with L and R up to 5000-digit integers. | Hard9 | CombinatoricsNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Master Zhu and the LeaperCount monotone leaper paths from (1,1) to (n,m) on a huge board with at most 100 blocked cells, modulo 110119. | Hard9 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Power of XORGiven n integers, compute the sum over all 2^n subsets of the k-th power of the popcount of the XOR of the subset, modulo 1e9+7. | Hard9 | Bit manipulationMath+2 | No attempts yet | 6s | 512 MB | Judgeable |
| JokeGiven a text and up to ten patterns with per-letter erasure costs, delete letters so that no pattern occurs, minimizing total cost. | Hard9 | String matchingDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| EarthquakeEach route is usable only if all its bridges survive; pick an adaptive inspection order of bridges to minimize the expected number of inspections before deciding whether any route connects the two lands. | Hard9 | ProbabilityDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Flip a CoinTwo players each pick a heads/tails string of length up to 20; a fair coin is flipped until one or both strings appear, and we must output the probabilities of Alice winning, Bob winning, and a tie. | Hard9 | ProbabilityDynamic programming+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Ascent Sequences Avoiding Pattern 201Count ascent sequences of length n that avoid the pattern 201, modulo a prime p, with n up to 500. | Hard9 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Maximum FlowGiven two paths of n vertices each plus 2n+1 cross edges with huge capacities, find the max flow from (0,0) to (1,n). | Hard9 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Less Time, More ProfitChoose a subset of plants to build; a shop pays off only when every plant it needs is built. Minimize the maximum build time, then maximize profit within that time. | Hard9 | Dynamic programmingGraph+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Pet TreeCount assignments of edge lengths (each within its own interval) to a tree's edges so the resulting tree diameter falls between S and E, modulo 1e9+7. | Hard9 | Dynamic programmingTree+2 | No attempts yet | 8s | 1024 MB | Judgeable |
| Human ErrorGiven a grid of Justin and Donald pieces where each turn a player must capture an adjacent piece, and each player may restrict their candidate moves to a set of fixed size, compute Justin's win probability under optimal play with random move choice. | Hard9 | Game theoryBit manipulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Wrong AnswerConstruct a cost matrix that makes a greedy two-character solution as far from optimal as possible, maximizing the ratio of its output to the true minimum. | Hard9 | GreedyDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| AtomsMaintain a sequence of charges under range add updates, and after restricting to a query segment, report the longest run of consecutive positions where each next charge exceeds the previous by exactly one. | Hard9 | Segment treeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Fibonacci Digit CountCount occurrences of the substring "11" within the first N characters of the infinite string formed by writing 1, 2, 3, ... in Fibonacci (Zeckendorf) representation. | Hard9 | MathDynamic programming+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| LogoGiven up to five polyomino patch shapes (each a subset of a 3x3 grid, flippable and rotatable) and up to three grid designs up to 55x5, decide if each design can be tiled exactly by non-overlapping patches and find the minimum patch count, or report NIE. | Hard10 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| HyperrectangleCompute d!V for the volume of a box with side lengths li where sum xi <= s via characteristic polynomials and Lenstra inclusion of capped orthants. | Hard10 | MathDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |