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 results575 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Graph Maximum MatchingGiven a small graph, decide whether some edges can be kept so every vertex has degree exactly 1.Easy2GraphBacktracking+1No attempts yet2s512 MBJudgeable
Come Back HomeCount simple paths of exact length K from the bottom-left to the top-right cell of a small grid, avoiding blocked cells and revisits.Easy3BacktrackingDFS+1No attempts yet2s128 MBJudgeable
Password GenerationGenerate all length-L increasing letter combinations from a given set of C letters that contain at least one vowel and two consonants, printed in lexicographic order.Easy3BacktrackingBrute force+1No attempts yet2s128 MBJudgeable
Placing CardsGiven up to 10 cards with 1 or 2 digit numbers, count the distinct integers formed by ordering exactly k chosen cards.Easy3Brute forceBacktracking+2No attempts yet1s256 MBJudgeable
Breed AssignmentCount the breed assignments for N cows under same/different constraints, or report 0 if they conflict.Easy3GraphBacktracking+2No attempts yet1s128 MBJudgeable
Going to the MoviesGiven a truck capacity C and up to 16 cow weights, pick a subset whose total weight is as large as possible without exceeding C.Easy3Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Stuttering StringsFor each input case, the program prints every length-n string over * and ! whose runs stay within the given limits, in lexicographic order with * first.Easy3BacktrackingRecursion+1No attempts yet1s128 MBJudgeable
Even More DicePrint every nondecreasing roll of n m-sided dice that sums to s in lexicographic order for each test case.Easy3BacktrackingRecursionNo attempts yet5s512 MBJudgeable
All PermutationsPrint every permutation of the numbers 1 to N in lexicographic order, one per line.Easy3BacktrackingRecursionNo attempts yet1s256 MBJudgeable
Travel of AlphabetsCount all length-L walks on a letter grid and the distinct strings among them, discarding any word containing a, c, or m.Easy3BacktrackingDFS+1No attempts yet2s256 MBJudgeable
Sums of 1, 2, 3 (2)Find the k-th composition of n using parts 1, 2 and 3 in lexicographic order, or print -1 when it does not exist.Easy3BacktrackingDynamic programmingNo attempts yet1s512 MBJudgeable
Modern Art Plagiarism (Small)Decide whether the smaller tree is a connected subgraph of the larger tree, with only the shapes mattering, not the original labels.Easy3TreeBacktrackingNo attempts yet5s512 MBJudgeable
String PermutationPrint every permutation of a short string of distinct characters, in the order given by the original character positions.Easy3BacktrackingRecursion+1No attempts yet5s512 MBJudgeable
N and M (1)Print every length-M sequence of distinct numbers chosen from 1 to N, in increasing lexicographic order.Easy3BacktrackingRecursionNo attempts yet1s512 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
N and M (3)Print every length-M sequence from 1 to N in lexicographic order, allowing repeats.Easy3BacktrackingRecursion+2No attempts yet1s512 MBJudgeable
N and M (4)Print all non-decreasing sequences of length M chosen from 1 to N, each exactly once, in lexicographic order.Easy3BacktrackingRecursionNo attempts yet1s512 MBJudgeable
Length M sequences from N numbersGiven N distinct numbers and an M, print every length-M permutation of the numbers in lexicographic order without repeats.Easy3BacktrackingRecursion+2No attempts yet1s512 MBJudgeable
N and M (6)Given N distinct natural numbers and M, print every ascending M-element subsequence in lexicographic order without repeats.Easy3BacktrackingSorting+2No attempts yet1s512 MBJudgeable
N and M (10)Given N numbers and an M, print every non-decreasing length-M selection of the numbers in lexicographic order without duplicates.Easy3BacktrackingSorting+2No attempts yet1s512 MBJudgeable
The Rice Cake Seller and the TigerPick one rice cake kind from each day's set so consecutive picks differ; output the daily picks or -1 if impossible.Easy3Dynamic programmingBacktracking+1No attempts yet1s128 MBJudgeable
Livestock LineupGiven at most 7 'must be milked beside' constraints among 8 cows, output the alphabetically first permutation satisfying all of them.Easy3Brute forceBacktracking+2No attempts yet1s512 MBJudgeable
Sudoku VariantGiven a 3x3 grid with at most three empty cells, count the ways to fill the empties so no digit repeats in any row or column.Easy3Brute forceBacktracking+1No attempts yet2s512 MBJudgeable
Sum of SubsequencesCount how many non-empty subsequences of up to 20 integers sum exactly to a given target S.Medium4BacktrackingBrute force+1No attempts yet2s256 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
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
Remarkable PrimesGiven N, output all N-digit primes whose every left-hand prefix (1 to N digits) is also prime, in ascending order.Medium4BacktrackingMath+1No attempts yet2s4 MBJudgeable
Number Board JumpCount the distinct length-6 digit strings obtainable by starting anywhere on a 5x5 digit board and making five moves to adjacent cells.Medium4DFSBrute force+1No attempts yet2s128 MBJudgeable
Shut the Box IGiven a target sum and a sorted list of open card values, choose the subset summing to the target that is lexicographically largest when sorted.Medium4BacktrackingArray+2No attempts yet1s128 MBJudgeable
TransportWith at most 20 items, choose a subset whose total weight is at most W and whose total value is as large as possible.Medium4Brute forceBacktracking+1No attempts yet1s128 MBJudgeable
Bale ShareAssign N bales (N up to 20) to three barns so the largest barn total is as small as possible, and print that smallest possible largest total.Medium4Brute forceRecursion+2No attempts yet1s128 MBJudgeable
The Sultan's SuccessorsFor each 8x8 board, place 8 non-attacking queens to maximize the sum of the numbers on the occupied squares.Medium4BacktrackingRecursion+2No attempts yet1s128 MBJudgeable
Mapping the RouteSimulate a west, north, east, south backtracking search on a small walled grid, number the route cells, mark other visited cells with ???, and draw the maze.Medium4DFSBacktracking+2No attempts yet1s128 MBJudgeable
LottoFor each set of k numbers in ascending order, print all 6-element subsets in lexicographic order, separated by blank lines.Medium4BacktrackingRecursion+1No attempts yet1s128 MBJudgeable
Who owns the Amiga?Given constraint lines over five rooms, decide whether the Amiga owner is uniquely determined and print that student, or state it cannot be found.Medium4Brute forceImplementation+2No attempts yet1s128 MBJudgeable
Making ZeroInsert +, -, or a space between consecutive numbers 1 to N and print every expression that evaluates to 0, in ASCII order.Medium4BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
BalanceCount the orders and pan choices for placing n distinct weights so the left pan is never heavier than the right at any step.Medium4Brute forceBacktracking+2No attempts yet2s128 MBJudgeable
Peg SolitaireMove pegs by jumping over adjacent pegs into empty holes to leave as few pegs as possible with the fewest moves.Medium4BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
DraughtsFind the most dark pieces one light piece can capture in a single chain of diagonal jumps on a 10x10 draughts board.Medium4BacktrackingDFS+1No attempts yet2s128 MBJudgeable
Balanced TeamsSplit twelve cows with given skill levels into four teams of three to minimize the gap between the strongest and weakest team sums.Medium4Brute forceBacktrackingNo attempts yet1s128 MBJudgeable
Treasure HuntersAssign up to 8 treasures to up to 6 hunters with differing valuations to minimize the gap between the richest and poorest hunter totals.Medium4BacktrackingBrute forceNo attempts yet1s128 MBJudgeable
Maximum Jumps for a Checkers KingGiven up to 20 checkerboards, find for each board the red king with the longest capture chain and print its row, column, and jump count.Medium4BacktrackingDFS+1No attempts yet1s256 MBJudgeable
Two's Round TripsList every route that starts at house 2, visits no house twice, returns to house 2, and print them as digit strings in numeric order.Medium4BacktrackingDFS+1No attempts yet1s256 MBJudgeable
QuentoFind a no-revisit path using exactly M digits on the fixed 3x3 board whose left-to-right value equals N and print the lexicographically smallest one.Medium4BacktrackingDFSNo attempts yet1s256 MBJudgeable
Wi-Fi Towers (Small)Choose which towers to upgrade to protocol B so the total score is maximized, where upgrading a tower forces every tower in its range to be upgraded too.Medium4GraphBrute force+1No attempts yet5s512 MBJudgeable
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.Medium4BacktrackingBrute force+2No attempts yet5s512 MBJudgeable
N and M (7)Given N distinct numbers and a length M, print every length-M sequence drawn from the numbers with repetition allowed, deduplicated and in increasing lexicographic order.Medium4BacktrackingRecursion+2No attempts yet1s512 MBJudgeable
N and M (8)Given N distinct natural numbers and a length M, print all non-decreasing sequences of length M drawn from the numbers, in lexicographic order.Medium4BacktrackingSorting+1No attempts yet1s512 MBJudgeable
N and M (9)Given N numbers (with duplicates) and length M, print every distinct length-M selection in increasing lexicographic order, using each copy at most once.Medium4BacktrackingSorting+1No attempts yet1s512 MBJudgeable
N and M (11)Given N numbers and a length M, list every length-M sequence drawn from the numbers, allowing repeats, in increasing lexicographic order without duplicates.Medium4BacktrackingRecursion+2No attempts yet1s512 MBJudgeable
N and M (12)Given N numbers and a length M, list all non-decreasing length-M sequences drawn from the numbers with repetition, in lexicographic order.Medium4BacktrackingSorting+2No attempts yet2s512 MBJudgeable
First In Last OutAssign distinct hexadecimal digits to the letters in LIST + FILO = STACK so the addition holds, and print every solution in lexicographic order.Medium4Brute forceBacktracking+2No attempts yet1s32 MBJudgeable
Counting Langford SequencesCount Langford sequences of length 2n where the numbers at positions x and y are equal, for n up to 12.Medium4BacktrackingRecursion+2No attempts yet2s512 MBJudgeable
Muscle LossCount orderings of N workout kits (N at most 8) such that a starting total of 500, which drops by K each day, never falls below 500.Medium4Brute forceBacktracking+2No attempts yet1s256 MBJudgeable
Broken CalculatorStarting from 1 on a calculator limited to D digits, find the largest value reachable after exactly P multiplications by digits 2-9, or report -1 if impossible.Medium5BacktrackingBrute force+2No attempts yet2s128 MBJudgeable
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.Medium5BacktrackingCombinatorics+1No attempts yet2s128 MBJudgeable
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.Medium5CombinatoricsBacktracking+2No attempts yet2s128 MBJudgeable
The Famous Seven PrincessesCount connected 7-cell shapes on a 5x5 grid of S/Y students where at least 4 cells are S.Medium5BacktrackingDFS+1No attempts yet2s256 MBJudgeable
Alphabet PathFind the longest path from the top-left cell of a grid moving to adjacent cells while never revisiting a letter already used, maximizing visited cells.Medium5BacktrackingDFS+1No attempts yet2s256 MBJudgeable
SequenceFind the K-th lexicographically smallest non-decreasing sequence of N positive integers summing to M.Medium5BacktrackingCombinatorics+1No attempts yet2s128 MBJudgeable
Inequality SignsGiven a sequence of < and > signs, place k+1 distinct digits 0-9 to satisfy all comparisons and output the lexicographically largest and smallest resulting digit strings.Medium5BacktrackingGreedy+1No attempts yet1s256 MBJudgeable
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.Medium5BacktrackingCombinatorics+1No attempts yet2s64 MBJudgeable
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.Medium5BacktrackingCombinatorics+1No attempts yet1.5s128 MBJudgeable
SudokuFill the five empty cells (marked 0) in a 9x9 Sudoku grid so every row, column, and 3x3 box contains the digits 1 through 9 exactly once.Medium5BacktrackingImplementation+2No attempts yet1s128 MBJudgeable
SafecrackerGiven a target T and up to 12 distinct uppercase letters, find five distinct letters whose signed power sum equals T; if several work, print the lexicographically greatest string.Medium5Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Sum It UpGiven a target and up to 12 numbers, list every distinct subset sum equal to the target, sorted in decreasing lexicographic order.Medium5BacktrackingSorting+2No attempts yet1s128 MBJudgeable
The ClocksGiven nine clock dials and nine moves that each rotate a fixed subset of dials by 90 degrees, find the shortest move sequence that sets every dial back to 12 o'clock.Medium5Brute forceBacktracking+2No attempts yet1s256 MBJudgeable
Listing Square Arrangements in Lexicographic OrderList every partition of n whose parts are non-increasing, and print the sequences in decreasing lexicographic order.Medium5BacktrackingRecursion+2No attempts yet1s128 MBJudgeable
Escaping the FarmAmong up to 20 cow weights, find the largest subset whose base-10 sum produces no carry in any digit position.Medium5Bit manipulationBrute force+1No attempts yet1s128 MBJudgeable
SlurpysGiven up to 10 short strings, decide whether each one is a Slurpy, meaning a Slimp followed by a Slump under the recursive grammar in the statement.Medium5RecursionString+2No attempts yet1s128 MBJudgeable
Peculiar PrimesList every integer in [X, Y] whose prime factors all belong to a given set of at most 10 primes, or print none.Medium5BacktrackingMath+2No attempts yet1s128 MBJudgeable
BananasDecide for each word whether it fits the recursive grammar of a monkey language, where words wrap other words in N and in B...S.Medium5StringRecursion+2No attempts yet1s128 MBJudgeable
Pattern GeneratorFor each (n, k) pair, print all n-bit strings with exactly k ones in decreasing numeric order, separated by blank lines.Medium5BacktrackingRecursion+2No attempts yet1s128 MBJudgeable
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.Medium5Dynamic programmingBacktracking+2No attempts yet1s128 MBJudgeable
TähekabeOn an N x N letter grid, decide for each of up to 10 query words whether a simple path from the start cell spells it, without reusing a cell.Medium5BacktrackingDFS+2No attempts yet1s1024 MBJudgeable
TransportationChoose a subset of passenger orders so that no route segment exceeds capacity n, maximizing total revenue.Medium5BacktrackingBrute forceNo attempts yet1s128 MBJudgeable
RelocationSplit up to 10 furniture items between two cars with capacity limits so that every item gets moved in the fewest number of paired trips.Medium5Dynamic programmingBinary search+2No attempts yet1s128 MBJudgeable
Network SaboteurSplit N nodes (N <= 20) into two sets A and B so the total weight of edges crossing between them is maximized.Medium5Brute forceBacktracking+1No attempts yet1s128 MBJudgeable
MinesweeperCount the largest possible number of second-row mines, including the marked ones, that fits the first-row digit clues.Medium5BacktrackingBrute forceNo attempts yet1s128 MBJudgeable
Opening the SafeDecide for each given quadruple of digits whether its four numbers can be combined with arithmetic operations and parentheses to make 24.Medium5BacktrackingBrute forceNo attempts yet1s128 MBJudgeable
VirologyDecide for each 14-gene sample whether the genes split into four triples or runs plus one pair.Medium5BacktrackingBrute forceNo attempts yet3s128 MBJudgeable
N-QueenCount the ways to place N non-attacking queens on an N by N board for N under 15.Medium5BacktrackingBit manipulationNo attempts yet10s128 MBJudgeable
NonogramDecide whether exactly one black-and-white grid fits the given row and column run lengths and print it, else print not unique.Medium5BacktrackingBrute force+1No attempts yet3s128 MBJudgeable
Make the target from four numbersDecide whether the first four integers can form the fifth using each exactly once with +, -, *, / and parentheses.Medium5Brute forceBacktracking+1No attempts yet1s128 MBJudgeable
GREAT + SWERC = PORTOCount the assignments of distinct digits to letters that make the word sum correct with nonzero leading letters.Medium5BacktrackingBrute forceNo attempts yet2s256 MBJudgeable
Permutation with no spacesRecover the permutation from 1 to N whose decimal forms concatenate to the given digit string, choosing the lexicographically smallest one on ties.Medium5BacktrackingBrute force+1No attempts yet1s256 MBJudgeable
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.Medium5BacktrackingCombinatorics+1No attempts yet1s256 MBJudgeable
BoggleFind every dictionary word that can be spelled on each letter grid with adjacent cells and no cell reused, treating q as qu.Medium5BacktrackingTrie+1No attempts yet1s256 MBJudgeable
Each digit at most twiceFind the largest integer L not greater than U whose decimal digits each appear at most twice.Medium5BacktrackingGreedy+1No attempts yet3s256 MBJudgeable
CheckersFind the Black piece that captures every White piece in one chained jump, or report Multiple or None.Medium5BacktrackingDFS+1No attempts yet2s256 MBJudgeable
Map ColouringColor each map with the fewest colors so bordering countries differ and print 1 to 4, or many when more are needed.Medium5BacktrackingGraphNo attempts yet5s256 MBJudgeable
CheckersCount the black kings that can capture all white kings in one chain of diagonal jumps.Medium5BacktrackingDFSNo attempts yet2s256 MBJudgeable
KenKen You Do It?Count the assignments of numbers 1 to n to the given cage cells that meet the target under the operator with distinct values in shared rows and columns.Medium5BacktrackingBrute forceNo attempts yet2s256 MBJudgeable
2048 (Hard)Slide and merge tiles on an N by N board for at most ten moves to maximize the largest tile.Medium5Brute forceBacktracking+1No attempts yet1s512 MBJudgeable
2048 (Easy)Find the largest tile reachable within at most five 2048 moves on a given board where no new tiles appear.Medium5Brute forceBacktracking+1No attempts yet1s512 MBJudgeable
Googlander (Small)Count all distinct walks on an R by C grid where the walker moves straight or turns right and follows forced moves until both moves are blocked.Medium5BacktrackingSimulationNo attempts yet5s512 MBJudgeable
Arithmetic Digit Numbers 2Count the integers from 1 to N, with N up to 10^18, whose decimal digits form an arithmetic sequence.Medium5BacktrackingCombinatorics+1No attempts yet0.5s512 MBJudgeable
Survivor (Small)Pick which foods to eat and in what order, respecting each shelf life, to maximize total survival time.Medium5BacktrackingDynamic programmingNo attempts yet5s512 MBJudgeable
Dire Straights (Small)Split the hand into groups of consecutive values to make the shortest group as long as possible.Medium5BacktrackingSortingNo attempts yet5s512 MBJudgeable
Doubly-sorted grid (small)Given a partially filled R by C letter grid with R and C at most 4, count the completions whose rows and columns are non-decreasing modulo 10007.Medium5BacktrackingDynamic programmingNo attempts yet5s512 MBJudgeable