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 |
|---|---|---|---|---|---|---|
| Making a TriangleGiven up to 40 sticks, partition all of them into three groups whose summed lengths form a triangle, maximizing the triangle's area via Heron's formula. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Nonlinear SequencesCount and list increasing length-L sequences from 1..M containing no three-term arithmetic progression, printing the first three lexicographically and the total count. | Medium6 | BacktrackingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Seat ArrangementCount the ways to seat N-1 ticket holders into N seats, given one free seat, so that each person sits in their own, adjacent, or the free seat. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Mayor Election PostersGiven n posters pasted in order over intervals on a huge wall, count how many posters remain at least partially visible after later posters overlap earlier ones. | Medium6 | Segment treeCombinatorics+2 | No attempts yet | 1s | 192 MB | Judgeable |
| Collecting ItemsCount monotone right/up paths from bottom-left to top-right on a grid that must pass through every item cell and avoid obstacle cells. | Medium6 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Pebble Game of ChanceCount the sequences of N wheel spins whose cumulative pebble cost never exceeds K, modulo 42043. | Medium6 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Building ColumnsCount distinct stacked-cube columns from four dice-like cubes where each column's four side faces show all four colors, up to rotation about the vertical axis. | Medium6 | Brute forceCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Rascal TriangleGiven a recursively defined 'Rascal triangle' with a division-based rule, compute R(n,m) efficiently for n,m up to 50,000 across up to 1000 queries. | Medium6 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum Cycle Value of 1Given n and k, count permutations of 1..n whose cycle containing element 1 has maximum element exactly k. | Medium6 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Recursive Palindrome PartitionsCount recursive palindrome partitions of N, where a partition is valid if it is a palindrome and both halves are recursively valid. | Medium6 | Dynamic programmingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tile FillingCount the number of ways to tile a 4×N board with 2×1 dominoes for multiple queries, bounded so the answer fits in a 32-bit integer. | Medium6 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Press to UnlockCount the number of ordered sequences of disjoint nonempty subsets (a set partition of any subset of buttons into an ordered sequence of blocks) for given B up to 11. | Medium6 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| No-Fold Hold'emGiven hole cards and four community cards in Texas Hold'em, find which possible river cards make you win, or otherwise tie, else print LOSER. | Medium6 | Brute forceSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Childhood Toy BoxesCount subsets of N boxes (as bitmasks over M<=20 toy types) whose union covers all M types, modulo 1e9+7. | Medium6 | Bit manipulationDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Square CrosswordCount distinct ways to pick four distinct equal-length words to fill a square crossword so top/bottom rows and left/right columns match corner letters. | Medium6 | Hash mapBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Counting Pipe InstallationsCount the ways to lay a single connected pipe path with six pipe shapes from the top-left entry to the bottom-right exit through a grid with blocked cells, modulo 10007. | Medium6 | Dynamic programmingMatrix+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Difficulty-Based Problem SelectionCount ways to pick exactly one problem per difficulty level 1..N given fixed-difficulty and flexible dual-difficulty problem pools, modulo 1e9+7. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Digit Sum in an IntervalCount integers in [A,B] with a given digit sum and output the smallest such integer, for bounds up to 10^15. | Medium6 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ConfusionCount permutations of 1..N with exactly C inversions, modulo 1e9+7, using DP with prefix sums for the given constraints. | Medium6 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Agent Mission AssignmentGiven an N x N matrix of success percentages, assign one mission per agent to maximize the product of chosen probabilities, essentially an assignment problem with a product (log-sum) objective. | Medium6 | Dynamic programmingBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| LadderGiven a target permutation for a ladder game, find the minimum number of horizontal rungs (adjacent-position swaps) needed to realize it. | Medium6 | GreedyCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Tournament Rank RangeGiven a single-elimination bracket's match winners, determine each queried player's best possible and worst possible final ranking consistent with the known beat relations. | Medium6 | TreeDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Beautiful NamesCount the number of orderings of N distinct strings such that all strings sharing a common prefix always form a contiguous block, modulo 1e9+7. | Medium6 | TrieCombinatorics+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Grid Job SchedulingGiven an N x N grid where cell (x,y) needs its left and top neighbors done first and K computers process jobs in parallel, compute the minimum total seconds to finish all cells. | Medium6 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Permutation RankGiven a permutation and many swap queries, compute the lexicographic rank modulo 1e9+7 for each swapped permutation efficiently. | Medium6 | CombinatoricsSegment tree+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Vandalized ChessboardGiven a board size and a blackened row, column, and two diagonals, compute the number of distinct blackened cells and how many should be repainted grey versus white based on the checkerboard color rule. | Medium6 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| BingoGiven a fixed call sequence, place numbers 1..N^2 on an NxN board to maximize how many rows exactly match some N-length window of consecutive calls in order. | Medium6 | CombinatoricsBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PatternCount unit squares with max(x,y) odd inside a large rectangle using a closed-form counting formula instead of brute force. | Medium6 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pizza DeliveryChoose at most K of M candidate sites to maximize the total population within radius R, counting each building once even if covered multiple times. | Medium6 | CombinatoricsBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TeamsCount ways to split N players into two equal-size teams so that no player shares a team with anyone on his exclusion list, treating the two teams as unordered. | Medium6 | Union-findCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Arranging CardsGiven C≤4 colors with N cards each in a hand sequence, find the minimum number of single-card moves to reach some arrangement where colors form contiguous ascending-value blocks in any color order. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| A Huge TowerCount the number of orderings of N distinct blocks into a tower, respecting a size-tolerance stacking rule, modulo 1e9+9. | Medium6 | SortingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Tennis ClubGiven each player's required match count, decide if a simple graph (no self loops, no repeated edges) with that exact degree sequence exists, typically via the Erdős–Gallai theorem. | Medium6 | GreedyMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ExpressionsCount balanced parenthesis strings of a given total length that have exactly a given maximum nesting depth. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Stack Machine ProgrammerGenerate a stack-machine program that maps up to five given small input-output integer pairs to their exact outputs under strict operand and stack constraints. | Medium6 | SimulationMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Justice for AllGiven a k x k 0/1 trust matrix (k up to 20), count the number of perfect matchings between knights and horses, i.e. the permanent of the matrix. | Medium6 | Dynamic programmingBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Game of Master-MindGiven past Mastermind guesses and their black/white hints, find the lexicographically smallest secret code consistent with all hints or report impossibility. | Medium6 | Brute forceCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Commedia dell'arteDetermine whether a 3D M^3 sliding puzzle can be restored to its solved state given its parity/permutation solvability rules. | Medium6 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cube ColoringGiven six unordered face-vision descriptions of a cube, reconstruct the lexicographically smallest assignment of colors to the six numbered faces that reproduces the vision multiset, or report impossibility. | Medium6 | Brute forceCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Java CertificationGiven rounded per-category percentages and totals, find n_i and w_i values reproducing them while minimizing the spread between the largest and smallest category size. | Medium6 | Brute forceMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Unit Squares Along a DiagonalGiven N, count unordered integer side pairs (a,b) such that a+b-gcd(a,b) equals N, using the diagonal-crossing formula for a grid rectangle. | Medium6 | Number theoryMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ExpectationCompute the exact expected value (as a reduced fraction) of the XOR of two independent uniform random integers in [0, n-1), for up to 1000 values of n up to 1e9. | Medium6 | Bit manipulationMath+1 | No attempts yet | 2s | 64 MB | Judgeable |
| TichuGiven a 13-card Tichu hand, compute the minimum number of legal combinations (singles, pairs, triples, quads, full houses, straights) that partition the hand. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Video PokerGiven a poker payout table and a five-card hand, compute the exact fraction expected value of the best discard strategy over all 32 subsets of held cards. | Medium6 | Brute forceCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Youth Hostel DormFind the maximum number of beds that can be placed in an l by w grid so every bed stays reachable from a single boundary entrance via floor tiles. | Medium6 | CombinatoricsGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sudoku TransformationDetermine whether a completed sudoku board can be turned into another via rotations, band/stack swaps, row/column swaps, and digit relabeling. | Medium6 | Brute forceSimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Lucky NumbersCount lucky numbers (digits 4 and 7 only) in [A,B], plus lucky numbers outside the range whose digit-reversal lands inside it, for B up to 10^47. | Medium6 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The RobberyGiven N item types where type k has exactly k identical copies, pick copies within a weight budget M to maximize total value (bounded knapsack with huge M and small N). | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Sky CodeGiven up to 10000 star IDs, count the 4-element subsets whose greatest common divisor equals 1, using Mobius inversion over divisor counts. | Medium6 | Number theoryCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Lucky NumbersCount numbers in [A,B] up to 10^12 expressible as products of one or more lucky numbers made only of digits 4 and 7, across many queries. | Medium6 | MathNumber theory+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Determinant of the GCD MatrixGiven a divisor-closed set of numbers, compute the determinant of the pairwise-gcd matrix modulo 1e9+7 using Smith's theorem via Euler's totient function. | Medium6 | Number theoryMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Crazy Tea PartyGiven n people seated around a circular table, compute the minimum number of adjacent swaps needed to reverse the circular seating order, for many test cases. | Medium6 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Binary PolynomialsGiven a Boolean function's polynomial coefficients over n variables, count vectors with exactly k ones that make the function evaluate to 1. | Medium6 | Bit manipulationCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CountdownFind the closest achievable value to a target by combining six given numbers with the four operations, keeping intermediate results positive integers. | Medium6 | Brute forceRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Fake ScoreboardReconstruct a binary team-by-problem matrix matching given row and column sums, outputting the lexicographically smallest valid matrix or reporting impossibility (Gale-Ryser style bipartite degree sequence problem). | Medium6 | GreedyCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Colored CubesGiven up to four cubes with colored faces, find the minimum number of face repaints so all cubes become identical under rotation. | Medium6 | Brute forceSimulation+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Hongjun's Royal GuardCount permutations of N distinct elements where every interior element is a local extremum (both neighbors larger or both smaller); N is at most 20. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Powers of ThreeGiven n, list the elements of the n-th smallest subset of powers of 3 when subsets are ordered by their sums. | Medium6 | MathCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sang-geun's LockCount the number of height-balanced binary trees with N nodes, print the last 9 digits padded to width 9. | Medium6 | Dynamic programmingRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| I'm Attacking the Darkness!Parse a dice expression with up to six dice and integer modifiers, then compute the reduced fraction of outcomes whose total meets or beats a target value. | Medium6 | Dynamic programmingProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bingo!Given column draw counts and X candidate 5x5 patterns, combine any Y of them into winning patterns and find the fewest additional draws that make some pattern fully markable. | Medium6 | Brute forceCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Black ViennaGiven each player's hand, the hidden gang, and records of interrogations, find the earliest turn after which at least one player can deduce the gang from their own cards and the answers. | Medium6 | Brute forceCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RobotsGiven garbage cells in a grid, robots walk from the northwest corner to the southeast corner moving only east or south; find the fewest robots that collect all garbage. | Medium6 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Not One Bit MoreCount integers in [LO, HI] whose repeated popcount chain reaches 1 at exactly step X, with LO up to 1e18 and X up to 10. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| StringerGiven fixed counts of each of N letters, find the K-th string in alphabetical order among all arrangements, without listing them. | Medium6 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PillsCount how many distinct sequences of W and H can appear as a bottle of N pills is emptied, two halves per pill. | Medium6 | Dynamic programmingCombinatorics | No attempts yet | 1s | 256 MB | Judgeable |
| KnotsFor each even N up to 100, find the probability that two random perfect matchings on N points form a single cycle. | Medium6 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Complaint SortGiven a sequence of n values, count the strictly decreasing subsequence triples (i < j < k with a_i > a_j > a_k). | Medium6 | ArrayCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Sanggeun Trapped in a MazeCount closed walks of length n on an infinite hexagonal lattice starting and ending at one room. | Medium6 | CombinatoricsDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Beach PartyGiven preference orders over music styles, assign distinct styles to s stages so that the most people share the stage you attend. | Medium6 | Brute forceCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Average Value SequenceGiven a non-decreasing average sequence m of length n, count the integer sequences s of length n+1 whose adjacent averages equal m. | Medium6 | MathCombinatorics+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Car ParkingGiven a row of cars and W workers, find the minimum number of cars that must change places so the types are sorted ascending. | Medium6 | GreedyDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Binary MatrixGiven a binary matrix, flip the fewest entries so every row has the same number of 1s and every column has the same number of 1s, or report that it is impossible. | Medium6 | GreedyCombinatorics+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Counting DigitsFor each query range [A, B], count how many times each decimal digit 0 through 9 appears in all integers written out from A to B. | Medium6 | MathImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Drop the TriplesPlayers alternate drawing cards from a stock and may drop valid triples; each maximizes perfect triples then common triples. Report the winner or a tie. | Medium6 | GreedyDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Balanced Cow BreedsCount the ways to 2-color the parentheses in a string so that each color class, read in order, forms a balanced parenthesis sequence. | Medium6 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dividing the GoldGiven N coins with values, find the minimum difference between two piles and count the subsets forming the lighter pile, modulo 1,000,000. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Mixed Up CowsCount permutations of N serial numbers (N at most 16) where every adjacent pair differs by more than K. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ChocolateFor C equally likely colors, after N draws where matching pairs are eaten, find the probability that exactly M colors remain on the table. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bulls and CowsCount binary sequences of length N where every pair of bulls has at least K cows between them, modulo 5000011. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow Frisbee TeamCount the nonempty subsets of N cows whose rating sum is divisible by F, modulo 100000000. | Medium6 | Dynamic programmingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Round NumbersCount integers in [Start, Finish] whose binary form has at least as many zeroes as ones. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| New Cow BrandsGiven each position's allowed distinct letters, list the codes ranked from start to finish in lexicographic order, where no letter repeats inside a code. | Medium6 | BacktrackingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ranking the CowsGiven partial comparison results between N cows with distinct milk rates, find the minimum number of additional pairwise comparisons needed to determine the full ranking. | Medium6 | GraphTopological sort+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Xavier Is Learning to CountGiven m distinct positive integers and a size p (at most 5), count for every attainable sum the number of p-element subsets that add up to it, listing sums in increasing order. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Bonus BondsGiven the next serial number in a region and a digit position, count how many already-sold serials have each digit 0-9 at that position. | Medium6 | MathCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| AnagramFor each given word, print every distinct string formed by rearranging its letters, in lexicographic order with duplicates removed. | Medium6 | BacktrackingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dihedral GroupsNormalize a run-length abbreviated string of rotations r and reflections m into the unique shortest equivalent sequence under the dihedral group of order 2n. | Medium6 | MathString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| California Jones and the Gate to FreedomGiven n stones and a binary index b, decide whether the chosen n/2 stones are exactly the combination at lexicographic rank b among all size-n/2 subsets. | Medium6 | CombinatoricsMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Parallelogram CountingGiven n points, count how many 4-point subsets form a parallelogram by pairing points that share a midpoint. | Medium6 | Hash mapGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Football LeagueGiven an even number of teams playing a single round-robin over n-1 turns, find the minimum total number of same-venue consecutive pairs across all teams. | Medium6 | MathCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A Decorative FenceGiven N and a rank C, output the C-th alternating (zigzag) permutation of 1..N in lexicographic order. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CouplesGiven N parties and their attendees, count pairs of people who appear together at more than K parties. | Medium6 | Hash mapCombinatorics | No attempts yet | 5s | 128 MB | Judgeable |
| Cutting Out of FactorialsGiven k from 2 to 500, remove the fewest of 1!, 2!, ..., k! so the remaining product is a perfect square, and report that count. | Medium6 | MathNumber theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BacteriaEach adult produces one young per second while young mature into adults; find the total population after T seconds modulo K, given initial counts. | Medium6 | MathCombinatorics+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Burger, French Fries, Soft DrinkCount the ways to cut a B/F/S stream into N consecutive blocks where every block has equal positive counts of each letter, or report Impossible. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Add Them UpGiven counts of each digit 1-9, sum every distinct number formable using each digit at most as often as it appears, modulo 1e9+7. | Medium6 | CombinatoricsDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Jack's SocksGiven an undirected graph of similar socks, decide whether a perfect matching exists and is unique, and print that matching if it is. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| The Fifth DimensionCount ordered simple paths with 6 distinct vertices and 5 edges in an undirected graph. | Medium6 | GraphCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |
| Highway Racing TracksCount the 5-vertex paths (chains of four edges on five distinct vertices) in a simple graph, treating each path as unordered. | Medium6 | GraphCombinatorics | No attempts yet | 1s | 128 MB | Judgeable |