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,786 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| 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 |
| TteokpireCount the number of ways to write N as an ordered sequence of one or more positive integers; equivalently, count compositions of N, modulo 1e9+7, for N up to 1e12. | Hard9 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cryptarithm?!Given three letter strings A+B=C, decide whether some assignment of distinct digits to letters makes the addition valid, columns up to 18 long. | Hard9 | BacktrackingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FlippingCount initial black/white colorings of an N by M grid that can reach the given coloring when a press inverts the whole monochromatic connected component containing that cell, modulo 1e9+7. | Hard9 | GraphUnion-find+2 | No attempts yet | 5s | 256 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 |
| BuildingsCount the distinct houses formed by placing m walls of n by n colored squares around an m-gon, up to rotation, modulo 1e9+7. | Hard9 | CombinatoricsMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Black ChainGiven a chain of n rings (up to 10^18), find the fewest rings to open so the resulting pieces can be combined into every weight from 1 to n. | Hard9 | GreedyCombinatorics+2 | No attempts yet | 0.1s | 512 MB | Judgeable |
| Prime Tree - 6Assign labels 1 to n to tree vertices so that edges joining two numbers with a shared factor are as few as possible. | Hard9 | GraphGreedy+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Prime Tree - 10Relabel the vertices of a given tree with 1..n so that as few edges as possible join two labels sharing a common divisor; this is an output-only optimization task. | Hard9 | Number theoryGreedy+2 | No attempts yet | 10s | 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 |
| Odd ColouringCount black/white ball colorings under cycle-index and Hadamard identities with large R, C, N, returning the count modulo 998244353. | Hard9 | MathCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Decorator CubeloverArrange n decorations on an n^3-cycle so each window of three labels is unique and the positional-value sum is minimal; report the nth digit of p-1. | Hard9 | CombinatoricsMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| SquareFreeGiven n up to 10^18, find the n-th squarefree positive integer using Mobius inversion and binary search. | Hard9 | MathNumber theory+2 | No attempts yet | 5s | 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 |
| Youngkwail Club RoomCover all '.' cells of a grid with 1x1 and 1x2 tiles, avoiding 'X' pillars, using the fewest tiles possible. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 256 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 |
| Quarry GameEach of N piles is a run of M consecutive pile sizes starting at X; a move takes at least one stone from one pile. Decide the winner under optimal play. | Hard9 | Game theoryMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| XOR SequencesCount, modulo 1e9+7, the ordered sequences of n distinct m-bit integers consistent with a given nearest-XOR-label map over all 2^m query values. | Hard9 | Bit manipulationDivide and conquer+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 |
| 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 |
| Sweet and SourChoose which Candy Country players drink a potion that randomizes their sweetness and sourness, maximizing Candy's expected match points under all random player orders and event coin flips. | Hard9 | ProbabilityCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Africa 2Submit code that matches the judge on exactly half its hidden test cases while passing the sample, a problem about exploiting judge behavior rather than a computable answer. | Hard9 | ImplementationBrute force+2 | No attempts yet | 1.357s | 1357 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 |
| Gosu 2Given a tournament on N players, find a transitive subtournament (chain) of size exactly 1 + floor(log2 N). | Hard9 | Divide and conquerCombinatorics+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Hanging RackGiven a binary hanging rack with 2^n hooks, find the hook number (mod 1e9+7) used on the k-th step when coats are hung to keep every rod balanced within 0 or 1. | Hard9 | MathRecursion+2 | No attempts yet | 1s | 512 MB | Judgeable |
| RulerFind the shortest ruler with N marks (0 to L) where all pairwise distances between marks are distinct, and print the mark positions. | Hard9 | BacktrackingBrute force+2 | No attempts yet | 2s | 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 |
| MessengerDesign strategies for two players who alternately move a piece on a 4x4 grid, knowing neither the call order nor its timing, so B can deduce the secret value X within 10000 moves. | Hard9 | ImplementationSimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ConstellationCount the ways to assign each unlabeled point to constellation A or B so that the two vertex sets can be drawn connected with mutually non-crossing segments. | Hard9 | GeometryCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Graph and CyclesGiven a weighted complete graph on an odd number of vertices, partition all edges into edge-disjoint cycles and minimize the sum over each cycle of the max weight on consecutive edge pairs. | Hard9 | GraphGreedy+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Nearest PointsCount the integer lattice points in an axis-aligned rectangle whose Euclidean distance to p1 is the minimum among K marked points. | Hard9 | GeometryDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| DivModuloCompute C(M,N) after removing every factor of D, and report the remainder modulo D, for M up to 4e18 and D up to 1.6e7. | Hard9 | MathNumber theory+2 | No attempts yet | 3s | 1024 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 |
| 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 |
| Graph CountingCount, modulo 998244353, the non-isomorphic undirected graphs on 2n vertices that have no perfect matching but lose that property when any missing edge is added. | Hard9 | CombinatoricsGraph+2 | No attempts yet | 5s | 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 |
| Bitwise XorCount non-empty subsequences in which the pairwise xor of every two chosen elements is at least x, modulo 998244353. | Hard9 | Bit manipulationTrie+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Another Coin Weighing PuzzleGiven m weighings and k coins per bag, find the maximum number of bags whose unique heavy bag can be identified, modulo 998244353. | Hard9 | CombinatoricsMath+2 | No attempts yet | 1s | 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 |
| 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 |
| Basis ChangeGiven one linear recurrence with coefficients a_i, find the unique recurrence with prescribed lags b_i that every sequence satisfying the first also satisfies. | Hard9 | MathImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Modulo-magic squaresCount n x n matrices over Z_m whose row, column, and two diagonal sums are all congruent to one constant, for n and m up to 1e9. | Hard9 | MathCombinatorics+2 | No attempts yet | 1s | 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 |
| FarawayCount lattice points (xe, ye) in [0, m]^2 such that for each of up to 10 constraints, (|xi - xe| + |yi - ye|) mod ki equals ti, with ki at most 5 and m up to 1e9. | Hard9 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Decimal ExpansionFor each query n up to 10^18, find the n-th digit after the decimal point of the infinite product (9/10)(99/100)(999/1000)... | Hard9 | MathNumber theory+2 | No attempts yet | 1s | 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 |
| IneqGiven a finite set S of integer lattice points, decide whether S can be cut out as exactly the integer points lying strictly below every line of some finite family of half-planes. | Hard9 | GeometryMath+2 | No attempts yet | 2s | 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 |
| Laser IntensificationFind probability p so that one photon entering the lower-left of a w by h grid, with nodes independently faulty with probability 1-p except n known faulty cells, yields k photons in expectation at the upper-right; print -1 if impossible. | Hard9 | MathCombinatorics+2 | No attempts yet | 2s | 64 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 |
| Curious Ball GameFor each query (N, M), find the M-th smallest bag size A such that drawing two balls gives probability exactly 1/N^2 that at least one is not red, outputting A and B mod 1e9+7. | Hard9 | Number theoryMath+2 | No attempts yet | 0.5s | 256 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 |
| Continue the SequenceGiven n values, extend the sequence by m terms so that it agrees with a polynomial of the smallest possible degree modulo 998244353. | Hard9 | MathNumber theory+2 | No attempts yet | 4s | 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 |
| RMQ Similar SequenceGiven sequence A, count the expected sum of a random real sequence B in [0,1] that has identical RMQ answers to A for every subarray, modulo 1e9+7. | Hard9 | TreeCombinatorics+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Rikka with Proper FractionsCount reduced proper fractions e/f with f at most n lying between two given fractions a/b and c/d, answering modulo 998244353. | Hard9 | Number theoryMath+2 | No attempts yet | 10s | 512 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 |
| 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 |
| CandiesFor each query k, count modulo 2 the pairs (child, candy kind) where buying only her favorite candy at that price leaves exactly k dollars. | Hard9 | Number theoryMath+2 | No attempts yet | 1s | 512 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 |
| Array ChallengeGiven a linear recurrence h and closed-form arrays b and a, compute floor(sqrt(a_n)) modulo 1e9+7 for n up to 1e15. | Hard9 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Master Zhu and CandiesGiven n candy heaps, players may remove any positive number from one heap or split one heap into three non-empty heaps; decide the winner under optimal play. | Hard9 | Game theoryMath+2 | No attempts yet | 3s | 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 |
| Random PointsGiven n points in general position, output 2^n times the expected number of vertices of the convex hull of a uniformly random subset, modulo 1e9+7. | Hard9 | GeometryCombinatorics+2 | No attempts yet | 5s | 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 |
| 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 |
| Airport Check-inEach counter has a random per-passenger time and a random remaining time for the current passenger; find the probability that the counter finishing first is also the one with the smallest per-passenger time. | Hard9 | ProbabilityMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Window XORApply the operation that replaces each element with the XOR of K consecutive elements (cyclically) exactly T times, where T can be as large as 10^18. | Hard9 | MathBit manipulation+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| K-th StringCount permutations t of n distinct letters whose k-th smallest non-empty substring equals s, modulo 1e9+7. | Hard9 | StringCombinatorics+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 |
| Connected Spanning SubgraphGiven a connected undirected graph, count the non-empty edge subsets whose chosen edges form a connected spanning subgraph, and print the count modulo 2. | Hard9 | GraphCombinatorics+2 | No attempts yet | 1s | 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 |
| IslandGiven the edge list of a tree whose N leaves are towns and whose internal nodes all have degree at least 3, count the distinct circular orderings of the leaves realizable as the outer face, and print the count as a product of prime powers. | Hard9 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fermat's Last TheoremOrder all positive quadruples (a,b,c,n) with n>=3 by max element then lexicographically, and print the sign of a^n+b^n compared to c^n for positions l through r. | Hard9 | MathCombinatorics+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 |
| f and gCompute g(T,k)=sum_{x=0}^{T} sum_i (x+a_i)^k mod 1e9+7 for every k from 0 to K, given N up to 1e5, K up to 5e4, T up to 1e18. | Hard10 | MathCombinatorics+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Find Marble Positions and VelocitiesReconstruct each marble's starting x-coordinate and constant velocity from N+1 unordered snapshots of N linearly moving marbles. | Hard10 | MathCombinatorics+2 | No attempts yet | 2s | 128 MB | Judgeable |
| CubesCount the orbits of general-purpose chip placements on cube faces under face rotations and cube rearrangement, given a fixed pattern of encoding chips. | Hard10 | CombinatoricsMath+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 |