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
Name GeneratorSplit a string into k different non-empty consecutive parts, or report that no such split exists, choosing the lexicographically smallest sequence.Medium5StringGreedy+1No attempts yet2s256 MBJudgeable
ABCDEGiven an undirected friendship graph, decide whether it contains a simple path of five distinct vertices, that is, a path with four edges.Medium5GraphDFS+2No attempts yet2s512 MBJudgeable
Smallest sum no subsequence can makeGiven N ≤ 20 numbers, find the smallest natural number that is not the sum of any non-empty subsequence.Medium5BacktrackingBrute force+1No attempts yet2s512 MBJudgeable
BFFs (Small)Find the largest subset of kids that can be arranged in a circle so each kid sits next to their BFF.Medium5GraphBrute force+1No attempts yet5s512 MBJudgeable
Paper PiecesCut an N x M digit grid into horizontal or vertical strips and maximize the sum of the numbers those strips form.Medium5Brute forceBit manipulation+2No attempts yet2s512 MBJudgeable
Flower PathPlace three plus-shaped flowers of 5 cells each on an N x N grid so no two overlap, all stay inside, and the total rented-cell cost is minimal.Medium5Brute forceBacktracking+2No attempts yet2s256 MBJudgeable
SlurpyDecide whether each uppercase string is a Slurpy, meaning a Slimp immediately followed by a Slump, where both are defined by recursive grammar rules.Medium5RecursionString+2No attempts yet2s512 MBJudgeable
Connect3Given Black's opening column x and White's winning square (a,b), count final 4x4 board states where White's move there completes three in a row first.Medium5BacktrackingSimulation+1No attempts yet0.5s512 MBJudgeable
CCTV Blind SpotsPlace each of up to 8 cameras in one of its allowed rotations on an 8x8 grid so that the fewest cells stay unwatched, given walls block sight.Medium5Brute forceBacktracking+2No attempts yet1s512 MBJudgeable
Jumping King Jelly (Small)Given an N by N board with jump numbers, move only right or down from the top-left and reach the bottom-right, or report failure.Medium5DFSBacktracking+2No attempts yet1s128 MBJudgeable
Two DotsGiven a grid of colored dots, decide whether any cycle of four or more same-colored dots exists, where consecutive dots touch by an edge.Medium5DFSGraph+2No attempts yet2s512 MBJudgeable
The Great Revegetation (Bronze)Assign each of N pastures one of 4 grass types so that every listed pair differs, choosing the lexicographically smallest N-digit answer.Medium5GraphGreedy+2No attempts yet2s512 MBJudgeable
⚾Given each of 9 players' predetermined results over N innings, choose a batting order with player 1 batting 4th to maximize total runs scored.Medium5Brute forceSimulation+2No attempts yet1s512 MBJudgeable
Building a Large NumberGiven N and a digit set K (size 1 to 3), find the largest number at most N whose digits all come from K.Medium5GreedyBacktracking+2No attempts yet1s256 MBJudgeable
Decreasing NumberGiven N, find the N-th smallest non-negative integer whose digits strictly decrease from left to right, or output -1 if none exists.Medium6CombinatoricsGreedy+2No attempts yet1s512 MBJudgeable
Word PuzzleCount how many words from a fixed dictionary can be spelled by paths of adjacent, non-repeating cells in a 5x5 letter grid.Medium6TrieBacktracking+2No attempts yet2s128 MBJudgeable
Student ShuffleCount permutations of up to 16 students so that every pair of adjacent heights differs by more than a given value K.Medium6Dynamic programmingBit manipulation+2No attempts yet2s128 MBJudgeable
Composite PrimeGiven up to 1e5 queries with N as large as 10^7, find the largest composite number at most N whose every proper contiguous digit substring of length 2 or more is prime.Medium6BacktrackingMath+2No attempts yet1s1024 MBJudgeable
Shom SquareConstruct the lexicographically smallest N by N grid using digits 0 to D-1 so every row and column contains all D values at least once.Medium6BacktrackingGreedy+1No attempts yet2s128 MBJudgeable
Number Connection PuzzleFind a Hamiltonian path on an m by n grid (both even, up to 8) connecting two given endpoints, moving only to adjacent cells without crossing itself, or report -1.Medium6BacktrackingGraph+1No attempts yet5s128 MBJudgeable
Sum of Lucky NumbersWrite N as a sum of the fewest numbers made only of digits 4 and 7, breaking ties by the lexicographically smallest sequence.Medium6Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Anti-PalindromeRearrange all characters of a string to form the lexicographically smallest anti-palindrome, where each pair of symmetric positions must differ, or report impossible.Medium6GreedyString+2No attempts yet2s128 MBJudgeable
Making PrimesCombine all N (up to 6) given numbers with +,-,*,/ and parentheses in every possible way to find the smallest and largest prime value obtainable.Medium6BacktrackingBrute force+2No attempts yet2s128 MBJudgeable
Box PuzzlePlace n^2 rotatable cube boxes into an n by n grid so touching side faces match and outward faces show 0, then output the arrangement and rotation counts.Medium6BacktrackingMatrix+2No attempts yet2s128 MBJudgeable
Finding the Maximum Score PathFind the maximum-score simple path from the top-left to bottom-right cell of an N x N grid moving only in four directions without revisiting cells.Medium6BacktrackingDFS+2No attempts yet2s128 MBJudgeable
Restoring Calculation ExpressionsInsert +, -, or * between digits of a string (length up to 9, no leading zero numbers) to produce all expressions evaluating to 2000, sorted lexicographically.Medium6BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
SudokuSolve a given 9x9 Sudoku puzzle via backtracking and output the lexicographically smallest completed board if multiple solutions exist.Medium6BacktrackingMatrix+1No attempts yet2s256 MBJudgeable
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.Medium6BacktrackingCombinatorics+1No attempts yet2s128 MBJudgeable
Wireless Communication Base StationsAssign positive integer frequencies to at most 12 base stations so adjacent stations (within distance 20) differ by at least 2, minimizing the count of distinct frequencies used.Medium6BacktrackingGraph+1No attempts yet2s128 MBJudgeable
SudokuSolve a standard 9x9 sudoku puzzle by filling empty cells so every row, column, and 3x3 box contains digits 1 through 9, using backtracking search.Medium6BacktrackingMatrix+1No attempts yet1s256 MBJudgeable
Restoring Equal-Length SticksGiven stick pieces, find the smallest common stick length so all pieces can be partitioned into groups summing to that length, and output the grouping.Medium6BacktrackingMath+1No attempts yet1s128 MBJudgeable
Good SequenceConstruct the lexicographically smallest square-free string of length N over the alphabet {1,2,3} (no two adjacent equal-length substrings identical).Medium6GreedyString+1No attempts yet1s128 MBJudgeable
24 Matchstick PuzzleGiven N and K, remove exactly N matchsticks from a 3x3 grid of 24 matchsticks so that exactly K complete squares remain and every leftover stick belongs to some square.Medium6BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Password Name FinderFind the minimum set of 2 to 5 distinct girl names of length 3 to 8 whose pairwise concatenations reconstruct all given passwords.Medium6StringBacktracking+1No attempts yet1s128 MBJudgeable
Bar CodeReconstruct the unique binary digit sequence from a partially unreadable bar code grid of black/white/unknown squares, or report it cannot be determined.Medium6BacktrackingString+1No attempts yet1s128 MBJudgeable
Galaxy InterconnectionGiven a low-degree graph with a proper k-coloring, output -1 if any edge shares a color, otherwise count vertices that start a simple path of k vertices visiting all k colors.Medium6GraphDFS+1No attempts yet3s256 MBJudgeable
16x16 SudokuSolve a given 16x16 Sudoku puzzle so each row, column, and 4x4 box contains letters A to P exactly once, given a unique solution exists.Medium6BacktrackingMatrix+1No attempts yet3s128 MBJudgeable
Enjoyable CommunicationFind the k-th shortest simple path (by length then lexicographic node order) between two nodes in a directed graph with up to 50 nodes and k up to 200.Medium6Shortest pathGraph+1No attempts yet3s128 MBJudgeable
Starting LineupAssign 11 players to 11 positions, each with ability 0 to 100, maximizing total ability while avoiding zero-ability slots; every player suits at most 5 positions.Medium6BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
CranesChoose a subset of at most 15 crane locations, each with a radius, so that every pair's distance exceeds the sum of radii, maximizing the total squared radius.Medium6Brute forceGeometry+2No attempts yet1s128 MBJudgeable
Build a Square from SticksGiven up to 20 stick lengths, decide whether all sticks can be split into four groups of equal total length.Medium6BacktrackingRecursion+2No attempts yet1s128 MBJudgeable
No TippingCount the orders in which n packages can be removed from a lever on two fulcrums so the board never tips.Medium6BacktrackingBit manipulation+1No attempts yet1s128 MBJudgeable
Pride and Prejudice and ZombiesFor each number up to 18 digits, decide whether its digits split into two equal-length factors with no leading or consecutive zeros.Medium6Brute forceBacktracking+1No attempts yet1s128 MBJudgeable
BounceFind the shortest non-self-intersecting path on a hex grid from the top row to the bottom and back to the top row on the right, whose letters form a repeated pattern of given length. ExampleMedium6DFSBacktracking+2No attempts yet1s128 MBJudgeable
Don't Get RookedFind the maximum number of non-attacking rooks on a board up to 4x4 where walls block rook attacks.Medium6BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
A Puzzling ProblemPlace up to 5 fixed-orientation polyomino pieces, each labeled by index, to tile a 4x4 square exactly, printing the lexicographically smallest labeled grid or a failure message.Medium6BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Curling 2.0On a grid with destructible blocks, find the fewest throws to slide a curling stone from start to goal, where each slide continues until it hits a block or leaves the board.Medium6DFSBacktracking+2No attempts yet3s128 MBJudgeable
New FriendsGiven up to 10 town names, partition them into the fewest groups where every pair of names in a group differ by at most one Levenshtein edit (case ignored).Medium6StringGraph+2No attempts yet1s128 MBJudgeable
Shut the Box IIGiven open cards and a rolled total, pick the set summing to the total that maximizes the probability of shutting every card under optimal play, and report that probability.Medium6Dynamic programmingBacktracking+2No attempts yet1s128 MBJudgeable
Report RecoveryRebuild a space-stripped sales report by splitting each digit run into numbers, choosing the lexicographically smallest reconstruction consistent with the report's structure.Medium6BacktrackingBrute force+2No attempts yet3s128 MBJudgeable
Fridge LockGiven K rings each showing 3 to 49 positive integers and K linear equations, pick one number per ring satisfying all equations and print the selection.Medium6Brute forceMath+2No attempts yet1s128 MBJudgeable
HorseshoesOn an N x N grid (N at most 5) of parentheses, find the longest walk from the top-left cell, visiting each cell at most once, whose collected characters form a run of '(' followed by an equally long run of ')'.Medium6DFSBacktracking+2No attempts yet1s128 MBJudgeable
Connect the CowsCount the axis-parallel tours from the origin that turn exactly once at each of N (at most 10) given cow positions before returning to the origin.Medium6BacktrackingGeometry+2No attempts yet1s128 MBJudgeable
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.Medium6BacktrackingCombinatorics+2No attempts yet1s128 MBJudgeable
Plato's BlocksGiven three n by n shadow patterns, decide whether one connected solid built from unit cubes can cast all three shadows simultaneously.Medium6BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
AnagramFor each given word, print every distinct string formed by rearranging its letters, in lexicographic order with duplicates removed.Medium6BacktrackingSorting+2No attempts yet1s128 MBJudgeable
European railroad tracksGiven up to 8 distinct gauge lengths, find the smallest number of points on a line such that every gauge appears as a distance between two points.Medium6Brute forceBacktracking+1No attempts yet1s128 MBJudgeable
Even a Kindergartner Could Solve ThisDecide whether each string over the alphabet {, }, and comma is a valid set by the given grammar, where brace characters can be either delimiters or atoms.Medium6StringDynamic programming+2No attempts yet2s128 MBJudgeable
A Model RailroadPlace a non-self-crossing path of straight and curved rails in a small grid from a bottom connection to a top connection, maximizing the number of cells used.Medium6DFSBacktracking+2No attempts yet1s128 MBJudgeable
Game Show MathInsert +, -, *, / between the given numbers in order, left to right, so the running value hits the target; output the smallest expression or NO EXPRESSION.Medium6DFSBacktracking+1No attempts yet2s128 MBJudgeable
World CupGiven win/draw/loss records for 6 nations in a round-robin group, decide for each of four cases whether some assignment of the 15 match results produces those records.Medium6BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Letter GameGiven up to 7 collected letters and a dictionary, find all words or pairs of words with the maximum total letter-value score, using each collected letter at most as often as it appears.Medium6StringHash map+2No attempts yet1s512 MBJudgeable
Heating MainCount the ways to lay a single non-crossing path of four fixed pipe shapes from the top-left top side to the bottom-right right side, respecting fixed pipes and blocked garden cells on a grid of at most 10 by 10.Medium6BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Prime ScrabbleGiven up to 8 digit tiles, choose a placement order and direction to maximize the sum of prime-reading sums earned minus the values of unplaced tiles.Medium6Brute forceMath+2No attempts yet1s1024 MBJudgeable
Algarvu-ScrabbleGiven up to 8 digit tiles, place them one by one at either end of a row to maximize prime-direction scoring minus penalties for unused tiles.Medium6BacktrackingBrute force+2No attempts yet1s1024 MBJudgeable
Puzzle of NumbersGiven three digit-and-star patterns for A, B, and C with A + B = C, fill the stars to build the smallest valid equation.Medium6BacktrackingMath+2No attempts yet1s128 MBJudgeable
Operator SignsInsert + or - between adjacent numbers so the left-to-right value equals the target, keeping every partial result within 10000, and print the lexicographically smallest expression.Medium6Dynamic programmingBacktracking+2No attempts yet1s1024 MBJudgeable
Flip GameFind the minimum number of flips to turn all 16 pieces white or all black, where each move flips a chosen cell and its orthogonal neighbors.Medium6Brute forceBit manipulation+2No attempts yet1s128 MBJudgeable
Beth TableauxParse a propositional formula and either report it valid or print the lexicographically smallest falsifying assignment.Medium6BacktrackingImplementation+2No attempts yet2s64 MBJudgeable
A Knight's JourneyFind the lexicographically smallest knight's tour that visits every square of a rectangular board with at most 26 squares exactly once.Medium6BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Dory's PhonebookGiven a dictionary of words and a phone number, find every encoding of the number as a space-separated sequence of dictionary words, sorted lexicographically.Medium6TrieBacktracking+2No attempts yet1s128 MBJudgeable
SudokuFill every empty cell of a 9x9 Sudoku grid so each row, column, and 3x3 box contains the digits 1 through 9 exactly once.Medium6BacktrackingMatrixNo attempts yet1s128 MBJudgeable
Water pipeConnect two points with axis-aligned pipe segments of given lengths and counts, turning only 90 degrees, and minimize the number of segments used.Medium6BFSGraph+2No attempts yet1s128 MBJudgeable
BackpackChoose a set of items whose total mass is at most p, where each chosen item requires its named lower-indexed prerequisite to be chosen too.Medium6Dynamic programmingTree+1No attempts yet1s128 MBJudgeable
Pattern LockGiven the unit-segment graph left by an Android pattern, find a valid pattern of at least four dots that draws exactly it.Medium6BacktrackingGraph+1No attempts yet3s128 MBJudgeable
LeetDecide whether the plain word can be split so each distinct letter maps to one fixed leet block of length at most k.Medium6BacktrackingString+1No attempts yet2s128 MBJudgeable
KTXDecide whether a departure permutation can be reordered into ascending grade order using a direct main line and two LIFO bypass tracks.Medium6StackBacktracking+1No attempts yet1s128 MBJudgeable
Who needs 8 queens when you can have N?Find the lexicographically smallest placement of N non-attacking queens on an N by N board for each test case.Medium6BacktrackingRecursion+1No attempts yet1s128 MBJudgeable
Jill's Tour PathsList every simple route from the start village to the destination within the distance limit, ordered by length then village order.Medium6BacktrackingDFS+2No attempts yet1s128 MBJudgeable
BoggleFind all dictionary words on each 4x4 Boggle board with 8-direction steps without reuse, then report the total score, longest word, and word count.Medium6TrieDFS+1No attempts yet10s512 MBJudgeable
Powerbase FormatCount how many integers in each query range lack a powerbase form d1^1+...+dL^L within the length bound using the given digits.Medium6BacktrackingDynamic programming+1No attempts yet1s128 MBJudgeable
Suspicious OrdersCount the cliques in a network of up to 20 people whose combined ordered items cover at least one of the given attack combinations.Medium6BacktrackingBit manipulation+1No attempts yet1s128 MBJudgeable
Breaking the EquationsPick twelve values from the given set that satisfy the six addition equations and form the lexicographically smallest tuple.Medium6Hash mapBrute force+2No attempts yet1s128 MBJudgeable
WormholesCount the pairings of N wormholes into pairs so that walking right and teleporting through pairs can loop forever from some start.Medium6BacktrackingGraph+1No attempts yet1s128 MBJudgeable
Bowling Score AssistantGiven eight frames of bowling scores and the rival total, find the lexicographically smallest rolls in frames 9 and 10 that win, or report impossible.Medium6BacktrackingSimulation+1No attempts yet3s128 MBJudgeable
Loopy transitCount distinct directed simple cycles in a graph of up to 9 stations, treating rotations of a loop as one.Medium6GraphBacktracking+1No attempts yet2s256 MBJudgeable
TowersFill an n by n Latin square with heights 1 to n that matches fixed cells and border visibility counts, printing the smallest solution or no.Medium6BacktrackingBrute forceNo attempts yet10s256 MBJudgeable
ZGODANGiven a non-handsome integer with up to 1000 digits, find the nearest integer whose consecutive digits alternate between even and odd, printing both on a tie.Medium6GreedyString+1No attempts yet1s32 MBJudgeable
CarpetsDecide whether the given carpets, each usable rotated, cover a W by H room exactly with no overlap.Medium6BacktrackingRecursionNo attempts yet1s256 MBJudgeable
Calvinball Championship Team AssignmentAssign n players to the fewest teams so no rival pair shares a team, breaking ties by lexicographically smallest team numbers.Medium6BacktrackingGraph+1No attempts yet1s256 MBJudgeable
Calvinball team divisionColor up to 14 players with the fewest teams so rivals differ, breaking ties by the smallest team-number sequence.Medium6GraphBacktracking+1No attempts yet1s256 MBJudgeable
Black ViennaCount the three-suspect sets that can form the hidden circle while matching every investigation reply about the two players' hands.Medium6Brute forceBacktrackingNo attempts yet1s256 MBJudgeable
Kimagure CleanerFill in the forgotten turns and pick each run length inside its range so the cleaner ends at (X, Y), printing the smallest such log.Medium6BacktrackingMathNo attempts yet10s1024 MBJudgeable
Password-free alphabet arrangementArrange A to Z in one row so none of the given passwords appears as a contiguous block, choosing the smallest such order or reporting impossibility.Medium6BacktrackingString matching+1No attempts yet5s512 MBJudgeable
Paper folding 2Fold a 6 by 6 or smaller number grid along grid lines so overlapping cells add up, and maximize the value held in one cell.Medium6BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Power Swapper (Small)Count the ordered swap sequences that sort the permutation when each block size is used at most once on aligned ranges.Medium6BacktrackingBrute force+1No attempts yet5s512 MBJudgeable
Symmetric Trees (Small)Decide whether a colored tree with at most 12 vertices admits a planar straight-line drawing with a vertical line of symmetry.Medium6Brute forceTree+1No attempts yet5s512 MBJudgeable
Crime House (Small)Assign each masked passage to a person so inside and outside states stay valid and report the smallest possible final occupancy, or CRIME TIME.Medium6BacktrackingSimulationNo attempts yet5s512 MBJudgeable
The Bored Traveling Salesman (Small)Choose a start city and a depth-first ticket tour of the graph so the concatenated first-visit ZIP codes form the smallest number.Medium6BacktrackingDFS+1No attempts yet5s512 MBJudgeable
Can't Stop (Small)Find the longest consecutive run of roll sets where every set contains at least one of k chosen numbers.Medium6Sliding windowBacktrackingNo attempts yet5s512 MBJudgeable