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
Letter ArithmeticAssign distinct digits to letters so that each given letter word plus a second equals a third, then print the three numeric values.Medium7BacktrackingMath+2No attempts yet1s128 MBJudgeable
TripGiven two strings, print all longest common subsequences in lexicographic order without duplicates.Medium7Dynamic programmingBacktracking+2No attempts yet1s128 MBJudgeable
PuzzlestanGiven N groups of M lettered items and statements about which items share or do not share an owner, reconstruct the full assignment of items to guests.Medium7Union-findBacktracking+2No attempts yet1s128 MBJudgeable
Destroying SquaresGiven an n x n matchstick grid (n <= 5) with some sticks already removed, find the minimum number of additional sticks to remove so that no square remains complete.Medium7BacktrackingBit manipulation+2No attempts yet5s128 MBJudgeable
Lattice AnimalsCount free n-polyominoes (up to rotation and reflection) that fit inside a w by h rectangle, with n up to 10.Medium7BacktrackingBrute force+2No attempts yet2s128 MBJudgeable
Queen KingdomOn an n by n board with pillars blocking queens' attacks, find the maximum number of non-attacking queens and the number of placements attaining it.Medium7BacktrackingBrute force+2No attempts yet2s128 MBJudgeable
MinesweeperGiven a partially revealed Minesweeper grid, mark each unrevealed cell as definitely a mine, definitely safe, or undetermined across all consistent arrangements.Medium7BacktrackingBrute forceNo attempts yet1s128 MBJudgeable
Fighting for TrianglesOn a triangular board with some edges already drawn, two players alternate adding edges, claiming a unit triangle when their edge completes it. Decide the winner with optimal play.Medium7Game theoryGraph+2No attempts yet2s512 MBJudgeable
Roman CorridorFind a left-to-right path through the grid whose symbol string is a valid Roman numeral and has the smallest decimal value.Medium7DFSGraph+2No attempts yet1s128 MBJudgeable
Vase CollectionGiven up to 100 shape-decoration pairs drawn from a 36 by 36 grid, find the largest k for which some k shapes and k decorations form a complete k by k block of owned pairs.Medium7Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Violet Jigsaw PuzzleCount how many ways to place and rotate the given pieces into an n by m rectangle so that all touching sides match tab-to-blank and border sides are flat.Medium7BacktrackingImplementation+1No attempts yet5s128 MBJudgeable
Mastermind IIGiven c codes and their A/B compatibility scores with a hidden code of length c, find the lexicographically smallest code consistent with all scores.Medium7Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
AllianceGiven a bipartite graph, pick the smallest set of edges so that every vertex which has any edge has at least one chosen incident edge.Medium7GraphGreedy+2No attempts yet1s128 MBJudgeable
Truncatable PrimesCount integers in [a, b] whose every prefix from the left is prime.Medium7BacktrackingNumber theoryNo attempts yet1s512 MBJudgeable
Jigsaw PuzzleGiven each piece's unordered neighbor list and the first two pieces of the top row, reconstruct the N by M puzzle grid or report that it is not unique.Medium7BacktrackingGraphNo attempts yet1s128 MBJudgeable
Up a TreeGiven three garbled preorder, inorder and postorder outputs from mixed-up recursive calls, list every call assignment and the smallest tree that fits each one.Medium7TreeBacktracking+2No attempts yet6s128 MBJudgeable
Lost ListsRebuild the lexicographically smallest increasing list of distinct positive integers matching each sorted pairwise sum list, or print -1 when none exists.Medium7BacktrackingSorting+1No attempts yet1s128 MBJudgeable
Subway MapDecide whether every station label fits above or below the line covering its own station point and no other, with no two labels overlapping.Medium7BacktrackingGeometry+1No attempts yet1s128 MBJudgeable
HomeworkChoose the phone call order that lets all N students finish their homework in the shortest time.Medium7BacktrackingGreedy+1No attempts yet2s128 MBJudgeable
Disperse!Count the ways to split an N by N grid into two congruent halves along cell edges with perimeter exactly M.Medium7CombinatoricsGeometry+1No attempts yet1s128 MBJudgeable
Box TopplingDecide if every standing box on an n by n floor can be toppled flat in some order and direction without leaving the floor or overlapping.Medium7BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Movie Theater SeatingDecide whether S solo guests and C couples fit into R rows of 8 seats with reserved seats while keeping neighbors and front seats empty.Medium7Dynamic programmingBit manipulation+1No attempts yet2s64 MBJudgeable
Royal GemsFill each cell of an n by m board with one of four gems to maximize the ruby count while every ruby, emerald, and sapphire neighbors the required higher gems.Medium7Dynamic programmingBacktracking+2No attempts yet1s128 MBJudgeable
Letter CubesGiven words that a set of letter cubes can spell, deduce which six letters sit on each cube.Medium7BacktrackingGraphNo attempts yet1s128 MBJudgeable
Triangulation and Triangle CountsDecide whether a number sequence matches the per-vertex triangle counts of some polygon triangulation and print its triangles.Medium7BacktrackingGraph+1No attempts yet1s128 MBJudgeable
Treasure ChestsOpen up to 12 treasure chests in the order that leaves the most keys, spending colored keys before wild ones to fill each lock.Medium7Dynamic programmingBit manipulation+1No attempts yet1s128 MBJudgeable
Holodeck HackingCount the positive integers X whose sum with their digit reversal equals the given Y.Medium7BacktrackingMathNo attempts yet2s128 MBJudgeable
VivoParc Animal AssignmentAssign one of four species to each of up to 100 enclosures so visible pairs differ, and print the lexicographically smallest valid assignment.Medium7BacktrackingGraphNo attempts yet1s128 MBJudgeable
Young diagrams and Young tableauxCount the fillings of the given Young diagram with numbers 1 to N that rise weakly across rows and strictly down columns.Medium7Dynamic programmingCombinatorics+1No attempts yet3s128 MBJudgeable
Plastic BagsPack every item weighing up to 2000 grams into capacity limited bags, including one free bag set by total price, at the lowest extra cost.Medium7BacktrackingBrute forceNo attempts yet1s128 MBJudgeable
JawbreakRemove groups of at least 3 same-coloured connected balls to maximize the sum of squared group sizes plus a 1000 point clearing bonus.Medium7BacktrackingSimulation+1No attempts yet2s512 MBJudgeable
PairPair up equal digits on a board of at most 5 by 5 through empty squares to remove the most pairs with the smallest total path length.Medium7BacktrackingBFS+1No attempts yet2s512 MBJudgeable
Magic SquareFill the empty cells with the unused numbers from 1 to N squared so every row, column, and both diagonals share one sum.Medium7BacktrackingBrute force+1No attempts yet2s1024 MBJudgeable
Clearing an N×M BoardRoll a ball that slides until blocked on a board with obstacles and find the fewest slides that visit every empty square.Medium7BacktrackingBFS+1No attempts yet3s256 MBJudgeable
DominosaReconstruct the domino tiling of an n by n+1 grid where each unordered symbol pair appears exactly once.Medium7BacktrackingBrute forceNo attempts yet1s128 MBJudgeable
Missing Piece 2001Decide whether a sliding-tile board reaches a target layout within N moves and report the smallest such move count.Medium7BacktrackingBFS+1No attempts yet1s128 MBJudgeable
Basin City SurveillanceDecide whether k vertices can be chosen so no two are adjacent in a graph of degree at most four.Medium7BacktrackingGraph+1No attempts yet2s256 MBJudgeable
Key to KnowledgeReconstruct the true-or-false key of up to 30 questions from each student's answers and score, printing the unique key or the count of matching keys.Medium7BacktrackingBrute force+1No attempts yet10s256 MBJudgeable
Three SquaresFind the smallest integer side length so that three equal axis-aligned squares placed on integer grid lines cover all given points.Medium7Binary searchBacktrackingNo attempts yet3s256 MBJudgeable
Can't stop playingStick each arriving power-of-two block to the left or right end, merge equal neighbours, and report if one block can remain with the smallest direction string.Medium7Dynamic programmingBit manipulation+2No attempts yet10s256 MBJudgeable
Guillotine Card GameCompute each player's final score in a three-player card game where one player secretly plays to minimize another player's score.Medium7Game theoryBacktracking+1No attempts yet3s128 MBJudgeable
Quarantine Station PlacementPlace quarantine stations on the fewest islands so every liner touches a station, or report that K stations cannot cover all liners.Medium7BacktrackingGraphNo attempts yet10s512 MBJudgeable
Calvinball championship, againColor n players with the fewest teams so no disliking pair shares a team, breaking ties by the lexicographically smallest assignment.Medium7BacktrackingGraph+1No attempts yet1s256 MBJudgeable
Calvinball team splitSplit up to 16 players into the fewest teams with no disliked pair sharing a team, breaking ties by the smallest assignment sequence.Medium7GraphBacktracking+2No attempts yet1s256 MBJudgeable
Calvinball team assignmentColor a graph of up to 15 players with the fewest colors so no dislike edge shares a color, printing the lexicographically smallest assignment.Medium7GraphBacktracking+1No attempts yet1s256 MBJudgeable
Calvinball team assignmentAssign up to 24 participants to the fewest teams so no disliking pair shares a team, and print the lexicographically smallest optimal assignment.Medium7BacktrackingGraph+1No attempts yet1s256 MBJudgeable
Calvinball minimum teamsSplit up to 20 players into the fewest teams with no disliking pair together, breaking ties lexicographically.Medium7BacktrackingGraph+1No attempts yet1s256 MBJudgeable
Calvinball team assignmentColor up to 15 players with the fewest teams so no disliking pair shares a team, breaking ties by lexicographic order.Medium7BacktrackingGraph+1No attempts yet1s256 MBJudgeable
Calvinball championship team splitColor up to 16 players with the fewest teams so no disliking pair shares a team, and print the lexicographically smallest optimal assignment.Medium7BacktrackingGraph+1No attempts yet7s512 MBJudgeable
Resistance Is (Not) Futile!Pick the fewest E-12 resistors whose sum is within 1 percent of the voltage over current, breaking ties by closeness.Medium7BacktrackingGreedy+1No attempts yet2s256 MBJudgeable
Inverse Divisor SumsPrint every integer M whose divisor sum equals the given N in increasing order, or none when no such number exists.Medium7BacktrackingNumber theory+1No attempts yet3s256 MBJudgeable
AvoiderCount self-avoiding walks of each length from a to b in the first quadrant starting east from the origin and print the sum.Medium7BacktrackingDFS+1No attempts yet1s256 MBJudgeable
Billiards SortingBall 1 moves through the triangular rack by swapping with a touching ball above or below, and the task asks for the fewest swaps that sort up to 15 balls.Medium7BFSGraph+1No attempts yet7s512 MBJudgeable
JAG-channel IIFind the lexicographically smallest member posting order consistent with the recorded top-to-bottom thread picks under move-to-front reordering.Medium7BacktrackingSimulation+1No attempts yet3s256 MBJudgeable
Sprinkler layoutSara tiles her fenced farm with tromino sprinklers around scarecrows using at most as many fence holes as fields.Medium7ImplementationSimulation+2No attempts yet1s128 MBJudgeable
WateringTile each 5x5 field with tromino sprinklers following the snake-order procedure and label them greedily with letters a to z.Medium7BacktrackingImplementation+2No attempts yet1s128 MBJudgeable
Namuk's Rotten Egg TrayPlace up to K nonoverlapping domino covers on an N by N tray to hide the most rottenness and report the remaining sum.Medium7BacktrackingSorting+1No attempts yet4s512 MBJudgeable
Elf Tournament LineupDecide whether 2^N elves can be lined up for a knockout tournament so every sensitive elf avoids its listed friends through the first K rounds.Medium7BacktrackingGraph+1No attempts yet5s512 MBJudgeable
Log Set (Small)Reconstruct the original integer multiset from the frequencies of all its subset sums, breaking ties by sorted order.Medium7BacktrackingSorting+1No attempts yet5s512 MBJudgeable
Can't Stop (Large)Find the longest run of consecutive roll sets where every set contains at least one of k chosen numbers.Medium7Sliding windowBacktrackingNo attempts yet30s512 MBJudgeable
Erdős and Szekeres Sequence ReconstructionRebuild the lexicographically smallest permutation of 1 to N whose increasing and decreasing subsequence lengths match the given arrays.Medium7BacktrackingGreedy+1No attempts yet5s512 MBJudgeable
Opening the Treasure ChestsOpen all N chests in the lexicographically smallest order with single-use typed keys taken from other chests, or report IMPOSSIBLE.Medium7GreedyGraph+1No attempts yet5s512 MBJudgeable
Yut Nori Board Check (Small)Decide whether the recorded throw sequence can produce the given board under the stated Yut Nori movement, capture, and shortcut rules.Medium7BacktrackingSimulation+1No attempts yet5s512 MBJudgeable
The Next NumberGiven N, the count of each nonzero digit in N defines the whole list; find the next number that has exactly those digit counts.Medium7GreedyBacktracking+2No attempts yet5s512 MBJudgeable
Choosing a T-shirtThree players alternately cross out numbers from 1 to n, each trying to leave the survivor highest on his own ranking; find the survivor.Medium7Game theoryBacktracking+1No attempts yet2s256 MBJudgeable
Finding a string with enough inversionsFind the lexicographically smallest permutation of the first N lowercase letters with at least V inversions that is not smaller than the given string S.Medium7BacktrackingCombinatorics+1No attempts yet2s512 MBJudgeable
Mutalisk 2Given up to 20 SCVs with health, each attack deals 9, 3, and 1 damage to three distinct SCVs; find the minimum number of attacks to destroy all of them.Medium7Dynamic programmingBit manipulation+1No attempts yet2s512 MBJudgeable
Rock Paper Scissors RankingGiven each contestant's probabilities for scissors, rock, and paper, find the probability that contestant 1 finishes in place K of the recursive elimination tournament.Medium7ProbabilityDynamic programming+1No attempts yet2s512 MBJudgeable
Light UpPlace bulbs on white cells of an N by N Light Up board so every white cell is lit and each numbered black cell has the required count of adjacent bulbs, choosing the lexicographically smallest solution.Medium7BacktrackingBrute force+2No attempts yet2s256 MBJudgeable
MegaDamasGiven a checkers-like board with your and opponent pieces, find the maximum number of opponent pieces one capture move can take.Medium7DFSBacktracking+2No attempts yet2s512 MBJudgeable
Tecle & SomeList every way to split S into terms of at most D digits whose concatenated digits form a path on a phone keypad using each digit at most once.Medium7DFSBacktracking+1No attempts yet2s512 MBJudgeable
Crystal JailsGiven up to 27 small polycube blocks that may be rotated but not reflected, decide whether they tile a W x D x H box exactly.Medium7BacktrackingRecursionNo attempts yet8s512 MBJudgeable
Linear Ether GeometryConnect N libraries on a hallway to the internet using M cables and hubs, minimizing hubs first then total cable slack.Medium7GreedyBacktracking+1No attempts yet8s512 MBJudgeable
The divisor conquersPlace the N cards one at a time so each new card divides the sum of the cards already down, and print the lexicographically smallest winning order or No.Medium7BacktrackingGreedy+2No attempts yet8s512 MBJudgeable
Tight-Fit SudokuFill a 6 by 6 grid with digits 1 to 9 so no digit repeats in a row, column, or 3 by 2 box, including split squares holding two digits.Medium7BacktrackingImplementation+1No attempts yet2s512 MBJudgeable
Quality ExpressionsGiven a bracket expression with ? placeholders and per-arity limits, choose values so the expression is valid and its value is as large as possible.Medium7Dynamic programmingTree+1No attempts yet1s64 MBJudgeable
Safe road systemDelete the fewest road characters so every remaining road is connected to at least two neighbours under the given adjacency rules.Medium7GraphBacktracking+1No attempts yet1s64 MBJudgeable
Rather Perplexing Showdown (Large)Find the alphabetically earliest lineup of R, P and S players that lets a single-elimination tournament finish without any tie match.Medium7BacktrackingDivide and conquer+2No attempts yet5s512 MBJudgeable
Technobabble (Small)Given N topics (N <= 16) made of two words, find the largest number of topics that could have been formed by combining an existing first word with an existing second word.Medium7BacktrackingBrute force+2No attempts yet5s512 MBJudgeable
Placing TilesGiven a grid with blocked cells, cover every empty cell with 1 x k horizontal or vertical tiles (k is any positive integer, chosen per tile) and minimize the number of tiles.Medium7BacktrackingDynamic programming+2No attempts yet2s512 MBJudgeable
Pythagorean TriplesGiven N stick lengths, pair them into as many disjoint pairs as possible so each pair forms the legs of a primitive Pythagorean triple.Medium7GraphMath+2No attempts yet2s512 MBJudgeable
Mahjong Waiting TilesGiven a 13 tile mahjong hand numbered 1 to 9, list every tile still available that completes the hand into one head plus four bodies, or into seven distinct heads.Medium7BacktrackingRecursion+2No attempts yet1s256 MBJudgeable
Going DutchGiven each person's net balance from the receipts, find the minimum number of money transfers that settles everyone to zero.Medium7Dynamic programmingBit manipulation+2No attempts yet2s512 MBJudgeable
Twenty Four, AgainGiven four numbers in fixed order, find the minimum grade (parentheses plus adjacent-swap inversions) of an expression equal to 24 using each number once, with integer-only division.Medium7Brute forceBacktracking+2No attempts yet2s512 MBJudgeable
Deck of CardsTwo players alternate playing a card matching the table card in color or value; the first unable to move loses, so find the winner under optimal play.Medium7Game theoryGraph+2No attempts yet5s512 MBJudgeable
Single EliminationGiven the fixed win/loss outcome for every pair among 16 players, decide which players can be made champion by choosing all four rounds of pairings.Medium7BacktrackingDivide and conquer+2No attempts yet2s512 MBJudgeable
CapsulesFill a grid so each outlined region holds 1..n exactly once and no equal digits touch even diagonally, printing the lexicographically smallest solution.Medium7BacktrackingImplementation+2No attempts yet2s512 MBJudgeable
World Cup DrawSimulate the World Cup draw by placing each team into the leftmost group that keeps the rest of the pot placeable, then sort groups by total rank.Medium7GreedyBacktracking+2No attempts yet2s512 MBJudgeable
Frog placementAssign each of N frogs to a preferred pad so that every log, labeled with a topic, joins frogs whose interest levels agree on that topic, and print the lexicographically smallest assignment.Medium7BacktrackingGraph+2No attempts yet1s256 MBJudgeable
Delivery GuyOn a tree of N restaurants with demand A_i, maximize total delivered peppers in M time units, where each visit costs 1 to deliver and each edge costs 1 to traverse.Medium7TreeDynamic programming+2No attempts yet2s64 MBJudgeable
Chicken DeliveryChoose at most M of the chicken restaurants to keep open so that the sum over all houses of the distance to the nearest open restaurant is minimized.Medium7Brute forceBacktracking+2No attempts yet1s512 MBJudgeable
A Very Nasty Graph ProblemBuild the lexicographically smallest de Bruijn sequence of order N over two symbols, a shortest binary string containing every N-bit number.Medium7GraphDFS+2No attempts yet2s512 MBJudgeable
KMPEach of N scientists has letters from the first characters of their name words. For each query, decide whether its letters can be matched one each to distinct scientists, with order ignored.Medium7Bit manipulationDFS+2No attempts yet2s512 MBJudgeable
Bob's RummikubGiven tiles in hand and a legal table arrangement, find the largest number of hand tiles Bob can add while keeping the whole table partitionable into groups and runs.Medium7BacktrackingBrute force+2No attempts yet2.5s512 MBJudgeable
Covering with Colored PaperOn a fixed 10x10 grid of 0s and 1s, cover every 1 with at most five squares of each size (1x1 through 5x5), non-overlapping and axis-aligned, using the fewest squares.Medium7BacktrackingGreedy+2No attempts yet1s512 MBJudgeable
Laboratory 3Given a grid with walls and up to 10 viruses, choose M of them to activate simultaneously and minimize the time until the virus fills every empty cell, or print -1.Medium7BFSBacktracking+2No attempts yet0.25s512 MBJudgeable
Ant in a Hexagonal WebOn an infinite hexagonal web, count the ant walks that make exactly N turns before first revisiting a vertex, where the first step is fixed north.Medium7DFSBacktracking+2No attempts yet1s1024 MBJudgeable
Knapsack PackingGiven the multiset of all 2^n subset sums of n unknown non-negative weights, reconstruct the weights in non-decreasing order or report impossible.Medium7SortingGreedy+2No attempts yet2s512 MBJudgeable
NVWLSGiven a dictionary of words and a consonant-only message, reconstruct a sentence whose words concatenate to the message after vowels and spaces are removed, maximizing total vowels.Medium7Dynamic programmingString+2No attempts yet6s1024 MBJudgeable
TrapCount the self-avoiding walks of n unit grid steps that start at (0,0) going right and are trapped: no further step can be added without self-intersection.Medium7BacktrackingDFS+2No attempts yet2s512 MBJudgeable