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 |
|---|---|---|---|---|---|---|
| Counting four cyclesCount ordered 4-vertex cycles in an undirected graph given as an N by N adjacency matrix with N up to 250. | Medium5 | GraphCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Dreary DesignCount RGB triples with components from 0 to K whose largest pairwise difference is at most V. | Medium5 | CombinatoricsMath | No attempts yet | 5s | 512 MB | Judgeable |
| Password Attacker (Large)Count length-N strings over M symbols that use every symbol at least once, modulo 1e9+7. | Medium5 | CombinatoricsMath | No attempts yet | 5s | 512 MB | Judgeable |
| Parentheses Order (Small)Print the k-th valid parentheses string of n pairs in lexicographic order for each test case, or report that it does not exist. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 5s | 512 MB | Judgeable |
| Parentheses Order (Large)Given n and k, output the k-th valid parentheses string of n pairs in lexicographic order, or Doesn't Exist! when fewer than k exist. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Trie Sharding (Small)Split up to 8 strings across labeled servers to maximize the summed trie node counts and count the optimal splits. | Medium5 | Brute forceTrie+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Consonants (Large)Count the substrings of each given name that contain at least n consecutive consonants. | Medium5 | StringCombinatorics | No attempts yet | 5s | 512 MB | Judgeable |
| Arithmetic Digit Numbers 2Count the integers from 1 to N, with N up to 10^18, whose decimal digits form an arithmetic sequence. | Medium5 | BacktrackingCombinatorics+1 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Handing out candiesFor every K, count the ways to choose one candy of each brand 1 through K, and print the total over all K. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 2s | 512 MB | Judgeable |
| Trees and Path Lengths 2Find leaf counts p, q, r on a fixed 4-vertex path so the tree has exactly S length-3 paths, minimizing N then (p,q,r). | Medium5 | MathImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| pqrCount index triples p<q<r whose product A[p]*A[q]*A[r] is divisible by K, for N up to 2000. | Medium5 | CombinatoricsNumber theory+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Counting Music ScoresCount scores over two pitches and two durations with n seconds total, balanced pitch counts, at least as many long notes as short, and alternating pitches starting low. | Medium5 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct rational numbersCount distinct values of a/b with 0 <= a <= b <= N, i.e. fractions in [0,1] with reduced denominator at most N. | Medium5 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WindowPick a uniformly random axis-aligned subrectangle of an H by W grid; find the expected number of cells times 9, modulo 1e9+7. | Medium5 | MathCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Lucky TicketsCount digit strings of length 2N whose first N digits sum to the same value as the last N digits, modulo 1e9+7. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| EcologyCompute the probability that exactly M of N birds wear a tracker after D days of catching C random birds each day. | Medium5 | Dynamic programmingProbability+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Fibonacci ChickenGiven N, split it into Fibonacci-derived (people, chicken) pairs whose people counts sum to N, and report the minimum and maximum total chickens. | Medium5 | Dynamic programmingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hamming EllipsesCount words of length n over a q-symbol alphabet whose Hamming distances to two given words sum to exactly D. | Medium5 | CombinatoricsMath+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Fleecing the RaffleAdd k slips with your name to a box of n slips so the chance your name is drawn exactly once among p draws is maximized. | Medium5 | MathCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Jewelry StoreWith unlimited gems of each of N kinds, list all total values obtainable by choosing exactly K gems. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 5s | 512 MB | Judgeable |
| Winner of the Bubble GameTwo players alternately swap adjacent out-of-order pairs until the permutation is sorted; the one who cannot move loses. Decide the winner. | Medium5 | CombinatoricsGame theory+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Sum Decomposition 2Count ordered K-tuples of integers between 0 and N whose sum is N, modulo 1,000,000,000. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Good Positions in a PermutationCount permutations of 1..N whose number of positions i with |P_i - i| = 1 equals a given K, modulo 1e9+7. | Medium5 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| LettersGiven index i, return the uppercase letter at position i in the concatenation of all uppercase strings ordered by length then lexicographically. | Medium5 | CombinatoricsMath | No attempts yet | 0.2s | 256 MB | Judgeable |
| m-ary PartitionsCount the partitions of n into powers of m, for up to 1000 queries with n up to 10000. | Medium5 | Dynamic programmingMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PasswordCount n-digit strings over 0-9 that contain every one of the m given digits at least once. | Medium5 | CombinatoricsMath | No attempts yet | 1s | 64 MB | Judgeable |
| Binomial coefficient queriesGiven M pairs N and K, print the binomial coefficient C(N, K) modulo 1,000,000,007. | Medium5 | CombinatoricsMath+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Cities and StatesGiven up to 200,000 cities with names and two-letter state codes, count unordered pairs whose first two name letters match the other city's state code and vice versa, with different states. | Medium5 | Hash mapString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Vote (Large)Given N supporters of A and M of B in random arrival order, find the probability A leads after every vote; a ballot-problem computation. | Medium5 | CombinatoricsProbability+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Codejamon Cipher (Small)For each enciphered string, count the sentences of vocabulary words whose letter multisets concatenate to it, modulo 1e9+7. | Medium5 | Dynamic programmingHash map+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Sherlock and Parentheses (Small)Given L left and R right parentheses, arrange all of them to maximize the count of balanced non-empty substrings, counted by position. | Medium5 | GreedyMath+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Slides! (Small)Given B up to 6 and M up to 20, decide if exactly M paths from building 1 to B exist, and print the fixed-rule matrix when possible. | Medium5 | CombinatoricsDynamic programming+1 | No attempts yet | 5s | 512 MB | Judgeable |
| What Is Dynamic Programming?Count paths from the top-left cell to the bottom-right cell of an n by m grid when each step moves right, down, or diagonally down-right, printed modulo 1e9+7. | Medium5 | Dynamic programmingMatrix+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Tiling a 2 by N wallCount the ways to tile a 2 by N wall with 2x1, 1x2, and 1x1 tiles, modulo 1e9+7. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 2s | 512 MB | Judgeable |
| DespojadosCount the divisors of N that are squarefree and have at least two prime factors. | Medium5 | Number theoryCombinatorics+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| TilingCount the ways to tile a 3 by W rectangle with 2 by 1 dominoes, printing the result modulo 1e9+7. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Birthday CakeGiven up to 50 candle points and up to 15 cuts, decide whether the cuts carve the cake so that every resulting piece holds exactly one candle. | Medium5 | GeometryBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Counting a^i b^j c^k subsequencesCount subsequences of a string of a, b, c that read as some positive number of a's, then b's, then c's, modulo 1e9+7. | Medium5 | Dynamic programmingString+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Xayahh-Rakann at Moloco (Hard)Given n jars with m inseparable pairs, decide whether exactly k jars can be placed in one building so that no inseparable pair is split across the two buildings. | Medium5 | GraphUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| DunglishGiven a Dutch sentence and per-word dictionary options marked correct or incorrect, output the unique translation and its status, or counts of correct and incorrect translations. | Medium5 | ImplementationMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Drain PipesCount the number of ways to pick quantities of each pipe type, within the given stock, so the chosen pipes sum to exactly x. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Uks Is an Apple Fan!!Count the number of paths on an N by M grid where each cell directs movement right, down, or both, and every path must end at cell (N, M). | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| 1, 2, 3 Sum 5Count the ordered sums of 1, 2, and 3 that add to n, with no equal value adjacent, modulo 1,000,000,009. | Medium5 | Dynamic programmingMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 1, 2, 3 Addition 7Count ordered compositions of n into exactly m parts, where each part is 1, 2, or 3, modulo 1,000,000,009. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 0.25s | 512 MB | Judgeable |
| Adding 1, 2, 3 (9)Count ordered compositions of n into parts 1, 2, and 3 that use at most m terms, and output each count modulo 1,000,000,009. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Magic WeaponCount triples of details, one per color, where the red number's first and last digits match the green's last digit and the blue's first digit, and all three model numbers differ. | Medium5 | CombinatoricsMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Building a Symmetric StairGiven n unit cubes, build a symmetric stair (Ferrers diagram symmetric across the diagonal) using all n cubes, or report it is impossible. | Medium5 | MathImplementation+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Making the Number NCount how many digit-by-digit sequences build the number N when each new digit is attached to the left or right end. | Medium5 | Dynamic programmingString+2 | No attempts yet | 1s | 256 MB | Judgeable |
| League of Legends (Large)Count the sequences of skills A (1 second) and B (M seconds) that fill exactly N seconds with no idle time, modulo 1e9+7. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Tribal WarGiven N tribes where listed pairs are allied and all other pairs are hostile, count the number of triples that are all allied or all hostile. | Medium5 | CombinatoricsMath+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Code WordCount length-l digit sequences on an r by c grid where no two consecutive presses are orthogonally or diagonally adjacent, mod 1e9+7. | Medium5 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Summer TripGiven a string of event types, count contiguous substrings of length at least two whose first and last characters are distinct and each appears only once in the substring. | Medium5 | StringTwo pointers+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Rainbow StringsCount subsequences of a string in which no letter repeats, distinguishing them by position, modulo 11092019. | Medium5 | Dynamic programmingMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Managing DifficultiesCount triples of increasing indices i < j < k where a[j] - a[i] equals a[k] - a[j], so a[i] + a[k] = 2*a[j]. | Medium5 | Hash mapCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Big ChangesOn N labeled cities, count the spanning trees whose maximum degree is as large as possible, i.e. the star trees. | Medium5 | CombinatoricsTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Number Baseball FGuess a secret N-digit number with distinct digits by asking strike/ball queries, for up to 5040 games. | Medium5 | Brute forceImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Stacking Blocks TogetherEach of N students offers a set of distinct block sizes, at most one block per student is used, and we count subsets of students whose chosen blocks sum to exactly H modulo 10007. | Medium5 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| BinomialGiven a sequence, count ordered pairs (i, j) where the binomial coefficient C(a_i, a_j) is odd, using the Lucas theorem bit condition. | Medium5 | CombinatoricsBit manipulation+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Keep On MovinGiven counts of several character types, split all characters into palindromic strings so that the shortest palindrome is as long as possible. | Medium5 | GreedyMath+2 | No attempts yet | 1s | 64 MB | Judgeable |
| MountainsCount triples x < y < z where the middle mountain y is strictly taller than both mountain x and mountain z. | Medium5 | ArrayCombinatorics+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Mysterious EquationCount ordered pairs of non-negative integers (x, y) with x + y + xy = n, where n can be as large as 10^9. | Medium5 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| BarbellsSplit the weights 1 through n into three groups of equal total weight, or report that no such split exists. | Medium5 | MathGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Decreasing NumberGiven N, find the N-th smallest non-negative integer whose digits strictly decrease from left to right, or output -1 if none exists. | Medium6 | CombinatoricsGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Park Seongwon's ProbabilityCount permutations of up to 15 numbers whose concatenation is divisible by K, and output the probability as a reduced fraction. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Card Organization 1Each box lists counts per card color; find the minimum number of box-to-box transfers so at most one mixed box remains and every other color sits in a single box. | Medium6 | GreedyImplementation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Zigzag LineupCount permutations of N distinct heights where adjacent comparisons strictly alternate, modulo 1,000,000. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Student ShuffleCount permutations of up to 16 students so that every pair of adjacent heights differs by more than a given value K. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Code CollectionGiven N possible codes and target K distinct codes, compute the expected number of independent uniform draws needed to collect at least K distinct codes, with N up to 10^18. | Medium6 | ProbabilityMath+1 | No attempts yet | 2s | 256 MB | Judgeable |
| NMKConstruct a permutation of 1..N whose longest increasing subsequence is exactly M and longest decreasing subsequence is exactly K, or report impossible. | Medium6 | CombinatoricsGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Christmas TreeCount the ways to decorate an N-level tree where level k needs k ornaments split evenly among chosen colors, given limited red, green and blue ornaments. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Problem AssignmentGiven an N x N matrix of student-problem times, find the minimum-cost perfect matching assigning one distinct problem to each student. | Medium6 | Dynamic programmingGraph+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Restricted PermutationsCount permutations of 1..N where every element differs from its index by at most K, using a bitmask DP over a sliding window. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| TheaterConstruct the longest sequence of distinct nonempty actor subsets where consecutive scenes differ by exactly one actor and the play starts and ends with a single actor. | Medium6 | Bit manipulationCombinatorics+2 | No attempts yet | 2s | 128 MB | Judgeable |
| PokerCompute the exact probability of each of 12 six-card poker hand rankings, including custom back straight and royal straight flush definitions, as reduced fractions. | Medium6 | CombinatoricsBrute force+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Guitar ChordGiven each guitar string's open note and a target chord, choose which chord note each string plays to minimize the pressed-fret range needed to cover all chord notes. | Medium6 | MathGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| CandyGiven candy prices, count the distinct ways to pick a multiset of candies whose price sum is a prime number. | Medium6 | Dynamic programmingNumber theory+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Counting Divisible NumbersCount integers in a range that are divisible by at least one element of a given array using inclusion-exclusion over subsets and LCM. | Medium6 | CombinatoricsMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Anti-PalindromeRearrange all characters of a string to form the lexicographically smallest anti-palindrome, where each pair of symmetric positions must differ, or report impossible. | Medium6 | GreedyString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Making PrimesCombine all N (up to 6) given numbers with +,-,*,/ and parentheses in every possible way to find the smallest and largest prime value obtainable. | Medium6 | BacktrackingBrute force+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tree EncodingGiven N and an index, find the k-th lexicographically smallest preorder traversal string among all binary search trees built from the first N letters, using Catalan number counting. | Medium6 | CombinatoricsMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Sequences of 1 and -1Given M sequences of 1 and -1 of even length N, construct for each one a partner sequence whose elementwise product sums to zero, using at most N distinct partner sequences overall. | Medium6 | CombinatoricsPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tiling a GridCount the ways to fully tile an N by M grid (N, M up to 14) with 2x1 dominoes, modulo 9901. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Resident Registration NumberGiven a 19-digit ID pattern with some digits erased, count completions that form a valid birth date and satisfy the modular checksum rule for the last digit. | Medium6 | CombinatoricsMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tile CodesCount distinct tilings of a 2xN board using 1x2, 2x1, and 2x2 tiles, where mirror-image tilings under left-right flip count as one. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Count Selections with GCD 1Given up to 50 integers, count non-empty subsets whose greatest common divisor equals 1, modulo 10,000,003. | Medium6 | Number theoryCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Mirror NumbersCount how many numbers between A and B (up to 10^18) read the same when reflected in a mirror, using only digits 0,1,2,5,8 with 2 and 5 swapped. | Medium6 | CombinatoricsString+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Counting Ordered Pairs with a Given GCDCount ordered pairs (x, y) with x <= a, y <= b and gcd(x, y) = d for up to 50,000 queries. | Medium6 | Number theoryMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Making a RectangleGiven up to 16 sticks, choose four disjoint groups forming two equal-length pairs of sides to maximize the rectangle's area, or return -1 if impossible. | Medium6 | Bit manipulationDynamic programming+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Partitioning for Fun and ProfitGiven m, n and k, output the k-th lexicographically smallest partition of m into n non-decreasing positive parts. | Medium6 | CombinatoricsDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Counting Full Binary TreesCount full binary trees with exactly n nodes and height exactly k, modulo 9901, using a height-bounded DP and subtraction trick. | Medium6 | Dynamic programmingTree+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Cow PizzaCount subsets of up to 20 toppings that avoid containing every topping of any given forbidden constraint set, using inclusion-exclusion or bitmask enumeration. | Medium6 | Bit manipulationCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Rock-Paper-ScissorsCompute, as a reduced fraction, the probability that Hangseung reaches K round wins before Dongju in at most N rounds of rock-paper-scissors with ties possible. | Medium6 | Dynamic programmingProbability+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Trailing Zeros in a CombinationCompute the count of trailing zeros in C(n, m) for n up to 2 billion using prime factor exponents of 2 and 5 via Legendre's formula. | Medium6 | Number theoryMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Counting Grid TrianglesCount triangles with positive area formed by choosing three distinct lattice points from an (N+1) by (M+1) grid. | Medium6 | CombinatoricsMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Baby Goat LineupGiven binary labels A through B, find the X-th label when ordered first by popcount then by numeric value. | Medium6 | CombinatoricsBit manipulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Degree SequenceGiven a target degree sequence for N vertices, construct any simple graph's adjacency matrix matching it exactly, or report impossibility. | Medium6 | GreedyGraph+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Number of MultisetsGiven multiplicities of values from 1 to T among A numbers, count multisets of size K for S≤K≤B modulo 1,000,000. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Cactus GraphGiven a graph described by edge-paths, verify it is a cactus and count connected spanning subgraphs that remain cactus graphs. | Medium6 | GraphDFS+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Find the K-th Pinary NumberGiven K up to 10^18, output the K-th smallest binary string with no leading zero and no two consecutive 1s, treated as a number by value order. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Circular NetworkGiven a cycle of N nodes and P path requests, choose a direction for each request to minimize the total number of distinct cycle edges converted. | Medium6 | GreedyBit manipulation+1 | No attempts yet | 2s | 128 MB | Judgeable |