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 |
|---|---|---|---|---|---|---|
| Number of RectanglesGiven up to 5000 points, count axis-aligned rectangles whose four corners are all present among the points. | Medium5 | Hash mapCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| SequenceFind the K-th lexicographically smallest non-decreasing sequence of N positive integers summing to M. | Medium5 | BacktrackingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Theater SeatsCount permutations where each ticket holder sits in their own or adjacent seat, with VIP seats fixed and splitting the row into independent segments counted by a Fibonacci-like recurrence. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Polygon PartitionsCount noncrossing dissections of a regular N-gon into all triangles or all quadrilaterals, modulo 1e9, using Catalan-like combinatorics. | Medium5 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Number of PermutationsGiven a permutation's up-down pattern, count permutations of size n sharing the same pattern, modulo 1,000,000,000. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 2s | 128 MB | Judgeable |
| Sum of Powers of TwoCount the ways to write N as an unordered sum of powers of two, modulo one billion. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Adjacent Bit Pair CountCount binary strings of length n whose number of adjacent 11-pairs equals a given k, for up to 1000 queries. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| A Margarita Today?Count subsets of up to 30 prices whose sum is within budget D and whose leftover money cannot afford any unchosen item. | Medium5 | Brute forceRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Counting Sanggeun's Digit FriendsGiven up to a million large integers, count pairs that share at least one decimal digit, requiring bitmask digit sets and efficient counting over 1024 subsets. | Medium5 | Bit manipulationCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pleasant WordCount ways to fill blanks in a word with uppercase letters so it avoids three consecutive vowels or consonants and contains at least one 'L'. | Medium5 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Counting Axis-Aligned Right TrianglesCount triangles among N points where the right angle vertex has one point sharing its x-coordinate and another sharing its y-coordinate. | Medium5 | Hash mapMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TripletsGiven a grid with letters placed on some cells, count how many triples of letters are collinear. | Medium5 | GeometryCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Film FestivalGiven a bipartite graph of boat connections, count the number of pairs of left villages and pairs of right villages that form a complete K2,2 subgraph. | Medium5 | CombinatoricsHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Handong Does Not Want to Study!Given a functional graph where each node points to exactly one other node, find the starting node whose path visits the most distinct nodes before repeating, breaking ties by smallest index. | Medium5 | GraphDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Friends Calling PlanGiven call minutes between up to 16 employees, pair them all up to minimize total billing cost using bitmask DP over perfect matchings. | Medium5 | Dynamic programmingBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PINCount pairs of 4-character PINs (from a given list) that differ in exactly D of their four positions. | Medium5 | Hash mapCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Hop, HopCount, modulo 1000000, the number of ways to write n as a non-increasing sequence of jumps of length 1, 2, or 3, for n up to 1e9. | Medium5 | MathDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Enchanted MirrorDecide if bricks with fixed (real,mirror) letter pairs can be permuted so the row reads T1 and its mirror reads T2, given initial words S1,S2. | Medium5 | Hash mapString+2 | No attempts yet | 3s | 256 MB | Judgeable |
| History of FootballGiven final points of n (up to 8) football teams under win/draw/loss scoring, count the number of distinct match outcome assignments consistent with those totals. | Medium5 | BacktrackingCombinatorics+1 | No attempts yet | 2s | 64 MB | Judgeable |
| Graph MatchingCount the number of matchings (independent edge sets) of the cycle graph C_n for each given n, likely requiring big-integer arithmetic via a Lucas-sequence style recurrence. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Breaking the CipherGiven plaintext, ciphertext, and block size, count permutations of size k that transform every plaintext block into the matching ciphertext block. | Medium5 | CombinatoricsString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Industrial Spy's LetterGiven up to 7 digit shreds, count the distinct primes formable by arranging any subset of them (leading zeros dropped), over up to 200 test cases. | Medium5 | BacktrackingCombinatorics+1 | No attempts yet | 1.5s | 128 MB | Judgeable |
| I've Got Your Back(gammon)Map between 6-tuples of 15 pieces on 6 points, ordered lexicographically, and their index among the 15504 configurations. | Medium5 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SkylineCount permutations of 1..N with no increasing subsequence of length 3, modulo 1,000,000, for each N up to 1,000. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MeganominoesFor each query i, count unordered pairs of distinct tiles where one matching pair of ends touches and the two opposite ends sum to i. | Medium5 | Hash mapBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Frosh WeekGiven n distinct student numbers in a line, find the minimum number of adjacent swaps needed to sort them into increasing order. | Medium5 | SortingDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cantor SetGiven a decimal x between 0 and 1 that ends within 6 fractional digits, decide whether x lies in the Cantor set, that is, whether some ternary expansion of x avoids the digit 1. | Medium5 | MathNumber theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Team RankingsGiven up to 100 rankings of five teams, find the ranking minimizing the sum of pairwise-order disagreements, breaking ties alphabetically. | Medium5 | Brute forceCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tight WordsCount words of length n over digits 0..k where adjacent digits differ by at most 1, then print that count as a percentage rounded to five decimals. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Know When to Hold ThemRank a set of five-card poker hands from most to least valuable, using nine standard hand categories and their tie-breakers. | Medium5 | SortingImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PERMSFor each query (n, k), count permutations of 1..n having exactly k inversions, with n up to 18 and k up to 200. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Great Geek Game-show 3000!Given a random permutation of N names, each contestant follows its cycle up to K steps; find the probability every cycle has length at most K. | Medium5 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SoccerCompute probability distribution of final scores after up to T seconds of a stochastic soccer simulation with passing, stealing, shooting, and absorbing states. | Medium5 | ProbabilityDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Baby's BlocksGiven a multiset of letters, find the 0-based rank of a given distinct permutation among all distinct permutations in lexicographic order. | Medium5 | CombinatoricsString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| JOI FlagCount fillings of an M by N grid with J, O, I (some cells fixed) that contain at least one L shape: J with O to its right and I below, modulo 100000. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Commute RouteCount monotone lattice paths from (1,1) to (w,h) that never turn at two consecutive intersections, modulo 100000. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Listing Square Arrangements in Lexicographic OrderList every partition of n whose parts are non-increasing, and print the sequences in decreasing lexicographic order. | Medium5 | BacktrackingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Odd or EvenPair each red number with a blue number to minimize how many pairs sum to an even value, since Mary wins those. | Medium5 | GreedyMath+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Computer DJGiven N labeled songs, map the k-th character of the infinite string of all words over A..Z in length-then-lex order back to its song title. | Medium5 | MathCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow IDsFind the N-th smallest binary number that has exactly K one-bits and no leading zeros, then print it in binary. | Medium5 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow LineGiven N up to 20, convert between a permutation of 1..N and its lexicographic rank among all permutations, for up to 10000 queries. | Medium5 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bovine Bridge BattleCount sets of four points that are symmetric about some center, where each point pairs with its 180-degree rotation partner. | Medium5 | Hash mapGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Building a FenceCount the ordered ways to cut a plank of length N into four positive integer pieces whose longest piece is strictly shorter than the other three combined. | Medium5 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow CashCount the number of unordered ways to make an amount N using V coin denominations, where each coin can be used any number of times. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Fence RepairSplit one board into N planks of given lengths; each cut costs the length of the piece being cut, so find the minimum total cost. | Medium5 | GreedyHeap+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ATM PIN TheftGiven a sequence of observed key presses (digits and at most one backspace), count the four-digit PINs that could produce exactly that sequence of pressed keys. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hopeless CoachGiven past win, draw, and loss counts, find the probability that the team earns at least P points over the next N matches. | Medium5 | Dynamic programmingProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| EntropyFor each line of text, print the fixed 8-bit ASCII bit length, the optimal prefix-free Huffman bit length, and the compression ratio rounded to one decimal. | Medium5 | GreedyHeap+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Extrapolation Using a Difference TableExtend a sequence by k steps using a polynomial difference table, always assuming the highest-order differences stay constant, and print the (n+k)-th term. | Medium5 | MathDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| El DoradoCount the increasing subsequences of length exactly k in a sequence of n distinct numbers, for several test cases. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| A Game with MarblesEach move takes one marble from a bowl and, if it is not bowl 1, adds one marble to every lower-numbered bowl; count the total moves until all bowls are empty. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Rhinoceros BeetleGiven shared community cards and each player's two hole cards, evaluate every player's best five-card poker hand and print the indices of all winners. | Medium5 | ImplementationSorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Pattern GeneratorFor each (n, k) pair, print all n-bit strings with exactly k ones in decreasing numeric order, separated by blank lines. | Medium5 | BacktrackingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| King Thrór's GoldCount the ways to choose exactly k distinct bar values summing to T, and list all solutions in lexicographic order when there are at most 20. | Medium5 | Dynamic programmingBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Wonderful FoursGiven five digits, count unordered triples of distinct permutations (no leading zero) whose sum is a different valid permutation of the same digits. | Medium5 | Brute forceCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GearsCount how many distinct fractions a/b exist with both a and b in the range M to N. | Medium5 | MathNumber theory+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Geocaching CoordinatesGiven a coordinate formula with lowercase letter slots and rules for each variable's allowed values, print every distinct resulting coordinate in lexicographic order. | Medium5 | Brute forceCombinatorics+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Diophantus of AlexandriaGiven n, count the pairs (x, y) with x <= y satisfying 1/x + 1/y = 1/n. | Medium5 | Number theoryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Betting SetsPartition an N by M table of probabilities into groups of one cell per column to maximize the expected number of all-heads groups. | Medium5 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Digit Sum Over a RangeGiven l and u up to 2e9, find the total of the digit sums of every integer in that inclusive range. | Medium5 | MathDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The History of CottonGiven n, m, and g, print the g-th m-element subset of {1,...,n} in lexicographic order. | Medium5 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Yum YumFind the minimum number of straight lines needed to cover every integer-coordinate point in an (n+1) by (m+1) grid, excluding the frog's one starting point. | Medium5 | MathNumber theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ProtocolsCount the length-m strings over k symbols with no run of l equal symbols, then output floor((n/m) * log2(count)). | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 3s | 128 MB | Judgeable |
| LollobrigidaGiven a multiset of block heights, decide whether the blocks can be arranged so the sequence alternates up and down at every position. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Number of N-k-special SetsCount subsets of {1,...,n} with no two consecutive numbers whose sum exceeds k, for n up to 100. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |
| Monochromatic TrianglesGiven n points and a list of red edges (all other pairs are black), count the triangles whose three sides share one color. | Medium5 | CombinatoricsGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MatchesGiven m match lineups that each split n boys into two teams, decide whether every pair of boys is separated at least once. | Medium5 | Bit manipulationCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Rectangles 2Count axis-aligned rectangles with vertices on grid points of an n x m grid whose perimeter is at least p. | Medium5 | MathCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| BalloonsGiven stock counts for n balloon colors and m orders, decide whether each child can receive the requested number of distinct-colored balloons. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ElectricityGiven k lines between n homes and m windmills on parallel lines, count subsets of non-crossing lines where every home and windmill has degree at most one, modulo r. | Medium5 | Dynamic programmingSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| DiceFind the k-th non-decreasing sequence of length m with values from 1 to n, in lexicographic order. | Medium5 | CombinatoricsDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Super-Fast Circular RacesGiven a directed graph where each vertex has out-degree and in-degree at most two, count the ways to cover every vertex with vertex-disjoint simple directed cycles, modulo 10000, or report NIE if impossible. | Medium5 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Neon SignCount the triples of vertices whose three connecting tubes all share the same color in a red-blue complete graph. | Medium5 | CombinatoricsGraph | No attempts yet | 3s | 256 MB | Judgeable |
| HerbertCount distinct squares a robot starting at the origin can end on within n moves when each step or ninety-degree turn costs one move. | Medium5 | MathCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |
| The Hopeless QueueCount fillings of the movable spots with equal coin totals so every prefix keeps at least as many 50 coins as 100 coins, modulo 1000000. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 2s | 128 MB | Judgeable |
| Random Walk That Never Goes NegativeCount length-2N walks from 0 back to 0 with steps of plus or minus 1 that never drop below 0, modulo 1,000,000,007. | Medium5 | CombinatoricsMath | No attempts yet | 2s | 64 MB | Judgeable |
| The number of studentsFind the smallest numbers of girls and boys whose within-group and cross-group friend counts match the given a, b, c, and d. | Medium5 | MathNumber theory+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Algorithm Final ExamCount permutations of N items in which the first k positions are all wrong. | Medium5 | CombinatoricsMath | No attempts yet | 1s | 128 MB | Judgeable |
| Cut the CakeCount into how many regions the given infinite lines divide a circle. | Medium5 | GeometryCombinatorics | No attempts yet | 20s | 128 MB | Judgeable |
| Farmer John has no large brown cowFind the Kth adjective combination in alphabetical order among all combinations except the N forbidden ones. | Medium5 | CombinatoricsSorting | No attempts yet | 1s | 128 MB | Judgeable |
| The Alphabet StickerCount completions of a sticker pattern where each question mark becomes a visible letter and every letter forms one contiguous block. | Medium5 | CombinatoricsString | No attempts yet | 1s | 128 MB | Judgeable |
| Charity Booth RentalCount the strictly increasing positive triples GP, GA and PC that sum to T for each query. | Medium5 | CombinatoricsMath | No attempts yet | 1s | 128 MB | Judgeable |
| Number of LocksCount length-n strings over heights 1 to 4 that use at least three distinct heights and have an adjacent pair differing by exactly 3. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |
| OdometerCount the integers between X and Y whose decimal digits use one repeated digit except for a single different digit. | Medium5 | Brute forceCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |
| Club ScheduleCount attendance and key-passing schedules over N days where each day's leader attends and the key stays with attendees. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |
| Catalan SquareCompute the convolution sum S_n of Catalan numbers for a given n up to 5000 and print the exact integer. | Medium5 | CombinatoricsMath | No attempts yet | 1s | 256 MB | Judgeable |
| The Kth Anagram in Alphabetical OrderGiven a word and rank K, print the Kth distinct anagram of the word in alphabetical order. | Medium5 | CombinatoricsString | No attempts yet | 1s | 256 MB | Judgeable |
| Zeroing a Binary SequenceCount ordered flip sequences of exactly K moves that turn a given binary sequence into all zeroes. | Medium5 | CombinatoricsDynamic programming | No attempts yet | 1s | 256 MB | Judgeable |
| Restaurant RatingsCount how many nonnegative score sheets rank no better than the given sheet under total sum first and critic order second. | Medium5 | CombinatoricsDynamic programming | No attempts yet | 1s | 256 MB | Judgeable |
| Pi Day Pie DistributionCount the nondecreasing distributions of n pie pieces among k people with each person getting at least one piece. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 1s | 256 MB | Judgeable |
| Inherited diseaseFollow the birth-order path down D generations where a generation g member has g+1 children and print each breadth-first number modulo 1000000007. | Medium5 | MathCombinatorics | No attempts yet | 1s | 16 MB | Judgeable |
| Uniting DepartmentsMerge departments pairwise at product-of-sizes cost and report the total cost and the number of ordered merge sequences modulo 1000000007. | Medium5 | MathCombinatorics | No attempts yet | 1s | 256 MB | Judgeable |
| Attendance AwardCount length-N strings over L, O and A with at most one L and no three consecutive As for each N up to 3000. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 1s | 256 MB | Judgeable |
| Next Unique-Digit NumberFind the smallest integer above N that uses no zero and repeats none of the digits 1 to 9, printing 0 when none exists. | Medium5 | BacktrackingCombinatorics+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Football scorelinesCount the ordered scoring sequences by both teams that reach the given final score under the listed play values, modulo 1000000009. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 2s | 256 MB | Judgeable |
| Krusty's BurgerCount burger combinations of size, bun, cheeses, toppings and sauces whose size plus extra-item cost is at most B. | Medium5 | CombinatoricsMath | No attempts yet | 1s | 256 MB | Judgeable |
| Delicious CookieSplit every piece of a right triangle with legs a and b N times along the altitude to the hypotenuse and print the natural log of the K-th largest piece area. | Medium5 | CombinatoricsGeometry+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Running StepsCount left-right alternating sequences of one-step and two-step strides where both legs use equal counts and twos are at least as many as ones. | Medium5 | CombinatoricsMath | No attempts yet | 1s | 256 MB | Judgeable |
| Feast CoinsCount ways to reach total S with owned coins so that every chosen coin value appears the same number of times. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 3s | 256 MB | Judgeable |
| Perica's PianoSort the N key values and add each value multiplied by the number of K-sets where it is the largest, modulo 1000000007. | Medium5 | CombinatoricsSorting+1 | No attempts yet | 1s | 64 MB | Judgeable |