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 |
|---|---|---|---|---|---|---|
| The nth Fibonacci NumberGiven n up to 20, compute the nth Fibonacci number defined from 0 and 1. | Easy1 | Dynamic programmingRecursion | No attempts yet | 1s | 256 MB | Judgeable |
| Born in 1998, but 2541 in Thailand?!Given a Buddhist calendar year between 1000 and 3000, print the corresponding Gregorian year by subtracting 543. | Easy1 | MathImplementation+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Cantor SetFor each N, print a line of 3^N characters following the Cantor set rule: each third-level block of size 3^k has its middle third blanked, dashes elsewhere. | Easy2 | RecursionImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Constrained PermutationsCount permutations of 1..n (n at most 9) that satisfy given ordering constraints x before y. | Easy2 | Brute forceCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Huffman TreeGiven Z characters and arity N, decode the stored digit string into the per-character encoding. | Easy2 | TreeString+1 | No attempts yet | 3s | 128 MB | Judgeable |
| ICPC CalculatorEvaluate a dot-indented prefix expression where + sums its operands and * multiplies them. | Easy2 | RecursionTree+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Pascal's TriangleGiven n and k with 1 <= k <= n <= 30, print the k-th entry of row n in Pascal's triangle, equal to C(n-1, k-1). | Easy2 | MathCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| What Is a Recursive Function?Given N, print the chatbot message 'What is a recursive function?' repeated with nested quotation marks for N levels of recursion. | Easy2 | ImplementationString+1 | No attempts yet | 1s | 256 MB | Judgeable |
| ZGiven N and coordinates (r,c) in a 2^N x 2^N grid, compute the visit order index of that cell under recursive Z-order (Morton order) traversal. | Easy3 | Divide and conquerRecursion+1 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Largest Lucky NumberGiven N up to 1,000,000, find the largest number no greater than N whose digits are only 4s and 7s. | Easy3 | RecursionBrute force+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Count Numbers Made Only of 4 and 7Count integers between A and B (up to 1e9) whose digits are all 4s and 7s. | Easy3 | Brute forceCombinatorics+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Modular ExponentiationCompute A raised to the power B modulo C efficiently using fast modular exponentiation. | Easy3 | MathNumber theory+1 | No attempts yet | 0.5s | 128 MB | Judgeable |
| Tower of HanoiPrint the minimum move count for Tower of Hanoi with N disks, using big-integer count for N up to 100 and the explicit move sequence when N is at most 20. | Easy3 | RecursionMath+1 | No attempts yet | 6s | 128 MB | Judgeable |
| Tree TraversalBuild a binary tree from parent-child input and print its preorder, inorder, and postorder traversals. | Easy3 | TreeDFS+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Making Colored PaperRecursively quadtree-split an N×N grid of 0/1 cells into uniform-color squares and count the resulting white and blue pieces. | Easy3 | RecursionDivide and conquer+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Apartment ResidentsCompute the resident count in room n on floor k, defined by repeated prefix sums starting from room i having i residents on floor 0. | Easy3 | Dynamic programmingMath+1 | No attempts yet | 0.5s | 128 MB | Judgeable |
| Fibonacci NumberGiven n, print the n-th Fibonacci number, where the sequence starts 1, 1 and each later term is the sum of the previous two. | Easy3 | Dynamic programmingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SmeechParse a prefix Smeech expression with probabilistic plus or minus operators and compute its expected value to two decimals. | Easy3 | RecursionMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Elias Omega CodingFor each positive integer until a terminating 0, output its Elias omega code, built by recursively prepending the code of the bit length. | Easy3 | Bit manipulationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Leisurely StrollGiven a rooted tree of choice-nodes where leaf edges lead to pastures, find the maximum number of edges on any root-to-pasture path. | Easy3 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Going to the MoviesGiven a truck capacity C and up to 16 cow weights, pick a subset whose total weight is as large as possible without exceeding C. | Easy3 | Brute forceBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Help the problem setterFor each test case, read a binary search tree on labels 1..n and print each node's frequency, computed bottom-up as 1 plus the sum of the frequencies of all its proper descendants. | Easy3 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Genetic CodePrint the first n characters of the infinite square-free sequence generated by the substitution N→NOP, O→NP, P→O. | Easy3 | StringRecursion | No attempts yet | 1s | 128 MB | Judgeable |
| Stuttering StringsFor each input case, the program prints every length-n string over * and ! whose runs stay within the given limits, in lexicographic order with * first. | Easy3 | BacktrackingRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Function run funCompute the recursive function w(a, b, c) with memoization for each query line until -1 -1 -1. | Easy3 | Dynamic programmingRecursion | No attempts yet | 1s | 128 MB | Judgeable |
| Even More DicePrint every nondecreasing roll of n m-sided dice that sums to s in lexicographic order for each test case. | Easy3 | BacktrackingRecursion | No attempts yet | 5s | 512 MB | Judgeable |
| Bus 3000Given k stops where half the riders plus half a rider get off each time until the bus is empty, find the starting passenger count. | Easy3 | MathRecursion | No attempts yet | 1s | 128 MB | Judgeable |
| Candy FactoryEach parent in a heap-ordered binary tree makes as many candies as the smaller child count, and the total subtracts consumed ingredients from all made candies. | Easy3 | TreeRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Quadtree Image CompressionCount the bits produced by recursively splitting an L by L binary image into quadrants until each block is uniform. | Easy3 | Divide and conquerRecursion+1 | No attempts yet | 2s | 1024 MB | Judgeable |
| Complete Binary TreeReconstruct each level of a complete binary tree from its inorder visit order. | Easy3 | TreeRecursion | No attempts yet | 1s | 128 MB | Judgeable |
| All PermutationsPrint every permutation of the numbers 1 to N in lexicographic order, one per line. | Easy3 | BacktrackingRecursion | No attempts yet | 1s | 256 MB | Judgeable |
| Printing Stars - 19Print the N-level nested square star figure that the sample cases define. | Easy3 | RecursionImplementation | No attempts yet | 1s | 256 MB | Judgeable |
| Bell RingingPrint all permutations of 1 to n in the recursive insertion order where bell n sweeps each row left to right or right to left. | Easy3 | RecursionImplementation | No attempts yet | 2s | 256 MB | Judgeable |
| Tower of Hanoi move sequencePrint the minimal sequence of moves that transfers N disks from rod 1 to rod 3 under the smaller-on-larger rule. | Easy3 | RecursionImplementation | No attempts yet | 1s | 256 MB | Judgeable |
| Googol String (Small)Build the recursive 0/1 string defined by S with a middle 0 plus a switched reversal, then answer the Kth character for each test case. | Easy3 | RecursionSimulation | No attempts yet | 5s | 512 MB | Judgeable |
| TriangleRecursively subdivide a triangle into three corner triangles N-1 times and print the resulting ASCII fractal. | Easy3 | Divide and conquerRecursion+1 | No attempts yet | 1s | 64 MB | Judgeable |
| String PermutationPrint every permutation of a short string of distinct characters, in the order given by the original character positions. | Easy3 | BacktrackingRecursion+1 | No attempts yet | 5s | 512 MB | Judgeable |
| N and M (1)Print every length-M sequence of distinct numbers chosen from 1 to N, in increasing lexicographic order. | Easy3 | BacktrackingRecursion | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (2)Print all ascending sequences of M distinct numbers chosen from 1 to N, in lexicographic order. | Easy3 | BacktrackingRecursion+1 | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (3)Print every length-M sequence from 1 to N in lexicographic order, allowing repeats. | Easy3 | BacktrackingRecursion+2 | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (4)Print all non-decreasing sequences of length M chosen from 1 to N, each exactly once, in lexicographic order. | Easy3 | BacktrackingRecursion | No attempts yet | 1s | 512 MB | Judgeable |
| Length M sequences from N numbersGiven N distinct numbers and an M, print every length-M permutation of the numbers in lexicographic order without repeats. | Easy3 | BacktrackingRecursion+2 | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (6)Given N distinct natural numbers and M, print every ascending M-element subsequence in lexicographic order without repeats. | Easy3 | BacktrackingSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (10)Given N numbers and an M, print every non-decreasing length-M selection of the numbers in lexicographic order without duplicates. | Easy3 | BacktrackingSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Virus OutbreakRead hour values until -1 and print the Fibonacci number a(X) for each in the format 'Hour X: Y cow(s) affected'. | Easy3 | MathDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Binary Search TreeInsert a sequence of integers into a BST and output the depth of each inserted node. | Easy3 | TreeRecursion+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Season of ReadingReplace WHO, WHERE, and WHAT in each sentence with the given resolving elements, expanding nested references. | Easy3 | StringRecursion+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Alpha Tic-Tac-ToeGiven a 3x3 tic-tac-toe board with X to move or O to move, find whether the side to move can force a win, a draw, or only a loss under perfect play. | Easy3 | Game theoryRecursion+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Total Number of CountsGiven N bills and bundle size M, repeatedly count items and group them into bundles of M until no bundle can form, then print the total number of counts. | Easy3 | MathSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Sam-sam NumberDecide whether N can be written as a sum of distinct powers of 3, using each power at most once. | Easy3 | MathImplementation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Thue-Morse StringFind the character at position k in the Thue-Morse sequence, where k can be as large as 10^18. | Easy3 | Bit manipulationMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Endless StringStarting from a string A, repeatedly replace every $ in S with the previous result, then print characters from position min to max after N runs. | Medium4 | StringRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Infinite SequenceCompute the N-th term of a sequence where A_i equals A at floor(i/P) plus A at floor(i/Q), using memoized recursion for huge N. | Medium4 | RecursionDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Decompressed String LengthCompute the total length of a string after fully expanding nested K(Q) compression patterns, where K is a single digit repeat count. | Medium4 | StackString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Quad Tree CompressionGiven an N x N binary grid, recursively quadrant-compress it into a string using uniform-region shortcuts and parenthesized quadrant order. | Medium4 | Divide and conquerRecursion+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Chemical Formula MassParse a chemical formula with nested parentheses and digit multipliers to compute the total atomic mass using H=1, C=12, O=16. | Medium4 | StackString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Bracket ValueParse a bracket string with two bracket types and compute its defined nested value, or output 0 if it is invalid. | Medium4 | StackString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Molecular MassParse a nested chemical formula with parentheses and repeat counts, then compute the total molecular mass from atomic weights. | Medium4 | StackRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CalculatorParse and evaluate fully parenthesized arithmetic expressions with big integers up to 90 digits, printing Error on overflow, negative results, or division by zero. | Medium4 | StringMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Guess the NumbersDetermine whether some permutation of up to 5 given values assigned to the unknowns in a fully parenthesized arithmetic expression makes it evaluate to a target result. | Medium4 | Brute forceRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Molecular FormulaParse a nested molecular formula with repetition counts and atomic weight lookups to compute total molecular weight, or report UNKNOWN. | Medium4 | RecursionString+1 | No attempts yet | 3s | 128 MB | Judgeable |
| TreeGiven the preorder and inorder traversals of a binary tree, reconstruct the tree and print its postorder traversal. | Medium4 | TreeRecursion+1 | No attempts yet | 1s | 192 MB | Judgeable |
| TautologyGiven propositional formulas in Polish notation, decide for each whether it is a tautology by parsing and evaluating it over every truth assignment. | Medium4 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A Smart Brain is a Tasty BrainParse each of up to 10000 Boolean expressions, evaluate it, and report whether the brain's given answer matches. | Medium4 | StringStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Symbolic Logic MechanizationParse a prefix logic formula, report the first syntax error left to right, then classify it as a tautology, contradiction, or contingent. | Medium4 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Image CompressionCompress a binary square bitmap with a quadtree and a majority threshold, then output the image the encoding reconstructs. | Medium4 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Set-Theoretic Number NotationParse two numbers given as von Neumann ordinal sets, add their values, and print the sum in the same nested-brace notation. | Medium4 | StringRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Musical ChairsGiven N children in a circle and a step D, repeatedly remove the D-th child counting around the circle; report the last child left plus N and D. | Medium4 | MathSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Flatten the ExpressionParse a recursively repeated bracketed expression and print its flattened string without spaces. | Medium4 | StringRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bale ShareAssign N bales (N up to 20) to three barns so the largest barn total is as small as possible, and print that smallest possible largest total. | Medium4 | Brute forceRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow PinballGiven a triangle of nail scores with R rows, find the maximum sum along a path from the top nail down to the last row, moving to one of the two adjacent nails below each step. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Strange Towers of HanoiCompute the minimum number of moves to transfer n disks (n at most 12) from tower A to tower D using four towers. | Medium4 | Dynamic programmingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Roads Around the FarmGiven N cows and a difference K, a group of size s splits into two nonempty groups differing by K when possible; count the final grazing groups. | Medium4 | RecursionMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Eating PuzzleGiven up to 21 bucket sizes and a calorie limit, choose a subset with the largest sum that does not exceed the limit. | Medium4 | Brute forceBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Sultan's SuccessorsFor each 8x8 board, place 8 non-attacking queens to maximize the sum of the numbers on the occupied squares. | Medium4 | BacktrackingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Quad TreeParse an XBM hex bitmap, then recursively encode it as a quad tree: uniform squares become B or W, mixed ones become Q followed by four sub-squares. | Medium4 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree RecoveryGiven a binary tree's preorder and inorder traversal strings, print its postorder traversal. Process runs until end of file. | Medium4 | TreeRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| LottoFor each set of k numbers in ascending order, print all 6-element subsets in lexicographic order, separated by blank lines. | Medium4 | BacktrackingRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Matrix Chain MultiplicationGiven matrices with dimensions and fully parenthesized products, report the elementary multiplication count or an error if dimensions mismatch. | Medium4 | StackRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| From Prefix to PostfixTranslate each prefix arithmetic expression over + and - into its equivalent postfix form, stopping at the terminating 0. | Medium4 | StackTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Double Knockout CompetitionSimulate a double-elimination tournament round by round and print the number of undefeated, one-loss, and eliminated teams after each round. | Medium4 | SimulationMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BalanceCount the orders and pan choices for placing n distinct weights so the left pan is never heavier than the right at any step. | Medium4 | Brute forceBacktracking+2 | No attempts yet | 2s | 128 MB | Judgeable |
| DyzioParse a 0/1 description of recursive halving cuts and output the cut count at which the first shortest piece appears. | Medium4 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Recursive Pattern (Szlaczek)Given a starting sequence that is repeatedly extended by appending its own reversal, report the value at position M. | Medium4 | RecursionArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Quad TreesBuild the quadtree partition of each binary image and print its level-order bitstream as uppercase hex without leading zeros. | Medium4 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Single Digit AdderEvaluate each line as an arithmetic expression of single digits with plus, minus, and parentheses. | Medium4 | StackRecursion | No attempts yet | 1s | 128 MB | Judgeable |
| TicketsPrint the K-th n-bit string in reflective Gray code order for the given n and K. | Medium4 | Bit manipulationRecursion | No attempts yet | 1s | 64 MB | Judgeable |
| Uncompressing Compressed WordsExpand each nested compressed word by concatenating its parts and repeating the group n times. | Medium4 | RecursionStack+1 | No attempts yet | 1s | 256 MB | Judgeable |
| ShipuraEvaluate expressions that combine floor division by powers of two with squaring modulo 1,000,000,007 and nested brackets. | Medium4 | StackRecursion+1 | No attempts yet | 8s | 512 MB | Judgeable |
| Star Pattern 18Print the size N star figure of nested triangles with alternating orientation defined recursively. | Medium4 | RecursionMatrix+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Decision TreeParse a recursively defined decision tree, then for each animal walk the tree using its features and multiply node weights to get the probability. | Medium4 | TreeRecursion+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Counting Ugly ExpressionsInsert +, -, or nothing between adjacent digits of a digit string, count how many of the 3^(D-1) expressions evaluate to a number divisible by 2, 3, 5, or 7. | Medium4 | Brute forceRecursion+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Far Far AwayGiven a directed tree rooted at city 1 with weighted edges, find the maximum root-to-node path weight, or -1 if it stays below M. | Medium4 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Obfuscated TreesDecode a tree from its obfuscated token stream, where each internal node carries an ordering code and subtree count, then print its values in pre-order. | Medium4 | TreeRecursion+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Hidden PalindromeGiven a word of at most 40 lowercase letters, find the longest palindromic subsequence obtainable by deleting letters from the front and back. | Medium4 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| N and M (7)Given N distinct numbers and a length M, print every length-M sequence drawn from the numbers with repetition allowed, deduplicated and in increasing lexicographic order. | Medium4 | BacktrackingRecursion+2 | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (8)Given N distinct natural numbers and a length M, print all non-decreasing sequences of length M drawn from the numbers, in lexicographic order. | Medium4 | BacktrackingSorting+1 | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (9)Given N numbers (with duplicates) and length M, print every distinct length-M selection in increasing lexicographic order, using each copy at most once. | Medium4 | BacktrackingSorting+1 | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (11)Given N numbers and a length M, list every length-M sequence drawn from the numbers, allowing repeats, in increasing lexicographic order without duplicates. | Medium4 | BacktrackingRecursion+2 | No attempts yet | 1s | 512 MB | Judgeable |
| N and M (12)Given N numbers and a length M, list all non-decreasing length-M sequences drawn from the numbers with repetition, in lexicographic order. | Medium4 | BacktrackingSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |