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
Treasure Chests (Small)Open all N chests in the lexicographically smallest valid order using keys found inside chests, or report IMPOSSIBLE.Medium6BacktrackingDFS+2No attempts yet5s512 MBJudgeable
Street Tree Props (Small)Each of up to 10 trees needs one stick of strength B or two sticks summing to B, using the smallest total strength.Medium6BacktrackingSortingNo attempts yet5s512 MBJudgeable
Closet Room (Small)Place the maximum number of 2-cell closets with fixed door orientations on a grid with pillars so every door tile stays free and reachable from the entrance.Medium6BacktrackingBrute force+1No attempts yet5s512 MBJudgeable
Polygraph (Small)With at most 10 people, decide for each whether every satisfying assignment of truth-teller and liar types forces Truthtown, Liarville, or leaves it undecided.Medium6Brute forceSimulation+2No attempts yet5s512 MBJudgeable
EZ-SokobanOn a board of at most 12 by 12 with up to 5 boxes that must stay edge-connected, find the fewest box pushes to reach the goal arrangement.Medium6BFSSimulation+1No attempts yet5s512 MBJudgeable
Mine Layer (Small)Given a small Minesweeper-style clue grid (R is 3 or 5, C is 3 to 5), find the maximum number of mines the middle row can hold over all layouts that match the clues.Medium6Brute forceBacktracking+2No attempts yet5s512 MBJudgeable
Digital AdditionGiven a black and white picture formed by stacking three seven-segment digit rows, find the lexicographically smallest digit addition that could have produced it.Medium6ImplementationBrute force+1No attempts yet2s256 MBJudgeable
Word Puzzle 2Given a 5x5 letter grid and up to 20000 dictionary words, count how many words can be traced through adjacent cells without reusing a cell.Medium6DFSBacktracking+1No attempts yet2s128 MBJudgeable
Cash BookGiven N amounts and a signed total F, decide for each amount whether it is forced to be added, forced to be subtracted, or free, over all sign choices summing to F.Medium6Dynamic programmingBacktracking+2No attempts yet2s512 MBJudgeable
Construction ToyGiven up to nine distinct segment lengths, find the largest possible distance from a wall reachable by gluing triangles onto an initial base segment.Medium6GeometryBacktracking+1No attempts yet2s512 MBJudgeable
Tiling PolygonsTile a rectilinear polygon with 1x3 and 3x1 tiles, choosing at each step the lexicographically smallest covering grid.Medium6BacktrackingRecursion+2No attempts yet8s512 MBJudgeable
CoggleGiven a 5x5 letter grid and a dictionary, count how many dictionary words can be traced through adjacent cells without reusing a cell.Medium6BacktrackingTrie+1No attempts yet1s512 MBJudgeable
Two OperationsStarting from X = Y = 1, repeatedly add one variable to the other, and find the shortest (then lexicographically smallest) operation string that makes N appear.Medium6BFSGraph+2No attempts yet2s512 MBJudgeable
Trapezoid puzzleTile a triangular-grid hexagon of shaded cells with 3-triangle trapezoids, backtracking in a fixed canonical order and colouring pieces greedily so no two equal colours share an edge.Medium6BacktrackingGreedy+2No attempts yet0.5s1024 MBJudgeable
The Triangle GameGiven six numbered triangles, arrange all of them into a legal hexagon where touching edges match, and maximize the sum of the six outer edge numbers.Medium6Brute forceBacktracking+2No attempts yet2s512 MBJudgeable
KUBC League (Small)Given a tournament on N players, find the longest simple path starting at player 1 and output the lexicographically smallest such path.Medium6GraphDFS+2No attempts yet1s256 MBJudgeable
Tae and Dotori split a chocolate barCount assignments of U cells to T or D so each person's region is connected, the sizes differ by at most K, and neither region contains a 2x2 block.Medium6BacktrackingDFS+2No attempts yet2s512 MBJudgeable
Inserting operatorsGiven up to 11 numbers and counts of the four arithmetic operators, place the operators between adjacent numbers, evaluate left to right without precedence, and report the maximum and minimum results.Medium6Brute forceBacktracking+2No attempts yet2s512 MBJudgeable
Start and LinkSplit N people into two equal teams to minimize the difference between the teams' total pairwise ability sums.Medium6Brute forceBacktracking+1No attempts yet2s512 MBJudgeable
Go around the LabyrinthDecide whether a walk from the top-left corner can visit the other three corners and come back, where each non-entrance room collapses after one visit.Medium6GraphDFS+2No attempts yet2s512 MBJudgeable
Flow FreeGiven a 4x4 Flow Free board with 3 or 4 color pairs, decide whether all cells can be covered by non-crossing paths joining matching endpoints.Medium6BacktrackingDFS+1No attempts yet2s512 MBJudgeable
Shredding CompanySplit a digit string into contiguous pieces so their sum is as large as possible without exceeding a target, reporting rejection on ties and error when even the smallest sum is too big.Medium6BacktrackingBrute force+2No attempts yet2s512 MBJudgeable
Frog 3Assign each frog to a preferred pad so that every pair of pads joined by a log holds frogs with equal interest for that log's topic.Medium6GraphBacktracking+2No attempts yet1s256 MBJudgeable
Inserting Operators (2)Insert one of +, -, x, / between each adjacent pair from a limited supply, evaluating left to right with C++14 integer division, and report the largest and smallest results.Medium6BacktrackingBrute force+2No attempts yet2s512 MBJudgeable
Inserting Operators (3)Place the given +, -, *, / operators between N numbers to form an expression, then report the largest and smallest values it can take.Medium6Brute forceBacktracking+2No attempts yet2s512 MBJudgeable
Room NumberFind natural numbers A and B with A + B = N, no leading zeros, and no digit repeated across both numbers, minimizing A.Medium6Brute forceMath+2No attempts yet1s256 MBJudgeable
Pia Atelier: Alchemist of the Mystery CompetitionChoose and order 3 of up to 10 candidate 4x4 materials, placing each rotated onto a 5x5 furnace, to maximize a weighted color-sum quality.Medium6Brute forceSimulation+2No attempts yet3s512 MBJudgeable
Mosaic Logic PuzzleGiven clue numbers on a border-extended grid saying how many of the 3x3 neighbors are black, color cells black or report impossibility.Medium6BacktrackingDFS+2No attempts yet2s512 MBJudgeable
Digit RearrangementGiven A and B, rearrange the digits of A (no leading zero) to build the largest permutation that is still strictly less than B, or print -1.Medium6BacktrackingGreedy+2No attempts yet2s512 MBJudgeable
Insiders' Rock-Paper-ScissorsWith a fixed gesture matchup table and each player's throw sequence, decide whether Jiwoo can win while never repeating a gesture, given match order Jiwoo, Kyunghee, Minho and ties favoring the later player.Medium6SimulationImplementation+2No attempts yet2s512 MBJudgeable
Rotate Array 4Try every order of up to 6 rotation operations on the grid and report the largest possible minimum row sum after all rotations.Medium6Brute forceBacktracking+2No attempts yet1s512 MBJudgeable
Two-Pan BalanceGiven up to 13 distinct weights, count how many integers from 1 to their sum cannot be formed when each weight goes on the bowl side, the other pan, or unused.Medium6Brute forceBacktracking+2No attempts yet1s512 MBJudgeable
Integral PyramidGiven n and x, decide whether positive integers can fill the bottom row of Pascal-style sums so the single top cell equals x, and print a valid pyramid.Medium6CombinatoricsMath+2No attempts yet2s512 MBJudgeable
Bus PlanningSplit n kids (n up to 17) into the fewest groups so no two enemies share a group and each group has at most c kids, then output one valid grouping.Medium6Bit manipulationDynamic programming+2No attempts yet2s512 MBJudgeable
Rubber Duck Lovers ClubPick exactly P of N members and assign each a value in [xi, yi] so the P values sum to E, or report that this is impossible.Medium6GreedyBacktracking+2No attempts yet1s512 MBJudgeable
PasswordCount the Android-style 3x3 patterns whose segment directions match a given string, allowing any segment lengths, with no self-intersection allowed.Medium6DFSBacktracking+2No attempts yet2s512 MBJudgeable
Avoiding SurveillancePlace exactly 3 obstacles on empty cells of an N x N grid so that no teacher can see any student along its row or column.Medium6Brute forceBacktracking+2No attempts yet2s256 MBJudgeable
Weapon EngineeringOn a grid of at most 5 by 5 cells, place L-shaped triominoes (with the corner counted twice) so the covered cells' score is maximized.Medium6BacktrackingBrute force+2No attempts yet2s256 MBJudgeable
Mini BattleshipCount the ways to place k distinct ships of given sizes on an n by n grid so that hits, misses, and empty squares all match the observed board.Medium6BacktrackingBrute force+2No attempts yet6s512 MBJudgeable
Smallest Integer with K Distinct DigitsGiven N up to 10^18 and K up to 10, construct the smallest integer at least N that contains exactly K distinct decimal digits.Medium7Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
MafiaGiven guilt scores and a reaction matrix, the mafia Eunjin picks one night victim at a time and must survive as long as possible, returning the maximum number of nights.Medium7Bit manipulationDFS+2No attempts yet2s128 MBJudgeable
Paper CuttingDecide whether five fixed-shape pieces can be translated without rotation to exactly tile an L x L grid, then print the lexicographically smallest piece-number layout or gg if impossible.Medium7BacktrackingBit manipulation+2No attempts yet2s128 MBJudgeable
Bead NecklaceCount distinct linear arrangements of beads with given color counts (3 to 5 colors, up to 35 beads total) so that every three consecutive beads have different colors.Medium7CombinatoricsMath+2No attempts yet2s128 MBJudgeable
New Magic SquareFill a 5x5 grid with numbers 1 to 25 so each row strictly increases, respecting up to one prefilled cell per row, and output the lexicographically smallest valid grid or -1.Medium7BacktrackingGreedy+2No attempts yet2s128 MBJudgeable
Finding Domino TilingsCount the ways to tile a fixed 8x7 numeric grid with all 28 distinct dominoes so that each domino's pair matches the covered cell values.Medium7BacktrackingBit manipulation+2No attempts yet2s128 MBJudgeable
GraduationMatch already-taken and newly taken courses to graduation requirements via bipartite matching, minimizing extra courses and finding the lexicographically smallest such set.Medium7GraphGreedy+2No attempts yet2s128 MBJudgeable
ASCII LabyrinthGiven a grid of blank, straight, and corner tiles that can be rotated in place, find the shortest path connecting the top-left to the bottom-right corner and count all valid distinct routes.Medium7BFSBacktracking+2No attempts yet1s128 MBJudgeable
BishopsGiven an N by N board with some cells forbidden, find the maximum number of bishops that can be placed so no two attack each other along diagonals.Medium7GraphDFS+2No attempts yet10s128 MBJudgeable
First Sudoku MistakeGiven 81 sequential Sudoku moves, find the first move after which no digit assignment can complete a valid Sudoku board.Medium7BacktrackingSimulation+1No attempts yet2s128 MBJudgeable
Network MonitoringGiven several graphs, decide for each whether a vertex cover of size at most 10 exists.Medium7GraphBacktracking+1No attempts yet1s128 MBJudgeable
Unit Fraction DecompositionCount ways to write p/q as a sum of at most n unit fractions (order ignored) whose denominators multiply to at most a.Medium7BacktrackingNumber theory+2No attempts yet2s128 MBJudgeable
Restore the SequenceReconstruct a permutation of 1..N that satisfies M range max/min constraints, or report impossibility.Medium7GreedyBacktracking+1No attempts yet1s128 MBJudgeable
Formula SubstitutionGiven two formula strings with variables 0 and 1, find basic-formula substitutions for both variables that make the two formulas syntactically identical, similar to unification.Medium7RecursionString matching+2No attempts yet1s128 MBJudgeable
MutexesGiven up to 5 threads each executing LOCK/UNLOCK instructions on mutexes, determine if a deadlock state is reachable via some interleaving and if so output the lexicographically smallest deadlock state description.Medium7BFSSimulation+2No attempts yet1s128 MBJudgeable
AmbiguousSplit a scrambled, space-free string into a unique sequence of dictionary words matching letter multisets, first and last letters, reporting ambiguity or impossibility.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Villages on a HighwayGiven all pairwise distances between N villages on a line, reconstruct every possible set of consecutive gaps that reproduces exactly that multiset of distances.Medium7BacktrackingCombinatorics+1No attempts yet1s128 MBJudgeable
ZigzagGiven up to 10 points on a small grid, find a polyline of collinear-point segments covering all points with the fewest bends, then minimal total length among such solutions.Medium7CombinatoricsGeometry+2No attempts yet3s128 MBJudgeable
Dice PuzzleGiven partial top and front faces of a 3x3x3 cube of standard dice with fixed chirality and opposite-face contact constraints, enumerate all valid orientations and report every possible sum of the right-side faces.Medium7BacktrackingSimulation+2No attempts yet1s128 MBJudgeable
Magic StarFill the twelve cells of a hexagram with distinct numbers 1 to 12 so each of the six lines sums to 26, choosing the lexicographically smallest completion of a partially given star.Medium7BacktrackingBrute force+2No attempts yet1s256 MBJudgeable
To Score or Not to ScoreGiven the coordinates of two soccer robot teams, decide whether the team in possession can score a goal that survives the removal of any single teammate.Medium7ImplementationBacktracking+2No attempts yet1s128 MBJudgeable
Parencedence!Two players alternately parenthesize one operator of an expression, maximizing and minimizing the value, and two rounds with swapped first movers decide the winner.Medium7Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
The Worm TurnsFind a start cell and first direction that maximize how many food pieces a self-avoiding worm eats, turning only when blocked.Medium7DFSBrute force+2No attempts yet3s128 MBJudgeable
How Big Is It?Given up to 8 circles, arrange them all touching the bottom of a box to minimize the box's total width.Medium7BacktrackingGeometry+1No attempts yet1s128 MBJudgeable
The Thirty-One GameGiven a prefix of draws in the card game Thirty-One with cards 1 to 6, decide who wins from that position under perfect play with the remaining deck.Medium7Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
Prime-Free SequenceFind the lexicographically smallest permutation of n..m where sums of any 2 to d consecutive numbers are all non-prime, or report none.Medium7BacktrackingDFS+2No attempts yet1s128 MBJudgeable
CrabblesGiven a dictionary and hands of at most 10 lettered tiles with values, find the maximum-scoring dictionary word formable from each hand's tiles.Medium7TrieBacktracking+2No attempts yet1s128 MBJudgeable
Rings and RunesValidate the runes for several gates, report the highest-priority error, then decide if the resulting 3-CNF formula is satisfiable.Medium7SimulationImplementation+2No attempts yet1s128 MBJudgeable
Building Zombie FencesOn an n x n grid with n at most 6, find the longest single closed fence loop using lattice-point walls so every numbered plot has exactly that many of its four sides walled.Medium7BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
YO!Count paint-over patterns of a short string whose remaining letters, read left to right, form one or more dictionary words without overlap.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Rank and FileGiven a pawnless chess position and the side to move, decide whether that side's king is safe, in check, or checkmated.Medium7SimulationBrute force+2No attempts yet1s128 MBJudgeable
PegsGiven a 5x5 peg solitaire board with empty, peg, and blocked cells, find the minimum number of pegs reachable by any sequence of horizontal or vertical jumps.Medium7DFSBacktracking+2No attempts yet1s128 MBJudgeable
Shut the BoxGiven N pieces labeled 1 to N and up to T turn values, mark disjoint sets of unmarked pieces summing exactly to each turn value in order, and find the largest total number of pieces markable.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Hex Tile EquationsFind the unique Hamiltonian path through a small hex grid of digit and operator tiles that spells a valid left-to-right equation with both sides equal.Medium7BacktrackingDFS+2No attempts yet1s128 MBJudgeable
The Triangle GameGiven six triangles with numbered edges, rotate and arrange them into a hexagon where touching edges match, maximizing the sum of the six outer edges.Medium7BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Find the Winning MoveGiven a 4x4 tic-tac-toe position with x to move, find the earliest cell in row-major order where x has a forced win, or report none.Medium7Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
Chambers Ceramic ConundrumGiven nine tetromino-like tiles with fixed shapes and a strict placement order, decide whether the forced backtracking rule can cover a 6x6 grid and print the layout.Medium7BacktrackingSimulation+2No attempts yet1s128 MBJudgeable
Team WorkSplit the given pieces into three groups of equal total length, using each piece at most once, and report the largest such length or 0.Medium7BacktrackingBrute force+1No attempts yet5s128 MBJudgeable
Smallest DifferenceSplit the given distinct digits into two non-empty groups, order each into a number with no leading zero, and minimize the absolute difference.Medium7Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Hop — Don't Walk!Sliding-tile puzzle with walk and hop moves where hops flip the passed tile; find the fewest moves (depth under 10) to make all black tiles contiguous.Medium7BFSBacktracking+2No attempts yet1s128 MBJudgeable
Jonny Hates MathSplit a digit string into positive addends of at most 5 digits with no leading zeros that sum to a given total, minimizing the number of plus signs and breaking ties lexicographically.Medium7DFSBacktracking+2No attempts yet5s128 MBJudgeable
Word AdditionCount letter-to-digit assignments that make a cryptarithmetic addition of up to 12 words valid, with no leading zeros and distinct digits per letter.Medium7BacktrackingBrute force+2No attempts yet40s128 MBJudgeable
Gokigen NanameFill an n by n grid with one diagonal per cell so each numbered lattice point has exactly that many diagonal endpoints and no diagonal cycle forms.Medium7BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Buddy, Can You Spare a Tronk?Count and list all multisets of n distinct unit fractions summing to exactly 1, with a repetition limit and forbidden denominators.Medium7BacktrackingNumber theory+2No attempts yet5s128 MBJudgeable
Utopia DividedAssign 2N distinct numbers into N signed x/y pairs so the teleporter visits the given regions in order, choosing the lexicographically smallest guiding.Medium7GreedyBacktracking+2No attempts yet1s128 MBJudgeable
Santa Claus and RudolphCount the closed tours that start and end at the single church, visiting every house once, where each move is a straight horizontal or vertical glide that may not pass over an already visited house.Medium7BacktrackingDFS+2No attempts yet12s128 MBJudgeable
The Longest ChainGiven n strings, each with labeled rings a and b at its ends, find the number of vertices in the longest trail in the resulting multigraph.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Joyful ColoringGiven subsets of size at most 3, decide whether every subset can be made non-monochromatic under a 2-coloring.Medium7BacktrackingGame theory+2No attempts yet3s128 MBJudgeable
Traveling ShoemakerCities each belong to one or two color confederations; moving between cities consumes and produces tickets. Decide if a start city exists to visit every city exactly once.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
HaywireGiven a 3-regular graph on N cows (N at most 12), find the ordering of cows in a row minimizing the sum of pairwise distances between friends.Medium7BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Dreisam EquationsInsert +, -, and * into a number-and-parenthesis equation so it holds under strict left-to-right evaluation, choosing the lexicographically smallest valid string.Medium7BacktrackingImplementation+2No attempts yet1s128 MBJudgeable
PuzzleGiven up to 36 fixed-orientation pieces, each with flat, jut, or cavity edges, decide whether they can tile an n by m rectangle with matching jut-cavity adjacencies.Medium7BacktrackingImplementation+2No attempts yet1s128 MBJudgeable
Picture PuzzleCount the number of ways to place and rotate nine square pieces into a 3x3 grid so every touching edge pair matches (same letter, one L half and one R half).Medium7BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Number GameGiven the available numbers from 2 to 20 in a Number Game position, list every move that leaves the opponent in a losing position.Medium7Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
Roman NumeralsEach line gives a Roman sum A+B=C. Decide whether it holds as a Roman numeral equation, then classify its cryptarithm as impossible, ambiguous, or valid.Medium7Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Graph ColoringFor each graph, find a maximum independent set and output one optimal coloring whose sorted black node list is lexicographically smallest.Medium7GraphBacktracking+2No attempts yet1s128 MBJudgeable
Channel AllocationGiven a planar graph of up to 26 repeaters, find the chromatic number, the fewest colors needed so adjacent repeaters differ.Medium7GraphBacktracking+2No attempts yet1s128 MBJudgeable
Balanced FoodGiven a pizza of n slices and a sector-shaped table, find the lexicographically smallest order of eating slices so the remaining slices' center of gravity always stays over the table.Medium7Brute forceGeometry+2No attempts yet1s128 MBJudgeable
The Settlers of CatanGiven an undirected graph where nodes have degree at most three, find the longest path that uses no edge more than once.Medium7GraphDFS+1No attempts yet1s128 MBJudgeable
Mhocskian LanguagesGiven a context-free grammar in Chomsky normal form and a list of words, decide for each word whether the start variable can derive it.Medium7Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Paint by NumbersGiven the run lengths of stars in every row and column of an n x m grid, reconstruct the lexicographically smallest grid of dots and stars.Medium7BacktrackingImplementation+2No attempts yet1s128 MBJudgeable