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 results514 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
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
Flip It!Simulate a sequence of row and column flips that collapse a grid of cards into one pile, then list the face-up cards from the bottom.Medium6SimulationImplementation+2No attempts yet1s128 MBJudgeable
Challenge 24From four distinct positive integers, enumerate every value reachable using each number once with +, -, *, and even-only division, then report the longest run of consecutive integers, choosing the largest start on ties.Medium6Brute forceRecursion+2No attempts yet1s128 MBJudgeable
Based Integer ConstantsFor each string, decide whether it is a valid Ada integer constant, which may nest a based integer as the base of another based integer.Medium6StringRecursion+1No attempts yet1s128 MBJudgeable
Euclid's GameGiven two starting numbers, decide who wins the subtraction game Euclid's Game under optimal play, for each pair until the terminating 0 0 line.Medium6Game theoryMath+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
Sang-geun's LockCount the number of height-balanced binary trees with N nodes, print the last 9 digits padded to width 9.Medium6Dynamic programmingRecursion+1No attempts yet1s128 MBJudgeable
George Lucas and 1138Given a digit string, use all its digits with +, -, *, / and parentheses, and report the smallest positive integer that no expression can produce.Medium6Divide and conquerBrute force+2No attempts yet1s128 MBJudgeable
Falling LeavesGiven the leaf-removal stages of a binary search tree, reconstruct the unique tree and print its preorder traversal.Medium6TreeRecursion+2No attempts yet1s128 MBJudgeable
ChemistryParse a chemical formula with nested parentheses and multipliers, then output each element's total atom count in lexicographic order.Medium6StackString+2No attempts yet1s128 MBJudgeable
Removing ParenthesesGiven an expression of single-letter variables with addition and multiplication, remove every pair of parentheses that can go without changing the value, and print the result.Medium6StackString+2No attempts yet1s128 MBJudgeable
ResistorsParse a nested expression of series and parallel resistor connections and output the exact resistance as a reduced fraction.Medium6StringStack+2No attempts yet1s128 MBJudgeable
Last DigitsFor each test case, print the last n digits (with leading zeros) of the power tower of height i with base b.Medium6Number theoryMath+2No attempts yet2s128 MBJudgeable
Newton's AppleParse two binary trees from post-order tokens with nil markers, then decide whether one can be turned into the other by swapping left and right children at any nodes.Medium6TreeRecursion+2No attempts yet1s128 MBJudgeable
Off BalanceGiven a 2D grid of digit-labeled blocks, group 4-block pieces, build the support tree, and check each piece's accumulated center of mass against its bottom-column span.Medium6DFSTree+2No attempts yet1s128 MBJudgeable
The Genome Database of All Space LifeDecode a run-length compressed genome string with nested parentheses and print the character at index i, or 0 if the index is out of range.Medium6StringRecursion+2No attempts yet1s128 MBJudgeable
The Counting ProblemFor each pair (a, b), count how many times each digit 0 through 9 appears when writing every integer between them, inclusive.Medium6MathImplementation+2No attempts yet1s128 MBJudgeable
A Foldy but a GoodyGiven a string of U and L folds, find the coordinates of the m-th point (end or right angle) on the unfolded strip.Medium6RecursionDivide and conquer+2No attempts yet1s128 MBJudgeable
Fractal DistanceGiven the order of two houses along an n-th Hilbert curve, compute the straight-line distance between their grid positions.Medium6Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
PalindromeGiven a string, find the minimum number of characters to insert anywhere so the string becomes a palindrome.Medium6Dynamic programmingString+2No attempts yet1s256 MBJudgeable
Binary Search TreeGiven the preorder traversal of a binary search tree, print its postorder traversal.Medium6TreeDivide and conquer+2No attempts yet1s256 MBJudgeable
Justice LeagueDecide whether the graph of heroes can be split into a clique and an independent set.Medium6GraphDivide and conquer+2No attempts yet1s128 MBJudgeable
Moo GameGiven N up to 1e9, report whether the N-th character of the recursively defined Moo sequence is 'm' or 'o'.Medium6RecursionDivide and conquer+2No attempts yet1s128 MBJudgeable
Instant ComplexityParse a small nested-loop program, compute its running time as a polynomial in n, and print the collected polynomial from highest degree down.Medium6ImplementationStack+2No attempts yet1s128 MBJudgeable
StrategyParse a small strategy language, then simulate every pair of up to 10 programs for 10 rounds and print each program's total score.Medium6ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Paper FoldingDraw the dragon curve made by folding a strip of paper N times and opening each crease to 90 degrees, using underscores and bars.Medium6ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Car TriallingParse each line against a small case-sensitive grammar and decide whether it is a valid car-trialling instruction, echoing it with spaced collapsed or printing Trap!.Medium6StringImplementation+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
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
Boolean LogicParse a fully parenthesized proposition formula, then print a truth table with each subformula's value placed at its symbol or operator column.Medium6ImplementationRecursion+2No attempts yet1s128 MBJudgeable
Tree PruningGiven a rooted binary tree with colored nodes, prune subtrees to make the whites minus blacks equal exactly D, minimizing the number of prunes.Medium6TreeDynamic programming+2No attempts yet2s512 MBJudgeable
FractalsDraw a level-`level` block fractal of given width from (0,1) to (width,1) and list, in order, every integer y where the vertical line x meets a segment.Medium6RecursionImplementation+2No attempts yet1s128 MBJudgeable
Sum of ProductsExpand a polynomial-like expression of variables into a sum of products, then sort each term's letters and sort the terms lexicographically.Medium6StringRecursion+2No attempts yet1s128 MBJudgeable
QuadtreesGiven two quadtree preorder strings for 32x32 black-and-white images, count the black pixels in their union by recursively merging overlapping quadrants.Medium6RecursionTree+2No attempts yet1s128 MBJudgeable
Tree IsomorphismGiven two rooted trees in pre-order with '#' closing each node's child list, decide whether the trees are isomorphic ignoring node labels.Medium6TreeDFS+2No attempts yet1s128 MBJudgeable
Turning a TreeReroot a given ordered tree at a specified leaf so the counter-clockwise order of neighbors at each node stays the same, then print the new tree.Medium6TreeDFS+2No attempts yet1s1024 MBJudgeable
Code FormattingParse a TRIVIAL program given by a grammar and print it back with strict indentation and whitespace rules.Medium6ImplementationRecursion+2No attempts yet2s128 MBJudgeable
Beth TableauxParse a propositional formula and either report it valid or print the lexicographically smallest falsifying assignment.Medium6BacktrackingImplementation+2No attempts yet2s64 MBJudgeable
Fractal CakePrint the chocolate pattern of a rectangular window in a 2^(N+1) square grid built by recursively darkening the middle 2x2 of every 4x4 block N times.Medium6Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
Another Rock-Paper-Scissors ProblemGiven a game number N up to 10^12, determine the move that beats Sonny's move in his self-similar rock-paper-scissors sequence.Medium6RecursionDivide and conquer+1No attempts yet2s512 MBJudgeable
SpreadsheetEvaluate a small 9x26 spreadsheet where each cell holds an integer expression with +, -, *, / and cell references, reporting 1000000 if cell A1 is part of a circular reference.Medium6ImplementationDFS+2No attempts yet1s128 MBJudgeable
Paper FoldingRepeatedly fold the left part of a binary strip over the right where symbols match and find the shortest reachable length.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Binary Search TreeCount the insertion orders that build the same binary search tree as the given permutation.Medium6CombinatoricsTree+1No attempts yet2s256 MBJudgeable
Binary Search Tree 2Count the permutations of 1 to N that build the same binary search tree as the given permutation.Medium6CombinatoricsTree+1No attempts yet1s128 MBJudgeable
SignalsCompare the signal sets generated by two series-parallel circuit expressions and print whether they are equal, nested, disjoint or overlapping.Medium6String matchingRecursion+1No attempts yet1s128 MBJudgeable
CubeCut a W by L by H integer block into integer-sided cubes with the fewest cuts and output the number of cubes.Medium6Dynamic programmingRecursionNo attempts yet10s128 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
Unscrambling ImagesThe solver recovers the hidden child order at each quadtree node from the test encoding and restores the secret image.Medium6TreeRecursion+1No attempts yet1s128 MBJudgeable
Secret CodeCount the sequences of operations that build the given string from a source of length at least 2 by gluing each string to a copy missing one end character.Medium6Dynamic programmingString matching+1No attempts yet1s128 MBJudgeable
CarpetsDecide whether the given carpets, each usable rotated, cover a W by H room exactly with no overlap.Medium6BacktrackingRecursionNo attempts yet1s256 MBJudgeable
Above or Below the Koch CurveGiven a level L Koch curve from (0,0) to (1,0), decide whether each query point lies above or below the curve.Medium6RecursionGeometry+1No attempts yet1s256 MBJudgeable
DepactingDecode a nested Pact structure with run-length repeats and omitted record fields, then answer value queries on it.Medium6RecursionString+1No attempts yet1s256 MBJudgeable
ImplicationGiven formulas assumed true, decide for each query formula whether it holds under every assignment that satisfies all assumptions.Medium6Brute forceBit manipulation+1No attempts yet2s256 MBJudgeable
Hilbert SortSort up to 200,000 labeled grid points by the order in which the Hilbert curve visits them.Medium6RecursionSorting+1No attempts yet5s256 MBJudgeable
Infinite Garden (Large)Compute the shortest axis-aligned route between two even-coordinate points in the maze drawn by the tape-driven robot without crossing its walls.Medium6BFSSimulation+1No attempts yet5s512 MBJudgeable
Equivalent StringsDecide whether two equal-length strings are equivalent under recursive splitting and optional swap of halves.Medium6Divide and conquerString+2No attempts yet2s512 MBJudgeable
The Halting ProblemGiven a small register program that may call itself recursively, decide whether it halts on the input and output the returned value, or print * if it runs forever.Medium6SimulationRecursion+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
Hamiltonian HypercubeGiven two binary strings in Gray Code order, count how many code words lie strictly between them on the n-bit Gray Code path.Medium6Bit manipulationRecursion+1No attempts yet2s512 MBJudgeable
Cactus ConstructionGiven a cactus as edge-disjoint paths, simulate the fixed recursive procedure that emits join, recolor, and connect operations assembling it with four colors.Medium6GraphDFS+2No attempts yet2s512 MBJudgeable
Small Ping Pong TournamentGiven the total points each of 2^N players scored, decide whether Dudu (first score) can be the champion.Medium6Brute forceRecursion+2No attempts yet2s512 MBJudgeable
Attendance RecordRearrange the letters of a record over A, B, C so the result is valid (B needs one rest day, C needs two) and lexicographically smallest.Medium6GreedyBrute force+2No attempts yet2s512 MBJudgeable
Rather Perplexing Showdown (Small)Find the alphabetically smallest left-to-right lineup of R rocks, P papers, and S scissors so that a single-elimination bracket never pairs identical moves.Medium6Divide and conquerRecursion+2No attempts yet5s512 MBJudgeable
Fractiles (Small)Choose at most S tile positions to inspect so that, for any original K-tile sequence, you can decide whether some gold tile exists.Medium6RecursionMath+1No attempts yet5s512 MBJudgeable
Secret Cow CodeAn infinite code string grows by doubling: each step appends the current string rotated right by one. Find the N-th character.Medium6RecursionDivide and conquer+1No attempts yet2s512 MBJudgeable
Tiling the Shower Floor (Large)Fill a 2^K by 2^K grid with L shaped trominoes leaving one drain cell empty, using the specified recursive placement and numbering scheme.Medium6Divide and conquerRecursion+2No attempts yet1s512 MBJudgeable
Flow Graph ComplexityParse a comma-separated flow-graph string of S, B(...), L(...) nodes, count forward and backward edges and nodes, and print |EF| + W*|EB| - |V| + 2 or -1 if malformed.Medium6StringImplementation+2No attempts yet1s512 MBJudgeable
Philosopher's WalkGiven the step index m along a Hilbert curve of side n = 2^k, find the cell coordinates (x, y) of that step.Medium6Divide and conquerRecursion+2No attempts yet0.5s512 MBJudgeable
Decisions, DecisionsGiven the truth table of an n-variable boolean function, count the vertices in its unique minimal binary decision diagram.Medium6Dynamic programmingDivide and conquer+2No attempts yet2s512 MBJudgeable
Tournament ChartParse a knockout bracket given as a string and decide whether the reported win counts for all players can be consistent with some assignment of match winners.Medium6TreeDFS+2No 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
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
Dragon CurveGenerate the segments of N dragon curves on a 101 by 101 grid, mark the grid points they pass through, and count unit squares whose four corners are all marked.Medium6ImplementationRecursion+2No attempts yet1s512 MBJudgeable
You on That DayGiven measured environmental factors and one-operation definitions, compute each factor's partial derivative of HAPPY and print it as a reduced fraction.Medium6Dynamic programmingDFS+2No attempts yet1s512 MBJudgeable
Eli's Curious ExperimentCount the maximal independent sets of a path on N vertices that have size at least two, for many N up to 76, labeled by test case number.Medium6Dynamic programmingCombinatorics+1No attempts yet3s512 MBJudgeable
The Total is RightDecide whether a target N can be formed exactly from up to six given integers using +, -, times, and exact division with positive intermediates.Medium6Brute forceRecursion+2No attempts yet2s512 MBJudgeable
Drawn and QuarteredA fixed permutation is applied to a string K times; find where each index goes and output the rearranged string.Medium6MathBit manipulation+1No attempts yet2s512 MBJudgeable
Curse of the MeetingCount the ways N people around a round table can pair up and shake hands simultaneously without any arms crossing, modulo 987654321.Medium6Dynamic programmingCombinatorics+2No attempts yet1s256 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
Binary Ternary Search Play 1For every index in a sorted array of size N, compare the number of probes binary search and ternary search need to reach it, and count how often binary wins, ties, and loses.Medium6Divide and conquerBinary search+2No attempts yet1s256 MBJudgeable
Nested Set ModelRoot an undirected tree at S, traverse children in ascending order, and label each node with nested left/right interval numbers.Medium6DFSTree+2No attempts yet1s1024 MBJudgeable
The Tower of PisaGiven n disks stacked on the first of three rods, where the second rod lets you move a group of top disks together, find the minimum moves to shift all disks to the third rod.Medium6Dynamic programmingRecursion+1No attempts yet2s512 MBJudgeable
Modified HanoiSimulate a modified Tower of Hanoi with a no-repeat-move rule and a fixed move priority order, counting moves until all disks gather on one pole.Medium7SimulationRecursion+2No attempts yet2s128 MBJudgeable
Last Josephus SurvivorGiven N people in a circle and a step size K up to 90, find the last person remaining after repeatedly removing every K-th person, with N up to 10^15.Medium7MathRecursion+1No attempts yet2s128 MBJudgeable
WarGiven a forest of vassal relations and per-country conquest costs, find the minimum days needed to conquer or force surrender of at least M countries using tree knapsack DP.Medium7Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
Special NodesIn a rooted tree where child weights exceed parent weights, mark vertices special or ordinary to minimize the total of each ordinary vertex's weight minus its nearest special ancestor's weight.Medium7Dynamic programmingTree+2No attempts yet2s128 MBJudgeable
RPGGiven quests that require either a strength or intelligence threshold and grant points to freely raise those stats, find the maximum number of quests completable.Medium7Dynamic programmingSorting+2No attempts yet2s128 MBJudgeable
Binary Search TreeGiven the insertion order of 0..N-1 values, compute the sum of node heights in the resulting binary search tree efficiently for N up to 250000.Medium7TreeDivide and conquer+2No attempts yet2s256 MBJudgeable
Youngsik FunctionCount integers in [A, B] up to 1e9 whose repeated adjacent-digit-difference reduction (the Youngsik function) eventually collapses to the single digit 7.Medium7Dynamic programmingRecursion+2No attempts yet2s128 MBJudgeable
O Yeongsik's TreasureGiven a reachable target Tower of Hanoi arrangement, find the shortest move sequence from the initial all-on-A state and print the disk positions after exactly M moves.Medium7RecursionDivide and conquer+2No attempts yet1s128 MBJudgeable
Binary Tree DrawingGiven a binary tree reconstructed from preorder and inorder traversals, compute the minimum area of a grid drawing where each right child extends the row and each down child extends the column.Medium7Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
Compare Tree Traversal PathsGiven two 0/1 Euler-tour strings from DFS traversals of a tree rooted at the same vertex, decide whether both could come from the same underlying tree.Medium7TreeString+1No attempts yet2s128 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
Mobile Binary NumberGiven a nested-bar mobile whose bars may each be flipped independently, find the K-th lexicographically smallest distinct binary string obtainable across all flip combinations.Medium7Dynamic programmingRecursion+2No attempts yet1s128 MBJudgeable
Clearing the BeadsFind the minimum number of beads to insert between colored beads so every bead can eventually be cleared by removing runs of length at least K.Medium7Dynamic programmingStack+1No attempts yet1s128 MBJudgeable
Strange PainterReconstruct a picture painted by a recursive quadrant-coloring process closest (in Hamming distance) to a given N x N binary target, then output that minimal difference and the picture.Medium7Divide and conquerDynamic programming+1No attempts yet1s128 MBJudgeable
Sierpinski TriangleGiven a Sierpinski-triangle sub-triangle's name string, output the names of all triangles it leans against based on the fractal's midpoint-subdivision structure.Medium7StringRecursion+2No 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
Non-boring SequencesDetermine whether every contiguous subarray of a sequence has at least one element unique within that subarray, using an efficient divide and conquer approach.Medium7Divide and conquerArray+1No attempts yet5s128 MBJudgeable
Character EquationGiven a recursive definition of a huge string T through variable concatenation equations, determine whether a pattern P is a subsequence of T without expanding T explicitly.Medium7Dynamic programmingString+2No attempts yet1s256 MBJudgeable