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 |
|---|---|---|---|---|---|---|
| Tiling a 3-by-N WallCount the number of ways to tile a 3-by-N wall using 2x1 dominoes, for N up to 30. | Medium4 | Dynamic programmingCombinatorics | No attempts yet | 2s | 128 MB | Judgeable |
| Find the Binary NumberGiven N, L, and I, output the I-th binary string of length N (with at most L ones) in increasing numeric order. | Medium4 | CombinatoricsBinary search+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Color WheelCount the ways to choose K non-adjacent colors from N colors arranged in a circle, modulo 1,000,000,003. | Medium4 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Nondecreasing NumbersCount the number of n-digit strings (digits 0-9, leading zeros allowed) that are nondecreasing, for n up to 64 requiring big integers. | Medium4 | CombinatoricsMath | No attempts yet | 1s | 128 MB | Judgeable |
| Number of Points Visible from the OriginCount lattice points (x,y) with 0<=x,y<=N visible from the origin, meaning gcd(x,y)=1 or one coordinate is 0/1 edge case. | Medium4 | Number theoryMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| LottoCount n-element increasing subsequences from 1..m where each next number is at least double the previous, using combinatorics or DP. | Medium4 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Horizontal and Vertical PuzzleGiven 6 three-letter words, choose 3 as rows and 3 as columns so the grid's columns also match the remaining words, outputting the lexicographically smallest valid arrangement. | Medium4 | Brute forceString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Planet X3Given up to a million numbers, compute the sum over all pairs of the XOR of their values by counting set bits per bit position. | Medium4 | Bit manipulationMath+1 | No attempts yet | 1s | 192 MB | Judgeable |
| 4 and 7Given K, output the K-th smallest positive integer whose digits are only 4 or 7, using a binary-representation-like construction. | Medium4 | MathBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Leonardo's NotebookDetermine whether a given permutation of the alphabet can be expressed as some permutation applied twice (its functional square). | Medium4 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Expected AllowanceGiven n m-sided dice and a cutback k, compute the exact reduced fraction for the expected value of max(1, sum of dice - k). | Medium4 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Lagrange's Four-Square TheoremFor each input number, count the unordered ways to express it as a sum of one to four positive perfect squares. | Medium4 | Brute forceMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Pen CountsCount the number of triangles with integer side lengths summing to N, where rotations count as the same and reflections differ. | Medium4 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Suit DistributionFor each pair (a, b), compute the probability that the opponents' a+b cards of one suit split a and b between them. | Medium4 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BlackjackGiven n decks and three visible cards, compute the probability that the player's two-card hand beats the dealer's two-card hand. | Medium4 | MathCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Road ShopCount the number of ways to choose bead counts for n colors summing to r, with at least m beads of each color. | Medium4 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Hexagonal TilesCount the sequences of increasing tile numbers from the start tile to tile N, where each move goes forward by 1 or 2. | Medium4 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Make a GuessGiven MasterMind guesses and their excellent/good counts, decide for each position whether every consistent password shares the same character, else print '?'. | Medium4 | Brute forceImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| DartsCount unordered triples of dart hits (single, double, treble regions, bulls, or misses) whose scores sum to a given turn score. | Medium4 | Brute forceImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dairy QueenCount the number of ways to make N cents using unlimited coins of the given C denominations, ignoring order. | Medium4 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Barbara Bennett's Wild NumbersGiven a wild number W with digit and ? positions and a same-length number X, count the length-n digit strings matching W that are strictly greater than X. | Medium4 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Binomial ShowdownFor each pair (n, k), print the binomial coefficient C(n, k), stopping at the terminating pair 0 0. | Medium4 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| LottoFor each set of k numbers in ascending order, print all 6-element subsets in lexicographic order, separated by blank lines. | Medium4 | BacktrackingRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ParliamentSplit N delegates into groups of distinct sizes so that the product of the sizes is maximized, and print the sizes in ascending order. | Medium4 | MathGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Dart ChallengeFor each dartboard, count how many distinct total scores k darts can produce, where each dart misses or scores s_i, 2s_i, or 3s_i (no triple on the top area). | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| IndomieEach of the N people ahead takes a uniformly random remaining item among rice, sugar, and Indomie (Indomie limited to S). Find the probability Indomie remains for Felix, as a percentage. | Medium4 | ProbabilityCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sultan's LandGiven P pillars on an N by N grid, count how many sets of four pillars form the corners of an axis-aligned rectangle. | Medium4 | ArrayHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BalanceCount the orders and pan choices for placing n distinct weights so the left pan is never heavier than the right at any step. | Medium4 | Brute forceBacktracking+2 | No attempts yet | 2s | 128 MB | Judgeable |
| HandshakesCount the matchings of a path with n vertices, then print the last digit of that count. | Medium4 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Byteland LotteryGiven up to 10^6 ball labels, compute the digital root of the sum of products over all non-empty subsets. | Medium4 | MathNumber theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| HyperclockGiven the cycle sizes of N clocks, the tour visits every configuration once; its length is the number of configurations, the product of the sizes. | Medium4 | MathCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |
| CoinsCount the ways to place coins of sizes 1 to n into slots with capacities a_i so every coin fits, modulo 1000000007. | Medium4 | SortingCombinatorics+1 | No attempts yet | 1s | 512 MB | Judgeable |
| SoldiersCount the monotonic lineups of n distinguishable soldiers by height and output the last four digits of the count. | Medium4 | CombinatoricsMath+1 | No attempts yet | 1s | 512 MB | Judgeable |
| CoinsCount the unordered combinations of up to 20 coin values that sum to the target amount M. | Medium4 | Dynamic programmingCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |
| A Card TrickGiven five cards, pick the hidden card and the order of the other four to satisfy the decoding rule, choosing the lexicographically smallest arrangement. | Medium4 | Brute forceCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Lock Patterns and Spanning TreesCount the spanning trees of an m by m king-move grid for m up to 6 by evaluating a cofactor of its Laplacian matrix. | Medium4 | MatrixMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree ColoringCount colorings of an N-node tree with K colors so adjacent nodes differ, modulo 93563. | Medium4 | Dynamic programmingTree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sums of Distinct Natural NumbersCount the partitions of each given N into distinct positive integers, including N itself, modulo 100999. | Medium4 | Dynamic programmingCombinatorics | No attempts yet | 7s | 128 MB | Judgeable |
| Coding of PermutationsThe task gives a permutation of 1 to n and asks for its 1-based rank among all permutations in lexicographic order. | Medium4 | CombinatoricsMath | No attempts yet | 1s | 128 MB | Judgeable |
| HousingCount the unordered splits of n into parts of at least 5 for n between 5 and 100. | Medium4 | Dynamic programmingCombinatorics | No attempts yet | 2s | 512 MB | Judgeable |
| LexicalGiven n and a permutation of 0 to n-1, compute its 1-based position in lexicographic order. | Medium4 | CombinatoricsMath | No attempts yet | 2s | 1024 MB | Judgeable |
| Triangles made from linesCount how many triples of the given lines form a triangle by removing triples that contain parallel lines. | Medium4 | Hash mapCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bessie Goes MooCount assignments of listed values to seven variables that make (B+E+S+S+I+E)(G+O+E+S)(M+O+O) a multiple of 7. | Medium4 | MathBrute force+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Dormitory ReassignmentCount the permutations of N students to rooms in which no student keeps the same room. | Medium4 | CombinatoricsDynamic programming | No attempts yet | 1s | 128 MB | Judgeable |
| Binomial Coefficient 3Compute the binomial coefficient C(N, K) modulo 1,000,000,007 for N up to 4,000,000. | Medium4 | CombinatoricsNumber theory | No attempts yet | 1s | 256 MB | Judgeable |
| Polynomial GameFor each test case, compute the coefficient of x^N in the product of (1+x+...+x^i) for i from 1 to k. | Medium4 | Dynamic programmingCombinatorics | No attempts yet | 1s | 256 MB | Judgeable |
| Kitchen CombinatoricsCount compatible starter, main and dessert triples weighted by brand choices over shared ingredients, printing too many above 10^18. | Medium4 | Brute forceCombinatorics | No attempts yet | 4s | 256 MB | Judgeable |
| Star trianglesFor each star taken as the right-angle vertex, multiply the counts of other stars sharing its column and its row, then add the products. | Medium4 | Hash mapCombinatorics | No attempts yet | 2s | 256 MB | Judgeable |
| Collecting Stamps 2Insert one J, O, or I stamp at any position to maximize the number of triples that read J, O, I in order. | Medium4 | Prefix sumCombinatorics | No attempts yet | 2s | 256 MB | Judgeable |
| Password Attacker (Small)Count length-N strings over M given symbols that use every symbol at least once, modulo 1e9+7. | Medium4 | CombinatoricsMath | No attempts yet | 5s | 512 MB | Judgeable |
| Number card trickChoose the sorted N-number multiset bounded by M whose subset product counts give the largest posterior weight. | Medium4 | Brute forceCombinatorics | No attempts yet | 5s | 512 MB | Judgeable |
| Crop Triangles (Small)Count triples of generated tree points whose coordinate sums are divisible by 3 in both axes. | Medium4 | CombinatoricsNumber theory+1 | No attempts yet | 5s | 512 MB | Judgeable |
| CandySum 2^K over all subsets of N candies with K elements, where the empty subset contributes 0, modulo 1,000,000,007. | Medium4 | CombinatoricsMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree and paths of length twoDecide whether some tree on N nodes has exactly S simple paths of length 2. | Medium4 | TreeCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| ABCFind the lexicographically smallest length-N string over A, B, C that has exactly K pairs i < j with S[i] < S[j]. | Medium4 | GreedyCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| AB StringFind the length-N A/B string whose number of (A before B) pairs equals K, choosing the lexicographically smallest such string. | Medium4 | GreedyCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Partitioning a QueueCount compositions of n whose parts avoid the arithmetic progression m, m+k, m+2k, with n up to 30 and up to 10000 test cases. | Medium4 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Disposable CupGiven A, B, and N, find every total height achievable by stacking N cups, where same-facing neighbors add A and opposite-facing ones add A+B. | Medium4 | CombinatoricsMath | No attempts yet | 1s | 32 MB | Judgeable |
| CombinationsGiven up to 1000 pairs (n, k), compute the binomial coefficient C(n, k) modulo 10^9+7 for each pair. | Medium4 | CombinatoricsMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Drawing PebblesGiven pebble counts per color, compute the probability that K randomly drawn distinct pebbles all share one color, printed to 10 decimals. | Medium4 | CombinatoricsMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Minimum overtakesGiven a starting order and a finishing order of up to 24 cars, print the minimum number of adjacent swaps that turn the start into the finish. | Medium4 | SortingArray+1 | No attempts yet | 2s | 512 MB | Judgeable |
| HyperloopFor odd N, print (N-1)/2 Hamiltonian cycles on the complete graph of N cities that partition all edges, using the given seat-walk construction. | Medium4 | GreedyMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Packing snack sticksGiven n and m, decide whether an n by m grid can be tiled exactly with 3-cell straight bars and L trominoes that may be rotated. | Medium4 | MathGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Bovine Genomics (Silver)Count triples of genome positions where no spotty cow and plain cow share the same three characters. | Medium4 | Brute forceHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Pizza (Large)Split a tower of N into unit towers, scoring the product of the two parts at each split, and maximize the total score. | Medium4 | GreedyMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Multiples of three from 0, 1, and 2 (Large)Count N-digit numbers made only of the digits 0, 1, and 2 that are divisible by 3, with no leading zero, modulo 1e9+9. | Medium4 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Ample Syrup (Small)Choose K pancakes from at most 10 to stack largest radius on the bottom, maximizing the exposed surface area divided by pi. | Medium4 | Brute forceSorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Go Northwest!Given N distinct points, find the probability that two independently drawn points lie on a 45-degree diagonal from each other. | Medium4 | Hash mapMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Clever TitleFor each uppercase word, count how many orderings of the n author names let you pick one uppercase letter from each name, left to right, to spell the word. | Medium4 | BacktrackingBrute force+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Secret of Chocolate PolesCount sequences of dark and white chocolate disks, each 1 cm thick except dark thick disks at k cm, alternating colors, starting and ending dark, with total thickness at most l. | Medium4 | Dynamic programmingCombinatorics | No attempts yet | 1s | 512 MB | Judgeable |
| Counting equilateral trianglesGiven a triangular tower with N layers of unit triangles, count every equilateral triangle of any size, both upward and downward pointing. | Medium4 | MathCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| One, Two, Three Plus FourCount the number of unordered sums of 1, 2, and 3 that add up to a given n, for each test case. | Medium4 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Match PredictionGiven win/draw/loss probabilities for all six matches among four teams, compute each team's probability of finishing in the top two. | Medium4 | ProbabilityBrute force+2 | No attempts yet | 1s | 256 MB | Judgeable |
| CombinationCompute N choose R modulo 1,000,000,007 for 0 ≤ R ≤ N ≤ 1,000,000 using a prime modulus. | Medium4 | MathNumber theory+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Multiples of 3Count ordered triples of multiples of 3 that add to n, with n a multiple of 3 between 3 and 3000. | Medium4 | MathCombinatorics+1 | No attempts yet | 0.1s | 128 MB | Judgeable |
| Plate ParityCount integers in [A, B] whose rightmost nonzero digit is odd versus even, where A and B go up to 10^16. | Medium4 | MathImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Contest SettingCount the ways to choose k problems whose difficulties are all distinct, given n problems and their difficulty values, modulo 998,244,353. | Medium4 | MathCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Making Roman NumeralsCount how many distinct sums can be formed by choosing N characters from {I, V, X, L} with repetition, where order does not matter. | Medium4 | CombinatoricsMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Terraced fieldsCount how many digit characters are 6 or 8 in the decimal numbers written on steps divisible by 8 plus the final step n. | Medium4 | MathImplementation+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Jinwoo's PasswordGiven N and a lowercase password of length at most N, find its 1-based position among all strings of length 1 to N in lexicographic order. | Medium4 | StringMath+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Badugi PokerGiven six distinct cards, each with a number 1 to 15 and a color, sort all 15 pairs by the ranking rules and print the winner first. | Medium4 | SortingImplementation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Plane DivisionGiven at most N lines with slope -1, 0, or 1, find the maximum number of regions the plane can be divided into. | Medium4 | MathCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Viyott's Stepping Stone CrossingCount the ways to jump from stone 1 to stone N when each jump adds any positive integer, modulo 1e9+7. | Medium4 | MathCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Cow-abunga!Given at most 9 cow weights, choose M of them and print every prime number that appears as a subset sum, in increasing order. | Medium4 | Brute forceCombinatorics+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Isosceles trianglesCount the isosceles triangles whose three vertices are vertices of a regular n-gon, for n up to 1e9. | Medium4 | CombinatoricsMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Misha's ProductGiven n distinct integers, concatenate every ordered pair of them and report the sum of all these concatenations modulo 1e9+7. | Medium4 | MathArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Two MeasurementsCount pairs of hours i < j in [l, r] whose difference is a multiple of the rotation period a. | Medium4 | MathCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Expandable Beautiful TrianglesCount the RGB-colored triangles on an N by M grid that share two vertices with another RGB triangle of strictly larger area. | Medium5 | Brute forceGeometry+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tower Floor DisplayGiven an N-digit floor number shown on a lamp display where off lamps may be broken, compute the average of every floor number consistent with the lit lamps. | Medium5 | MathCombinatorics+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Decreasing NumbersGiven N, output the N-th smallest number whose decimal digits strictly decrease left to right, or -1 if it does not exist. | Medium5 | CombinatoricsMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| DictionaryConstruct the K-th lexicographically smallest string made of N 'a's and M 'z's using combinatorial counting, or report -1 if K exceeds the total count. | Medium5 | CombinatoricsGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Partial RectanglesGiven an N x M grid doubled into a 2N x 2M grid, count how many times each letter appears summed over every possible subrectangle. | Medium5 | CombinatoricsMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Sevi GameGiven one roll of five dice, pick at least two dice to reroll so the expected score of a poker-dice scoring system is minimized, with ties broken lexicographically. | Medium5 | ProbabilityBrute force+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Gap Pair SequenceConstruct the lexicographically smallest sequence where each number from a given set appears twice with exactly that many numbers between the two occurrences, or report -1 if impossible. | Medium5 | BacktrackingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Captain DasomGiven N cannonballs, find the minimum number of tetrahedral-number piles whose sizes sum exactly to N using unbounded coin-change style DP. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Summit Handshakes 2Given N seats around a round table, count the ways N representatives can pair up with non-crossing handshake segments, modulo 987654321. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Labels Without a Forbidden DigitGiven N and a forbidden digit L, find the N-th smallest positive integer whose decimal digits never contain L. | Medium5 | MathCombinatorics+2 | No attempts yet | 2s | 128 MB | Judgeable |
| TilingCount the number of ways to tile a 2×n rectangle using 2×1 and 2×2 tiles for multiple values of n up to 250. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sum of Numbers 6Given N and the bottom value of a Pascal-like sum triangle built from a permutation of 1..N, reconstruct the lexicographically smallest top row. | Medium5 | CombinatoricsBacktracking+2 | No attempts yet | 2s | 128 MB | Judgeable |
| ChariotsConstruct a permutation of size N avoiding both fixed positions on the two main diagonals, or report impossibility for small N. | Medium5 | CombinatoricsMath+1 | No attempts yet | 2s | 128 MB | Judgeable |