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 |
|---|---|---|---|---|---|---|
| Aku NegarakuFor each N and M, simulate Josephus elimination around a circle and report the last remaining trainee's number. | Medium4 | SimulationArray+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Counting Langford SequencesCount Langford sequences of length 2n where the numbers at positions x and y are equal, for n up to 12. | Medium4 | BacktrackingRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Collecting EnergyGiven a row of N weighted beads (N up to 10), remove interior beads one at a time, scoring the product of the neighbors left and right, and maximize the total score. | Medium4 | Dynamic programmingRecursion+1 | No attempts yet | 1s | 512 MB | Judgeable |
| I'm Sick of Fibonacci~Given n, count the total number of calls made by the naive recursive Fibonacci function, modulo 1,000,000,007. | Medium4 | Dynamic programmingRecursion+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Road ConstructionGiven a tree with n countries and weighted edges, sum over all edges of weight times the absolute difference in size of the two components the edge splits the tree into. | Medium4 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Jerry and Tom 2Given N and values a1..aN, compute 1 minus the continued fraction 1/(a1 + 1/(a2 + ... + 1/aN)) as a reduced fraction P/Q. | Medium4 | MathNumber theory+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Gugu the RaccoonGiven a weighted tree rooted at node 1, find the maximum distance from node 1 to any other node. | Medium4 | TreeDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Number of PapersGiven an N x N grid of -1, 0, 1 values, recursively split non-uniform blocks into 9 equal sub-squares and count how many final uniform blocks hold each value. | Medium5 | Divide and conquerRecursion+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Removing ParenthesesGiven an arithmetic expression with letters and +,-,*,/,() parse it and print an equivalent expression using the fewest parentheses, applying sign/operator flips when parentheses are removed. | Medium5 | RecursionString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Sequence ReductionDecide if repeatedly merging adjacent elements as A[i]-A[i+1] can reduce the sequence to a single target value T. | Medium5 | Dynamic programmingRecursion | No attempts yet | 2s | 128 MB | Judgeable |
| Tree Height and WidthGiven a binary tree's parent-child structure, place nodes on a grid by binary tree layout rules and find the level with the maximum column width, breaking ties by smallest level. | Medium5 | TreeBFS+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Recover Tree PreorderGiven a tree's inorder and postorder sequences, reconstruct the tree and output its preorder traversal. | Medium5 | TreeRecursion+1 | No attempts yet | 5s | 128 MB | Judgeable |
| SequenceFind the K-th lexicographically smallest non-decreasing sequence of N positive integers summing to M. | Medium5 | BacktrackingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Star Printing - 10Recursively draw a Sierpinski-like N x N star pattern where N is a power of 3, replicating the base 3x3 block with blank centers at every scale. | Medium5 | RecursionMatrix+1 | No attempts yet | 1s | 256 MB | Judgeable |
| A Margarita Today?Count subsets of up to 30 prices whose sum is within budget D and whose leftover money cannot afford any unchosen item. | Medium5 | Brute forceRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| SudokuFill the five empty cells (marked 0) in a 9x9 Sudoku grid so every row, column, and 3x3 box contains the digits 1 through 9 exactly once. | Medium5 | BacktrackingImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Folding GameFor each fold sequence on a rectangle, count how many paper layers sit under a given point. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Flipping ColorsRepeatedly split each rectangle in fixed ratios h:v and flip the colors of the upper-right and lower-left parts; report the color reached by each query point. | Medium5 | RecursionDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Genealogical ResearchProcess birth and death records, then answer ancestor and descendant queries by printing the family tree recursively with dates. | Medium5 | RecursionTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FrenemiesFor each dataset, sum the signed scores of all simple paths without neutral links between a given person and every other person. | Medium5 | DFSGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sum It UpGiven a target and up to 12 numbers, list every distinct subset sum equal to the target, sorted in decreasing lexicographic order. | Medium5 | BacktrackingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The End of the WorldGiven a valid intermediate state of the Towers of Hanoi, compute how many more moves remain in the optimal solution. | Medium5 | RecursionDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Normal FormEvaluate a fully parenthesized AND/OR tree where odd levels are AND and even levels are OR, for several long test cases. | Medium5 | TreeImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Introduction to Digital CircuitsParse three-valued logic expressions over P, Q, R and count how many of the 27 assignments make the expression evaluate to 2. | Medium5 | RecursionImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| lsGiven a wildcard pattern where * matches any run of characters, print the input file names that match it, keeping input order. | Medium5 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Royal SuccessionGiven parent pairs for N people, compute each claimant's inherited fraction of the founder's blood and print the claimant with the largest fraction. | Medium5 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Listing Square Arrangements in Lexicographic OrderList every partition of n whose parts are non-increasing, and print the sequences in decreasing lexicographic order. | Medium5 | BacktrackingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SymmetryCount the squares a recursive center-splitting process marks on an N by M grid, where each step splits an odd-by-odd field into four half-sized subfields. | Medium5 | RecursionMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Best ParenthesisGiven a balanced parenthesis string encoded as 0/1 values, compute its recursively defined score modulo 12345678910. | Medium5 | StackRecursion+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Skewed SortingApply a recursive swap procedure on 2^N cows, comparing equal-length halves as base-2^N numbers, and report total distance moved plus final order. | Medium5 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Big DanceRepeatedly split the interval 1..N at the middle (front group gets the extra when odd), pairing cows when a group has exactly two, and add each pair's product to a running sum. | Medium5 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Treasure CaveGiven a binary branching from passage 1, find the list of passages on the unique path from the entrance to passage T and its length. | Medium5 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bit MapsConvert a rectangular bitmap between raw 0/1 array form and its recursive quadrant decomposition, honoring the split rules for odd dimensions. | Medium5 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SlurpysGiven up to 10 short strings, decide whether each one is a Slurpy, meaning a Slimp followed by a Slump under the recursive grammar in the statement. | Medium5 | RecursionString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| In DangerGiven n people in a circle where every second person is eliminated starting from person 1, report the final surviving position; n arrives encoded as xyez. | Medium5 | MathRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Sierpinski FractalDraw the outline of a depth-n Sierpinski triangle in ASCII, 2^n rows tall, with no trailing spaces and blank lines between the test cases. | Medium5 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Decode the TreeGiven a Prüfer code, rebuild the labeled tree on n vertices and print it as a canonical rooted word with children sorted by number. | Medium5 | TreeHeap+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Quad TreeDecode a quad tree string into an n by n black and white image, then print each row as XBM hexadecimal bytes. | Medium5 | RecursionDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Solving Linear EquationsParse each linear equation written in a recursive grammar with parentheses and multiplication, then report no, infinite, or the unique solution rounded to six decimals. | Medium5 | MathRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Alice Through the Looking GlassGiven a magnification level and a cell coordinate, decide whether that cell of the 5^m by 5^m self-similar grid is filled or empty. | Medium5 | RecursionDivide and conquer+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Twenty-fourFor each hand of four cards, find the largest integer value at most 24 reachable by an expression that uses all four values with +, -, *, / and only exact division. | Medium5 | Brute forceRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BananasDecide for each word whether it fits the recursive grammar of a monkey language, where words wrap other words in N and in B...S. | Medium5 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Divided FractalsPrint a rectangle of an iterated square fractal, with rows numbered bottom to top and cells joined by spaces. | Medium5 | RecursionImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pattern GeneratorFor each (n, k) pair, print all n-bit strings with exactly k ones in decreasing numeric order, separated by blank lines. | Medium5 | BacktrackingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree CuttingOn a tree of N nodes, print every node whose removal leaves each connected piece with at most floor(N/2) nodes, or NONE. | Medium5 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Reconstructing Binary TreesGiven the pre-order and in-order traversals of a binary tree with distinct labels, print its post-order traversal or report that no tree matches. | Medium5 | TreeRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Arm Wrestling TournamentSimulate a single-elimination arm wrestling bracket of 2^N players where winners lose strength and recover K before each match; report the champion and the opponents beaten. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SizeofRead a word size and a nested struct declaration and compute its storage size with word alignment. | Medium5 | RecursionImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Make the target from four numbersDecide whether the first four integers can form the fifth using each exactly once with +, -, *, / and parentheses. | Medium5 | Brute forceBacktracking+1 | No attempts yet | 1s | 128 MB | Judgeable |
| One Move from Towers of HanoiGiven n disks and an index k, report the disk and the source and destination posts of the kth move in the classic recursive Hanoi solution. | Medium5 | RecursionBit manipulation+1 | No attempts yet | 3s | 128 MB | Judgeable |
| All SquaresGiven starting size k, count the nested corner squares whose border or interior holds the query point. | Medium5 | RecursionGeometry | No attempts yet | 1s | 128 MB | Judgeable |
| Blue Gene, Jr.Simulate the recursive mutation rules on each short alphanumeric code and print the stabilized code. | Medium5 | RecursionSimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Binary Search Efficiency DoubterGiven a list length n, compute the total number of binary search loop iterations spent finding every element. | Medium5 | MathBinary search+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Formula EquivalenceDecide whether two Boolean formulas with AND, OR, and NOT over at most 16 variables agree on every truth assignment. | Medium5 | Brute forceRecursion | No attempts yet | 1s | 256 MB | Judgeable |
| Googol String (Large)Answer the Kth character of a recursively defined binary string for each query with K up to 10^18. | Medium5 | RecursionBit manipulation | No attempts yet | 5s | 512 MB | Judgeable |
| Broken Calculator (Small)Split X into factors typed with working digits only, minimizing the total of digit, multiply, and equals presses. | Medium5 | Dynamic programmingRecursion+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Decision Tree (Large)Parse a nested decision tree with optional feature names, then multiply node weights along the path chosen by each animal's features. | Medium5 | StringRecursion+2 | No attempts yet | 5s | 512 MB | Judgeable |
| A and B 2Given two strings of A and B, decide whether repeatedly appending A or appending B then reversing can turn S into T. | Medium5 | StringGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Palindromic substringsCount length-N uppercase strings whose length-M substrings include at least K palindromes. | Medium5 | Brute forceString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Movement 3Decide whether (x, y) is reachable by moving 3^k right or up on each step k, starting at the origin. | Medium5 | MathBit manipulation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Equal leaf distancesRaise edge weights in a weighted perfect binary tree so every root-to-leaf path has equal length, minimizing the total weight. | Medium5 | TreeGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| ResignationGiven each day's consultation length and payment, pick a non-overlapping set of jobs that all finish before day N+1 to maximize total payment. | Medium5 | Dynamic programmingBrute force+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Reincarnated as a Slime Researcher (Easy)Given a starting integer K, repeatedly factor it into two factors at least 2, minimizing the maximum number of splits along any root to leaf path. | Medium5 | GreedyNumber theory+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| SlurpyDecide whether each uppercase string is a Slurpy, meaning a Slimp immediately followed by a Slump, where both are defined by recursive grammar rules. | Medium5 | RecursionString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TilingCount the ways to tile a 3 by W rectangle with 2 by 1 dominoes, printing the result modulo 1e9+7. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sum of a geometric sequenceAdd the first n terms of a geometric sequence with first term a and ratio r, then print the sum modulo mod. | Medium5 | Divide and conquerMath+1 | No attempts yet | 0.5s | 128 MB | Judgeable |
| Engineering CalculatorEvaluate an integer arithmetic expression with precedence, right-associative exponentiation and square root, and truncation toward zero for incomplete roots and divisions. | Medium5 | RecursionMath+2 | No attempts yet | 1s | 256 MB | Judgeable |
| BlogGiven a string of R, G, and B, find the minimum number of contiguous same-color paint operations needed to build it. | Medium5 | Dynamic programmingString+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Level HamburgerA level-N burger is defined recursively from buns and patties; count how many patties lie in the bottom X layers. | Medium5 | RecursionDivide and conquer+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| What Does UNIST Stand For?Count ways to pick a prefix of each of N words so the concatenation spells UNIST, modulo 1e9+7. | Medium5 | Dynamic programmingString+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fractal PlanePrint a rectangular window of the grid at time s, where each step splits every cell into N x N and blacks out a centered K x K block. | Medium6 | Divide and conquerRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Random Number GeneratorGiven a linear congruential generator with huge parameters up to 10^18, compute the n-th term modulo m and then modulo g using fast exponentiation. | Medium6 | MathRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Can You Do Arithmetic?Parse and evaluate an arithmetic expression with +,-,*,/ and parentheses, respecting precedence, and print ROCK if the expression is invalid or divides by zero. | Medium6 | StringStack+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Infinite Sequence 2Compute A_N for a recursively defined sequence using nested floor divisions, requiring memoized recursion over a bounded set of distinct arguments. | Medium6 | RecursionMath+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Sum of Largest Power-of-Two DivisorsGiven A and B up to 10^15, compute the sum over that range of the largest power-of-two divisor of each integer. | Medium6 | MathNumber theory+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Prefix Reversal 3Given a string, for each prefix length from 1 to N in order you may choose to reverse that prefix, and you must output the lexicographically smallest string achievable after all choices. | Medium6 | StringGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tree EncodingGiven N and an index, find the k-th lexicographically smallest preorder traversal string among all binary search trees built from the first N letters, using Catalan number counting. | Medium6 | CombinatoricsMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Substitution Sequence Range CountsCount occurrences of 1, 2, 3 in a fixed interval of a sequence generated by simultaneous ternary substitution after N steps, without building the whole sequence. | Medium6 | RecursionDivide and conquer+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Fiibonacci TreeGiven preorder indices of two nodes in a recursively built Fibonacci binary tree, compute the shortest L/R/U path between them without ever materializing the tree. | Medium6 | TreeRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| XYZ StringGiven a self-similar X/Y/Z rewriting sequence, answer queries about the stage N string's length, its k-th character, or the count of a given character without building the full string. | Medium6 | RecursionDivide and conquer+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Flattening TablesParse nested HTML-style table layouts and output an equivalent single flat table using rowspan and colspan to preserve row and column alignment. | Medium6 | RecursionTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PibonacciCompute a Fibonacci-like sequence defined with the irrational constant pi as a recursive step and output it modulo 10^18. | Medium6 | Dynamic programmingRecursion+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Paper FoldingGiven a crease pattern of length 2^N-1, decide if it could arise from repeatedly folding the right half of a strip onto the left half. | Medium6 | Divide and conquerRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Partitioning for Fun and ProfitGiven m, n and k, output the k-th lexicographically smallest partition of m into n non-decreasing positive parts. | Medium6 | CombinatoricsDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Logical ExpressionsParse a custom logical expression grammar with user-defined unary and binary operator truth tables, then evaluate it to true, false, or unknown given partial variable assignments. | Medium6 | RecursionString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Image CompressionBuild the quadtree of an image padded to the next power-of-two square, then count total nodes and the minimum nodes after sharing identical non-leaf subtrees. | Medium6 | TreeRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Golomb SequenceGiven n up to 2 billion, compute the n-th term of the self-describing Golomb sequence efficiently. | Medium6 | MathRecursion+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Star Printing - 11Recursively build and print a Sierpinski-like star triangle of height N=3·2^k using the fractal rule of stacking scaled copies with exact spacing. | Medium6 | RecursionImplementation+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Recursive Palindrome PartitionsCount recursive palindrome partitions of N, where a partition is valid if it is a palindrome and both halves are recursively valid. | Medium6 | Dynamic programmingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hanging MonkeysParse a nested bracket string representing a binary vine structure and compute the minimum monkeys needed so every split has equal counts on both sides. | Medium6 | RecursionString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Complete Binary TreeFill a complete binary tree of level N with numbers 1 to 2^N-1 so each internal node's left/right subtree sums differ by exactly 2^D, then output preorder. | Medium6 | RecursionTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Beautiful NamesCount the number of orderings of N distinct strings such that all strings sharing a common prefix always form a contiguous block, modulo 1e9+7. | Medium6 | TrieCombinatorics+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Company RestructuringGiven a rooted tree where reporting edges may only be rewired within original parent-child-sibling triples, output a new tree with at most 2 children per node and at most one higher-IQ child than its manager. | Medium6 | TreeGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Football RankingRank football teams by points with a recursive mini-league tiebreak among tied teams, falling back to goal difference, goals scored, wins, then team number. | Medium6 | SimulationSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Moore MachineParse a series-parallel Moore machine expression and determine the unique erased output symbol that matches an observed string, or report ambiguity or impossibility. | Medium6 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MinistryParse a nested ternary-tree encoding of an organization and, using tree canonicalization/hashing, count structurally distinct subtrees grouped by depth. | Medium6 | TreeRecursion+1 | No attempts yet | 2s | 128 MB | Judgeable |
| FractalGiven a recursively self-similar fractal built from a base polyline, find the point at a given fraction of its total arc length after d recursive refinements. | Medium6 | RecursionGeometry+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The SetStack ComputerSimulate a stack machine whose elements are hereditarily finite sets, printing top-of-stack cardinality after each of five set operations. | Medium6 | Hash mapStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FirefightersDetermine if question-mark operators in an arithmetic expression with brackets can be replaced by +,-,*,/ to reach a given target value under integer truncating division. | Medium6 | Brute forceRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CountdownFind the closest achievable value to a target by combining six given numbers with the four operations, keeping intermediate results positive integers. | Medium6 | Brute forceRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |