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
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| K-th Parenthesis StringFind the K-th valid balanced parenthesis string of length N in lexicographic order, or -1 if fewer than K+1 exist. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 0.25s | 512 MB | Judgeable |
| 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. | Medium7 | SortingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Know your AliensGiven a human/alien label for each even number 2 to 2N, build the lowest-degree monic or anti-monic integer polynomial whose sign at 2i matches the label. | Medium7 | MathDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Insertion OrderFind a permutation of 1 to n whose insertion order into an unbalanced BST yields a tree of height exactly k, or report impossible. | Medium7 | TreeGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ShuffleApply a recursive shuffle to a deck of 2^n cards t times and print the final card order. | Medium7 | Divide and conquerBit manipulation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Shortest Accepted WordParse a regular expression over a, b, c and $ into a tree, then compute the shortest lexicographically smallest string each node accepts. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Binary and Ternary Search Game 3For each query N, compute the maximum number of array elements compared in binary search and in ternary search over all positions in a sorted array of size N. | Medium7 | Binary searchDivide and conquer+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Dividing the KingdomGiven n distinct integer-half points in the plane, output at most n-1 axis-parallel lines at integer coordinates so that no two points share a region. | Medium7 | Divide and conquerGeometry+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Make a NumberStarting from 1, find the minimum number of +1, -1, and power operations needed to reach a target N up to 10^18. | Hard8 | Number theoryMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Two-Bill PurchaseGiven a target amount D and two bill denominations P and Q, find the minimum total payment at least D achievable using nonnegative counts of each bill. | Hard8 | Number theoryMath+2 | No attempts yet | 0.5s | 128 MB | Judgeable |
| FractionsGiven a fraction a/b and a bound c, find fractions a1/b1 <= a/b <= a2/b2 with denominators at most c that minimize a2/b2 - a1/b1. | Hard8 | Number theoryMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Minimum Resistor NetworkFind the minimum number of 1-ohm or 2-ohm resistors combined via series and parallel connections to achieve an exact resistance a/b, capped at 16 or else -1. | Hard8 | MathRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Monkey TowerCompute the minimum number of moves to solve a 4-peg Tower of Hanoi with up to one million disks, using the Frame-Stewart recurrence modulo 9901. | Hard8 | Dynamic programmingMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Complete Binary TreeGiven two same-height complete binary trees whose leaves carry a permutation of labels, find the largest label subset whose pairwise leaf distances match in both trees. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Marble SlabsFind the minimum wasted area when guillotine-cutting a rectangular slab into a set of allowed non-rotatable rectangle sizes. | Hard8 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Palindrome EncodingGiven a binary string, repeatedly delete the second half of any even-length palindromic substring and find the minimum length achievable. | Hard8 | Dynamic programmingString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Banknotes for a New GameChoose K denominations starting at 1 won where each next one is 2, 3, 4, or 5 times the previous, to minimize the number of banknotes summing to N won. | Hard8 | Dynamic programmingMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Broadcast NetworkPick which edges of a rooted tree to install so that total user fees minus installation cost stays non-negative while maximizing the number of served users, solved with tree knapsack DP. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 2s | 128 MB | Judgeable |
| PrevtreeGiven the display code sequence (leaf-counts of root and left-children) of a strict binary tree, reconstruct the tree and output the lexicographically previous valid display code with the same leaf count, or 0 if none exists. | Hard8 | TreeRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tower of HanoiGiven Tower of Hanoi disks split validly across three rods, find the target rod and minimum moves (mod 1,000,000) to gather all disks on one rod. | Hard8 | GreedyMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Here-ThereGiven a Sierpinski-carpet-like fractal board built by recursively removing center squares, compute the shortest grid path length between two given cells avoiding removed regions. | Hard8 | BFSRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Number of Expression ValuesCount the distinct values an unspaced digit/operator string can yield when each subexpression is parsed as prefix, infix, or postfix. | Hard8 | Dynamic programmingString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Cutting the Stone SlabCount the number of ways to repeatedly cut an N x N stone slab with alternating horizontal/vertical straight cuts so every final piece has no impurity and exactly one crystal. | Hard8 | Dynamic programmingRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Last Non-Zero Factorial Digit 2Compute the last nonzero digit of N! for an N with up to 100 digits, requiring a modular recursive formula rather than direct computation. | Hard8 | MathNumber theory+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Antarctic ScientistsCompute the exact character count needed to render an ASCII family tree with fixed box drawing and branching link rules given a forest with up to two children per node. | Hard8 | TreeRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Repetition-Free FormulaParse a Boolean formula that may repeat variables, determine if the underlying function is read-once, and if so print its canonical repetition-free formula. | Hard8 | RecursionString+2 | No attempts yet | 2s | 64 MB | Judgeable |
| Billing TablesGiven an ordered old billing table with range-based prefix rules, build the minimal prefix-only dictionary table (no prefix a prefix of another) that reproduces exactly the same plan decisions for all 11-digit numbers. | Hard8 | TrieGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hardwood CuttingGiven a labeled grid board, compute the maximum number of pieces separable by straight guillotine-style cuts starting from exposed edges, accounting for pieces that interlock and cannot be separated. | Hard8 | SimulationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Telephone NetworkRoute m disjoint input-output requests through a recursive Clos-like network of binary switches, choosing at each layer the lexicographically smallest routing bit string. | Hard8 | GraphGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Term GeneratorParse a formula, convert it to a normal form by expanding nested sums and products according to given rewriting rules, then implement a cyclic generator that outputs requested numbers of terms, some possibly skipped without printing, based on huge signed counters. | Hard8 | String matchingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Proof GeneratorConvert a logical formula to a canonical disjunctive normal form using given rewrite rules, then cyclically output the k-th next satisfying terms under given axioms for a sequence of queries. | Hard8 | String matchingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Matrix CalculatorParse and evaluate a matrix expression language with block matrices, transpose, indexing, and modular arithmetic, printing each assignment's resulting matrix. | Hard8 | RecursionMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Mobile ComputingBuild every possible binary mobile from given stone weights and pick the widest one whose width is strictly less than a given room width, output as reduced fraction. | Hard8 | RecursionBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rotate to RootGiven a binary tree, compute the height of the tree after each node is rotated to the root one at a time. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GangsRank all lattice paths of E and S steps from (1,1) to the diagonal at (N,N) by a recursive 'OG' order, and output the run at rank M or ERROR. | Hard8 | CombinatoricsDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TreequivalenceGiven two textual tree notations, decide whether they describe the same unrooted planar drawing, allowing any root and cyclic order around each vertex. | Hard8 | TreeHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hilbert CurveCount how many points the n-th Hilbert curve shares with a given horizontal segment whose endpoints are grid multiples of 1/2^n. | Hard8 | RecursionDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Split WindowsGiven a preorder traversal of a split tree, draw the minimum-sized grid whose boundaries match the layout, applying proportional rounding at each split. | Hard8 | TreeRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Function OverloadingParse nested overloaded function calls; for each, determine whether resolution is unique, impossible, or ambiguous, counting ambiguity cases up to 1000. | Hard8 | Dynamic programmingImplementation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| ASCII ExpressionParse a multi-line monospace arithmetic expression into its syntax tree, then evaluate it modulo the prime 2011 with modular inverses for fractions. | Hard8 | ImplementationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dr. Podboq, or: How We Became AsymmetricRead a binary tree of cells, define each cell's left-right similarity by shared subtree shapes up to child swaps, then reorder children by asymmetry and print the normalized tree. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| VectorsParse and evaluate a small language over scalars and 3D vectors, including mixed operators and bracket styles that can close several open groups at once. | Hard8 | ImplementationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FoldGiven the sequence of A/V fold directions along an unfolded paper strip, find the minimum number of all-layer folding steps that produce it. | Hard8 | Dynamic programmingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree InsertionsCount how many permutations of a given sequence build the same binary search tree; values may repeat and answers need big integers. | Hard8 | TreeCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Manelzuma's RevengeGiven a recursive square-substitution rule, answer queries that print a rectangular window of one generated fractal iteration. | Hard8 | RecursionDivide and conquer | No attempts yet | 1s | 128 MB | Judgeable |
| Conditional StatementsParse a small nested if language, then for each checkpoint decide which variable assignments can reach it and print the forced true/false variables or unreachable. | Hard8 | SimulationImplementation+2 | No attempts yet | 10s | 128 MB | Judgeable |
| Order of TreesGiven n, print the n-th binary tree under a canonical ordering by node count and by (left subtree number, right subtree number) recursively. | Hard8 | CombinatoricsDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ExpressionsFor each range of digits and target, print every fully bracketed expression over the digits in order that evaluates to the target. (Note: summary must be one sentence, at most 160 chars.) | Hard8 | BacktrackingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree SimilarityGiven two ordered rooted trees, find the minimum number of node relabel, delete, and insert operations to turn the first tree into the second. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 3s | 128 MB | Judgeable |
| WalawehEach Walaweh list W_L is built from W_{L-1} by a fixed 8-step cycle of append/prepend and optional reversal operations; convert between (length, index) and the binary string. The recursion only needs O(log N) work per level, but the reversal and leading-zero handling make the index bit-mapping non-obvious. | Hard8 | RecursionBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ternary TreesLabel the leaves of a complete ternary tree so that, given a fixed query order, the leaf values stay hidden until every leaf is asked. | Hard8 | TreeRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| C-algaeDecide whether each given undirected graph can be built from single vertices by disjoint union and complete join. | Hard8 | GraphDivide and conquer+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Painter's StudioCount the number of positions where a hole in one self-similar fractal matrix coincides with a hole in the same matrix shifted by (x, y). | Hard8 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Words 2Given exponents k1..kn, find the smallest m such that the concatenation of h_k(0) is a substring of h_m(0), or report NIE. | Hard8 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| WordsGiven indices k_i, decide whether the concatenation of the words h^{k_i}(0) appears as a substring of some h^m(0). | Hard8 | StringDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree Rotations 2Given a binary tree with distinct leaf labels, rotations swap children at any node; find the minimum possible inversion count of the leaf sequence. | Hard8 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fibonacci RepresentationFor each query k, find the fewest Fibonacci numbers whose signed sum (plus or minus, repeats allowed) equals k. | Hard8 | Dynamic programmingMath+2 | No attempts yet | 3s | 128 MB | Judgeable |
| PlotterGiven the recursively defined order-n bytecurve and m integer points, report how many times and at which seconds the pen visits each point. | Hard8 | RecursionDivide and conquer+2 | No attempts yet | 5s | 128 MB | Judgeable |
| TrailsFor each axis-aligned unit-height tape, count the connected pieces of the bytecurve of order n that lie inside the rectangle. | Hard8 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DivisorsGiven n and an expression built from divisors of n with gcd and lcm, decide whether the expression's value is the same for every assignment of variables. | Hard8 | Number theoryTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hossa (Bull Market)Given a hossa permutation, output the next hossa in the defined recursive order. | Hard8 | CombinatoricsRecursion | No attempts yet | 1s | 128 MB | Judgeable |
| HarvardAssign each variable of a program with nested repeats to a memory bank within capacity to minimize access and select costs. | Hard8 | BacktrackingDynamic programming+1 | No attempts yet | 10s | 128 MB | Judgeable |
| Digital OnionGiven a balanced parentheses string, output the string that comes next in the defined price order. | Hard8 | CombinatoricsRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Exponential TowersGiven a power tower a^(b^c), count the towers of height at least 3 with bases above 1 that evaluate to the same value. | Hard8 | Number theoryCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Euler's ProblemGiven n, list every x with Euler phi(x) equal to n in increasing order, or report none. | Hard8 | Number theoryBacktracking+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cactus GeneratorParse the SCGL definition, build the cactus it describes with merged vertices renumbered, and print the counts, path cover number, and sorted edges. | Hard8 | GraphUnion-find+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Make a superpalindromeGiven a lowercase string, find the smallest superpalindrome of the same length that comes after it in lexicographic order. | Hard8 | StringRecursion+1 | No attempts yet | 1s | 16 MB | Judgeable |
| Last eight digits of a power towerGiven a and b, print the last eight digits of the b-level power tower of a, keeping leading zeros for large values. | Hard8 | Number theoryMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Birthday Numbers IIAdd up the products of every neighboring pair among the integers between x and y that use only the digits 3, 5 and 8, and report the total modulo 19980305. | Hard8 | MathRecursion+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Googlander (Large)Count the distinct self-avoiding walks on an R by C grid that start at the bottom left facing up and at each step go straight or turn right. | Hard8 | Dynamic programmingRecursion+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Power SwapperCount the ordered sequences of aligned block swaps, using each size at most once, that sort the given permutation. | Hard8 | Divide and conquerRecursion+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Alternative Bracket NotationConvert a balanced bracket string into the shortest alternative notation, where each pair's header gives absolute start and end indices of its contents. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 10s | 512 MB | Judgeable |
| XOR SequenceChoose B in [0, N-1] to XOR every element of A, then find the maximum possible count of index pairs i < j with C_i < C_j. | Hard8 | Divide and conquerBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ExponialCompute n^(n-1)^(...^1) modulo m for n and m up to 1e9, a tower too tall to build. | Hard8 | Number theoryRecursion+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Memory CellBuild the expression tree, find the largest pair of disjoint identical subtrees, and print the loser's postfix in lexicographic order. | Hard8 | StackTree+2 | No attempts yet | 1s | 512 MB | Judgeable |
| OminoboxFor every fixed N-omino placement in a small grid, the drop score is H minus the maximum stack height covered; sum the best placement score over all N-ominoes. | Hard8 | Brute forceImplementation+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Power towersGiven lists of positive integers, compute each power tower modulo M, where the tower can be astronomically large. | Hard8 | Number theoryRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WalkA fractal tiling is built by repeated splits; given a start cell and a walk, report for each move whether he crossed between tiles. | Hard8 | Divide and conquerRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ExpressionParse a two-dimensional rendering of nested fractions, additions, multiplications, and divisions, then print the reduced value as a fraction. | Hard8 | ImplementationRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |
| String TableBuild a table whose cells are huge concatenated strings defined by comparing neighbors, then print 50 characters from a given position of the final cell. | Hard8 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ProtocolStarting from one wire of capacity N, each year every wire splits into two wires transformed by two quadratic polynomials, and after M years we need the sum of 112345 raised to each wire's capacity, mod 1e9+9. | Hard8 | MathDivide and conquer+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Alien microbesCount the breeding patterns over H days starting from one microbe, where each day the microbes alive produce children with a total of at most W. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Booming BusinessCount ordered rooted trees with exactly w nodes and height exactly h, modulo 1e9+7, where children of each node are an ordered sequence. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Balloon WarehouseSimulate repeated insertions into an infinite balloon line, then report the colors at positions l to r-1 after all instructions. | Hard8 | TreeDFS+2 | No attempts yet | 7s | 512 MB | Judgeable |
| Boom!Count the ways to fold a strip of N segments so that no two chemically coated faces touch. | Hard8 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| POPABuild a binary tree on indices with inorder order 0..N-1 and parent weights dividing child weights, using at most Q gcd-equality queries on hidden subarrays. | Hard8 | Divide and conquerTree+2 | No attempts yet | 1s | 512 MB | Judgeable |
| ParenthesesClassify a C arithmetic expression as error, proper, or improper depending on validity and the minimality of its parentheses. | Hard8 | StackRecursion+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Adding ParenthesesParenthesize a single-digit expression with non-nested single-operator parentheses to maximize its left-to-right value. | Hard8 | Dynamic programmingRecursion+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Add Parentheses 3Parenthesize an alternating digit and +,-,* expression of length up to 19 to maximize its value, respecting left-to-right and multiplication-first rules. | Hard8 | Divide and conquerDynamic programming+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Identity FunctionGiven N, find the smallest positive k with every iterate F_k(a)=a for 1<=a<N under f(a)=a^N mod N, or output -1. | Hard8 | MathNumber theory+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Pear-wise VotingGiven ranked ballots and a selectable candidate order, decide for each candidate whether some agenda makes that candidate win sequential pairwise contests. | Hard8 | Bit manipulationDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| JOI FlagFill and fix a 2^K by 2^K grid so it follows the recursive quadrant rule for JOI flags, minimizing the number of already-written cells whose character must change. | Hard8 | Divide and conquerDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| String ProcessingDecide whether a recursive split-and-swap program can turn string S into T, and if so output the 2^k - 1 bit program. | Hard8 | Divide and conquerString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| QuadtreeGiven a 2^n by 2^n binary matrix and a budget k, flip at most k entries so the resulting matrix has a quadtree with the fewest possible cells. | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree RotationCompute the minimum number of restricted tree rotations (at the root or root's right child) to transform one 0-2 binary tree's shape into another and output a valid rotation sequence. | Hard9 | TreeGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ground WorksSimulate water filling inside the region enclosed by a rotated Hilbert curve fractal against a tilted ground line, accounting for trapped air pockets, and output the flooded area to four decimals. | Hard9 | GeometrySimulation+2 | No attempts yet | 3s | 256 MB | Judgeable |
| K’ak’-u-pakal and the Maya ScriptParse a recursive grammar for Maya glyph compositions and render a minimal-size ASCII-art box layout respecting horizontal/vertical grouping and bracket-doubling size rules. | Hard9 | RecursionString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Beneš Network RoutingGiven a required permutation between top and bottom computers of a recursively defined Beneš network, determine the lexicographically smallest sequence of switch settings that realizes it. | Hard9 | Divide and conquerGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Very Boring HomeworkInsert N keys into a BST, lay out its ASCII drawing, and report up to 5 small rectangular fragments of the picture. | Hard9 | TreeImplementation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Structural IsomersCount the number of distinct alkane carbon skeletons (free trees in which every node has degree at most 4) with n carbon atoms. | Hard9 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |