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,785 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Vera's FashionGiven N tops and N bottoms colored 1 to N, count how many top and bottom pairs have different colors.Easy1MathCombinatorics+1No attempts yet2s256 MBJudgeable
Time MachineGiven three two-digit numbers from a digital clock, count how many of the 6 permutations form a valid HH:MM:SS time.Easy2CombinatoricsBrute force+1No attempts yet2s128 MBJudgeable
DominoesGiven N, compute the total dot count across all unique dominoes with halves ranging from 0 to N.Easy2MathCombinatoricsNo attempts yet1s128 MBJudgeable
UnfriendCount the subsets of nodes in a rooted tree that can be removed, where removing a node forces removal of all its descendants.Easy2TreeBrute force+1No attempts yet2s512 MBJudgeable
What is n, Daddy?Count the ordered pairs (a, b) with 1 <= b <= a <= 5 and possibly a single hand, summing to n.Easy2MathBrute force+2No attempts yet2s512 MBJudgeable
Constrained PermutationsCount permutations of 1..n (n at most 9) that satisfy given ordering constraints x before y.Easy2Brute forceCombinatorics+2No attempts yet1s128 MBJudgeable
NumbersGiven three distinct digits and one of their six permutations, find that number's 1-based rank when all six permutations are sorted ascending.Easy2MathSorting+2No attempts yet1s1024 MBJudgeable
KamilGiven a word Kamil spoke, count the words he could have meant, since each position may map to one of several letters.Easy2MathCombinatorics+1No attempts yet1s128 MBJudgeable
Sums and DifferencesCount ordered pairs from distinct positions where the difference exceeds the sum, which holds exactly when the second element is negative.Easy2MathCombinatoricsNo attempts yet1s128 MBJudgeable
Binomial Coefficient 1Compute the binomial coefficient N choose K for given N up to 10 and K between 0 and N.Easy2CombinatoricsMathNo attempts yet1s256 MBJudgeable
Lazy Spelling Bee (Large)Count distinct words formed by picking each letter from its neighbors in the target word, modulo 1e9+7.Easy2CombinatoricsString+1No attempts yet5s512 MBJudgeable
Quake Live (Small2)Split the given players into two equal teams so the two skill totals differ as little as possible.Easy2Brute forceCombinatoricsNo attempts yet5s512 MBJudgeable
Tojaengi's Walk to SchoolCount monotone lattice paths from (1,1) to (w,h) that pass through a given shop, modulo 1000007.Easy2CombinatoricsMathNo attempts yet1s128 MBJudgeable
Card Game ContestFor each of N games, Meiji has A_i decks, or gets one basic deck if A_i is 0. Count the number of distinct ways to enter, modulo M.Easy2MathImplementation+2No attempts yet1s256 MBJudgeable
Boolean SatisfiabilityCount the assignments of a disjunction of single literals that make the formula true, where each variable takes true or false.Easy2CombinatoricsMath+2No attempts yet3s512 MBJudgeable
Pascal's TriangleGiven n and k with 1 <= k <= n <= 30, print the k-th entry of row n in Pascal's triangle, equal to C(n-1, k-1).Easy2MathCombinatorics+2No attempts yet1s256 MBJudgeable
Least Common Multiple of at Least Three NumbersGiven five distinct positive integers up to 100, find the smallest number divisible by at least three of them, essentially the minimum LCM over all triples.Easy3MathBrute force+2No attempts yet2s128 MBJudgeable
LotteryGiven N, M, K, compute the probability that two random M-subsets of 1..N share at least K numbers using the hypergeometric distribution.Easy3CombinatoricsMath+1No attempts yet2s128 MBJudgeable
Guitar ConcertGiven up to 10 guitars each covering a subset of up to 50 songs, find the minimum number of guitars needed to play the maximum possible number of songs.Easy3Bit manipulationBrute force+1No attempts yet2s128 MBJudgeable
Count Numbers Made Only of 4 and 7Count integers between A and B (up to 1e9) whose digits are all 4s and 7s.Easy3Brute forceCombinatorics+2No attempts yet2s128 MBJudgeable
Pinary NumbersCount binary strings of length N that start with 1 and have no two consecutive 1s, using Fibonacci-style counting with big integers up to N=90.Easy3Dynamic programmingMath+1No attempts yet2s128 MBJudgeable
Sum DecompositionCount ordered sequences of K integers from 0 to N whose sum equals N, modulo 1,000,000,000.Easy3Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
CombinationGiven n and m within 100, compute the exact value of the binomial coefficient C(n, m).Easy3MathCombinatorics+1No attempts yet2s128 MBJudgeable
Making Triangles with MatchsticksGiven n identical matchsticks, count the number of non-congruent integer-sided triangles whose perimeter equals n.Easy3MathCombinatorics+1No attempts yet1s128 MBJudgeable
Polygon Diagonal IntersectionsGiven N, a convex N-gon with no three diagonals concurrent, compute the number of interior diagonal intersection points using the combinatorial formula C(N,4).Easy3CombinatoricsMathNo attempts yet1s128 MBJudgeable
Relax! It's Just a GameFor each score (A, B), check whether the binomial coefficient C(A+B, A) equals the sum A+B, and print the comparison.Easy3MathCombinatorics+2No attempts yet1s128 MBJudgeable
Really Good CompressionGiven N distinct 1000-bit files, decide whether each can be compressed to at most b bits.Easy3MathCombinatorics+2No attempts yet1s128 MBJudgeable
Commute RouteCount monotone east/north lattice paths from (1,1) to (a,b) that avoid n blocked intersections, with a and b at most 16.Easy3Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
World Cup NoiseFor each n below 45, count the n-bit strings that contain no two adjacent 1s, and print the result per scenario with a blank line between cases.Easy3Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Black and White PaintingCount the 8x8 blocks inside an n by m checkerboard whose bottom-right square is white, given the color of the painting's bottom-right corner.Easy3MathCombinatorics+2No attempts yet1s128 MBJudgeable
Paths on a GridCount monotone lattice paths from the lower-left to the upper-right of an n by m grid.Easy3CombinatoricsMathNo attempts yet1s128 MBJudgeable
Chances of WinningGiven results of some games among four teams, count the outcomes of the remaining games where team T ends with strictly more points than every other team.Easy3Brute forceImplementation+2No attempts yet1s128 MBJudgeable
Don't pass me the ball!Given the scorer's jersey number J, count the ordered increasing 4-tuples of distinct jersey numbers ending at J.Easy3CombinatoricsMathNo attempts yet2s512 MBJudgeable
Mouse JourneyCount monotone right/down paths on an R by C grid from (1,1) to (R,C) that avoid K blocked cat cells.Easy3Dynamic programmingMatrix+1No attempts yet2s512 MBJudgeable
MaternityGiven the two alleles each parent carries for five genes, decide for each baby whether its five visible traits could result from that pairing.Easy3ImplementationCombinatorics+2No attempts yet1s128 MBJudgeable
Skew BinaryConvert each decimal number into its unique skew binary representation, printed as the sorted ranks of its nonzero digits.Easy3MathGreedy+2No attempts yet1s128 MBJudgeable
Prehistoric Operating SystemsCount binary strings of length n with no two adjacent D's, where D means DOORS and O means any other brand, for up to 40 test values of n.Easy3Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Sequences without StammersPrint the smallest alphabet size for which a square-free (stammer-free) string of length n exists.Easy3StringCombinatorics+1No attempts yet3s128 MBJudgeable
PostcardCount the contiguous segments that keep at least one mountain of height m or more after trimming both ends.Easy3CombinatoricsArrayNo attempts yet1s512 MBJudgeable
Class PairingsCount the ways to split N students into pairs for each test case and print the result modulo 1000.Easy3CombinatoricsMathNo attempts yet1s128 MBJudgeable
EncodingCount binary strings of length n that start with 1 and contain no adjacent ones for up to 100 queries.Easy3Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
PasswordFind the K-th password in lexicographic order whose letters appear in the same column of both 6 by 5 grids, or print NO.Easy3CombinatoricsSorting+1No attempts yet1s128 MBJudgeable
Lexicographic rank of a permutationGiven a permutation of the letters a to h, print its 1-based position in lexicographic order.Easy3CombinatoricsMathNo attempts yet1s128 MBJudgeable
Counting non-decreasing digit sequencesCount length-N non-decreasing sequences of digits 0 to 9, modulo 1000000007, for each test case.Easy3CombinatoricsNumber theoryNo attempts yet1s128 MBJudgeable
Fashion King HaebinCount all nonempty outfits by picking at most one item from each clothing kind.Easy3CombinatoricsHash mapNo attempts yet1s128 MBJudgeable
Equal Sum SetsCount subsets of {1..n} with exactly k elements that sum to s for each dataset.Easy3Dynamic programmingCombinatoricsNo attempts yet3s128 MBJudgeable
PermutationGiven up to 10 distinct sorted characters and a 1-based position, print the permutation at that position or No permutation when it exceeds n!.Easy3CombinatoricsMathNo attempts yet5s128 MBJudgeable
Unlock My SafeThe program prints the sorted permutation of digits 1 to N at index floor(N factorial / 3) for each N.Easy3CombinatoricsSorting+1No attempts yet1s128 MBJudgeable
Recycling Bin AllocationFind the waste-to-bin assignment that needs the fewest bin changes across all surveyed cities.Easy3Brute forceCombinatoricsNo attempts yet1s128 MBJudgeable
One Number HintImplement two fixed rules over 6-element subsets of 1 to 12: output the smallest element in S(x) missing from S(y), and answer yes when h lies in S(q).Easy3CombinatoricsImplementationNo attempts yet1s256 MBJudgeable
Grid Path CountCount right-and-down paths from the top-left to the bottom-right corner that pass through a given cell, if one is specified.Easy3CombinatoricsDynamic programmingNo attempts yet1s256 MBJudgeable
Algebraic TeamworkFor each given n, count the permutations of n elements that are not idempotent modulo 1000000007.Easy3CombinatoricsMathNo attempts yet3s256 MBJudgeable
Tigger's bouncesCount length-K walks on an R by C grid where each step stays put or moves to a side neighbor, summed over all starts, modulo P per query.Easy3Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Valid Parenthesis CountCount the distinct correct parenthesis strings of length L for each test case, modulo 1000000007.Easy3CombinatoricsDynamic programming+1No attempts yet2s256 MBJudgeable
Bessie Gets EvenCount assignments of listed values to seven letters that make the product (B+E+S+S+I+E)(G+O+E+S)(M+O+O) even.Easy3Brute forceCombinatorics+1No attempts yet1s256 MBJudgeable
Binomial Coefficient 2Compute the binomial coefficient C(N, K) modulo 10007 for N up to 1000.Easy3Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Ascending NumbersCount length-N digit strings, leading zeros allowed, whose digits never decrease left to right, modulo 10007.Easy3Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Bobby's BetDecide whether a bet pays off by computing the binomial chance of rolling at least R on at least X of Y rolls and comparing it to the odds W.Easy3ProbabilityCombinatorics+1No attempts yet2s256 MBJudgeable
PIN Code PossibilitiesCount n-digit codes with leading zeros allowed whose digits add up to s for each test case.Easy3Dynamic programmingCombinatoricsNo attempts yet3s256 MBJudgeable
Safe ZoneCount the K-step walks on segments 0 to N-1 with forced turns at the ends that finish inside segments P to Q.Easy3Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Compositions Missing a SequenceCount the ordered compositions of n that use no part from the arithmetic progression starting at m with step k.Easy3Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Preparing a knapsack problemRead t up to 1e18 and print k = 300 with sixty 1s plus extra elements chosen by greedy binomial decomposition so exactly t subsets sum to 300.Easy3CombinatoricsImplementationNo attempts yet1s32 MBJudgeable
Younghoon the PranksterGiven a digit string where 1 and 6 are interchangeable and 2 and 7 are interchangeable, print its k-th candidate in lexicographic order or -1.Easy3CombinatoricsStringNo attempts yet1s128 MBJudgeable
Polynesiaglot (Small 1)Count length-L words over C consonants and V vowels in which each consonant is directly followed by a vowel, modulo 1000000007.Easy3Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
PolynesiaglotCount length-L strings over C consonants and V vowels with no adjacent consonants and no trailing consonant, modulo 1e9+7.Easy3Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Polynesiaglot (Large)Count length-L words over C consonants and V vowels where every consonant is followed by a vowel, modulo 1e9+7.Easy3Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Lazy Spelling Bee (Small)Count distinct words formed by replacing each letter with itself or an adjacent letter of the target word.Easy3CombinatoricsStringNo attempts yet5s512 MBJudgeable
PinocchioCount the ordered 4-tuples of distinct positions in S whose letters are A, C, G, T in some fixed assignment.Easy3CombinatoricsMathNo attempts yet2s512 MBJudgeable
ΣSum Si/Ni over M dice and print the result modulo the prime 1,000,000,007 using modular inverses.Easy3MathNumber theory+2No attempts yet1s512 MBJudgeable
DictionaryFor each of the given 9-letter permutations of a through i, report its 1-based rank in lexicographic order.Easy3CombinatoricsMath+1No attempts yet2s512 MBJudgeable
Secret SantaFor a uniformly random permutation of N names, compute the probability that at least one resident draws their own name, rounded to 8 decimals; N can reach 10^12.Easy3ProbabilityMath+2No attempts yet2s512 MBJudgeable
Recurrence sequenceCompute the n-th term of a self-convolution recurrence where t(n) sums t(i)*t(n-1-i) for i from 0 to n-1, with n up to 35.Easy3Dynamic programmingMath+2No attempts yet5s512 MBJudgeable
Vote (Small)Given N supporters of A and M of B, find the probability that A leads after every vote in a random arrival order.Easy3MathProbability+1No attempts yet5s512 MBJudgeable
Squares in a grid squareFor each grid side length l, count every square whose sides lie along grid lines, including tilted ones.Easy3MathCombinatorics+1No attempts yet2s512 MBJudgeable
What's Your Tier?Starting at 2000 points, play 20 games with given win, loss, and draw probabilities; compute the probability of ending in each of five tiers.Easy3ProbabilityDynamic programming+2No attempts yet2s256 MBJudgeable
Walking to Sincheon Station, Sam (Small)Count N-digit numbers using only digits 0, 1, 2 that are divisible by 3 and have no leading zero.Easy3MathBrute force+1No attempts yet2s256 MBJudgeable
Nemmo Nemmo (Easy)Count subsets of cells of an N by M grid, with N*M at most 25, that contain no full 2 by 2 square of chosen cells.Easy3Brute forceBit manipulation+2No attempts yet1s512 MBJudgeable
Sat DownGiven your two cards, count how many of the 18 choose 2 possible opponent hands you beat, and print the win probability to three decimals.Easy3Brute forceImplementation+2No attempts yet1s256 MBJudgeable
ElectionGiven N total votes, M counted votes split as V1 and V2, and a threshold W, decide if the probability that candidate 1 wins (when each remaining vote is a fair coin) exceeds W%.Easy3ProbabilityMath+2No attempts yet1s512 MBJudgeable
Counting Domino SpotsCompute the total number of spots over all distinct unordered pairs of mark values from 0 to N.Easy3MathCombinatoricsNo attempts yet2s512 MBJudgeable
N and M (2)Print all ascending sequences of M distinct numbers chosen from 1 to N, in lexicographic order.Easy3BacktrackingRecursion+1No attempts yet1s512 MBJudgeable
Sejin's Group DateGiven N men and M women (M <= N), count the number of M-element subsets of men that could be paired with the women, modulo 1000000007.Easy3CombinatoricsMath+2No attempts yet1s512 MBJudgeable
Sum of Subrectangle AreasFor each N, compute the total area of all axis-aligned integer subrectangles in an N by N grid.Easy3MathCombinatoricsNo attempts yet2s512 MBJudgeable
NadanSplit K into N distinct positive integers that sum to K, and print one such distribution.Easy3GreedyMath+2No attempts yet1s64 MBJudgeable
Multinomial CoefficientGiven exponents n and m and a power k, compute the coefficient of x^k in (1+x+...+x^n)^m modulo 1,000,000,009.Easy3Dynamic programmingCombinatoricsNo attempts yet2s256 MBJudgeable
License Plate 1Given a format string of length at most 4 with c for letter and d for digit, count plates where no two adjacent characters are identical.Easy3CombinatoricsMath+2No attempts yet1s512 MBJudgeable
License Plate 2Count strings matching a pattern of letter and digit slots, where no two adjacent characters are equal, modulo 1,000,000,009.Easy3Dynamic programmingMath+2No attempts yet1s512 MBJudgeable
Fruit StealingCount the ways to distribute M identical stolen fruits among N labeled kinds so each kind receives at least one.Easy3CombinatoricsDynamic programming+1No attempts yet1s256 MBJudgeable
League of Legensal (Small)Count sequences of 1-second A casts and M-second B casts that fill exactly N seconds, modulo 1,000,000,007.Easy3Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
SapsanGiven a row of n seats split into n/2 adjacent pairs, find the largest number of occupied seats so that exactly half the seated people sit next to an occupied neighbor.Easy3MathGreedy+1No attempts yet2s512 MBJudgeable
Pie ChartOrder class percentages around a pie chart to maximize the count of sector boundaries exactly 50% apart, forming diameter lines through the center.Medium4Brute forceCombinatorics+2No attempts yet2s128 MBJudgeable
ZooCount the ways to place non-attacking lions in a 2 by N grid so that no two lions sit in adjacent cells, modulo 9901.Medium4Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
Lucky StringsCount the distinct rearrangements of a short string (length up to 10) that have no two adjacent equal characters.Medium4BacktrackingCombinatorics+1No attempts yet2s256 MBJudgeable
SoccerGiven per-interval scoring probabilities for two teams over 18 intervals, compute the probability that at least one team ends with a prime number of goals.Medium4ProbabilityMath+1No attempts yet2s128 MBJudgeable
Similar WordsCount unordered pairs of equal-length words that are related by some bijection between letters, similar to the isomorphic-strings check.Medium4StringHash map+1No attempts yet2s128 MBJudgeable
DominoesGiven an N x N grid of domino values (N up to 6), find the minimum and maximum of the cycle-sign-adjusted product over all row-column permutations.Medium4Brute forceBacktracking+2No attempts yet2s128 MBJudgeable
Perfect Attendance AwardCount length-N attendance strings over O, L, A that have at most one L and no three consecutive A's, modulo 1,000,000.Medium4Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Permutation OrderGiven N, either compute the k-th lexicographic permutation of 1..N or find the rank of a given permutation, using factorial number system logic.Medium4MathCombinatorics+1No attempts yet2s128 MBJudgeable
Gift ExchangeCompute the number of derangements of N items modulo 1,000,000,000.Medium4Dynamic programmingMath+1No attempts yet2s128 MBJudgeable
Circular DanceGiven N people in a circle, compute the minimum adjacent swaps needed to reverse their order up to rotation, which reduces to a closed-form floor formula.Medium4MathCombinatoricsNo attempts yet2s128 MBJudgeable