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 |
|---|---|---|---|---|---|---|
| Which is NextGiven a binary tree's numeric identifier under a bijective encoding, compute the identifier of the next tree in a defined ordering among same-size trees, wrapping around if it is the largest. | Medium7 | RecursionMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Complicated ExpressionsParse an arithmetic expression with parentheses and reprint it with every redundant parenthesis removed while preserving exact operator precedence and associativity semantics. | Medium7 | StringRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Auxiliary Question of the UniverseGiven a fragment of an arithmetic expression grammar (numbers, plus, parentheses), find the minimum insertions needed to make it a valid expression while keeping the fragment as a subsequence. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Kripke ModelGiven a Kripke model with n up to 10000 states, compute the set of states satisfying the CTL formula E(x U (AG y)) using fixed-point graph algorithms. | Medium7 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Castle GuardsGiven a recursively described tree of small buildings connected by corridors, compute the minimum vertex cover (guard placement) that watches every corridor in the whole castle. | Medium7 | Dynamic programmingTree+2 | No attempts yet | 2s | 128 MB | Judgeable |
| MobileGiven a recursively nested mobile of weighted objects, find the minimum number of object weights to change so every rod balances left and right. | Medium7 | TreeDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Common PolynomialParse two polynomial expressions with parentheses and exponents, expand them, then compute and print the normalized greatest common divisor polynomial. | Medium7 | MathRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Best Name for Your BabyGiven a context-free grammar-like rewriting rule set, find the lexicographically smallest terminal string of exactly length l derivable from start symbol S. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MobileGiven a full binary tree of rods and toys, find the minimum number of left-right child swaps so that all toys sit at depths differing by at most 1, with deeper toys to the left. | Medium7 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A Foldy but a GoodyFold a paper strip n times by upper and lower folds, unfold it into right angles, and find the coordinates of the m-th point along it. | Medium7 | RecursionDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BurnoutGiven a nested repeating on/off pattern and a target on-time N, find the elapsed time when total on-time first reaches N. | Medium7 | RecursionSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Preorder and PostorderCount how many m-ary trees share the given pre-order and post-order traversals. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| OrigamiGiven up to 8 folds of a square sheet, count how many layers of paper a query point pierces, ignoring points on edges. | Medium7 | GeometrySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Lightbulb TestingGiven a bulb life n and a periodic on/off pattern (with nested repeating groups), find the real time elapsed when total on-time reaches n. | Medium7 | ImplementationMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Syntax IncludedParse each HTML-like string against the given grammar and decide whether it is syntactically valid. | Medium7 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tournament BracketsGiven team pairings listed in column-major order and the champion, reconstruct the tournament bracket and render it with slashes, backslashes, and underscores. | Medium7 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Apply a Cold CompressDecode each compression-expression into its smallest pixel picture by parsing split tags and computing the relative scaling of the two halves, then draw the framed grid. | Medium7 | RecursionDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Walsh MatrixSum entries in one row of a Walsh matrix over columns S through E, where the matrix size 2^N can reach 2^60. | Medium7 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Functional Programming CountsImplement an interpreter for a tiny functional language with variables, single-parameter functions, and call-count profiling per definition line. | Medium7 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Protect Our Treasure!Given each pirate's set of keys, list every minimal group whose union covers all locks, ordered by size then lexicographically. | Medium7 | CombinatoricsBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Nim/3Three-player Nim where each player has a preferred winner; find player 1's optimal move with smallest stack then smallest count. | Medium7 | Game theoryDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Myth BustersFor each city's list of four-digit carriage IDs, decide whether every ID can reach the value 10 by permuting its digits and inserting +, -, *, / with parentheses. | Medium7 | Brute forceRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Surveillance CamerasGiven up to 50,000 distinct grid points, decide whether three axis-parallel lines (full rows or columns) can cover all of them. | Medium7 | Brute forceRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dreisam EquationsInsert +, -, and * into a number-and-parenthesis equation so it holds under strict left-to-right evaluation, choosing the lexicographically smallest valid string. | Medium7 | BacktrackingImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Picture PuzzleCount the number of ways to place and rotate nine square pieces into a 3x3 grid so every touching edge pair matches (same letter, one L half and one R half). | Medium7 | BacktrackingBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Calculator LanguageEvaluate expressions in a tiny language with right-associative equal-precedence operators, assignment, and right-to-left operand evaluation, then report changed variables. | Medium7 | ImplementationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Peter's CalculatorParse assignment, PRINT, and RESET statements, evaluate expressions with variables, detect cycles or undefined references, and print values or UNDEF. | Medium7 | ImplementationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ExpressionsGiven a postfix expression, produce another postfix expression that the same algorithm evaluates to the same value when a queue replaces the stack. | Medium7 | StackQueue+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Binary Search Heap ConstructionGiven label/priority pairs, build the unique treap (a binary search tree on labels and a max-heap on priorities) and print it in nested parenthesized form. | Medium7 | TreeStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sylvester constructionGiven a Hadamard matrix built by the Sylvester doubling rule, print a small rectangular sub-matrix specified by its top-left corner. | Medium7 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Lazy and Strict EvaluationGiven function definitions in a small Lisp-like language, count how many times each arithmetic operation runs under lazy (memoized) versus strict evaluation, skipping non-terminating tests. | Medium7 | ImplementationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Simplified λ-evaluationsEvaluate simplified lambda-calculus expressions by substitution, stopping after 1000 applications and printing unterminated if it does not finish. | Medium7 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| S and KGiven binary trees written with S and K, repeatedly apply the two rewrite rules until no rule fires, then print the final tree string. | Medium7 | ImplementationSimulation+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Snowball FightGiven fixed alternating throwing order and hit probabilities, players choose targets to maximize their team's win chance; compute win and draw probabilities under optimal play. | Medium7 | Game theoryProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| QuadTreesGiven pre-order strings of two quadtrees for N x N binary images, count the nodes in the quadtree of their pixelwise AND intersection, collapsing uniform quadrants. | Medium7 | TreeDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cake CuttingCount the distinct rectangular pieces that can be left after repeatedly halving a cake into two equal halves with equal candle counts. | Medium7 | Divide and conquerRecursion+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| DictionaryGiven a list of words, insert leading spaces so the list satisfies a recursive definition: every maximal run of words sharing a first letter must, after removing the first word and that letter, again be a dictionary. | Medium7 | TrieRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| List CalculatorImplement an interpreter for a small list language with slicing, unary and binary elementwise operators, concatenation, and single-character variable assignment. | Medium7 | ImplementationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bargain or No BargainGiven prize values and a budget M, decide whether optimal play maximizing expected log utility yields expected prize money above M. | Medium7 | Dynamic programmingProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Counting Satisfying AssignmentsParse one logical formula and count how many of the 4096 assignments to twelve variables make it true. | Medium7 | ImplementationSimulation+2 | No attempts yet | 2s | 256 MB | Judgeable |
| FloorsGuillotine-cut a rectangle tiled by disjoint rectangles into the smallest possible pieces and output the largest piece's area. | Medium7 | Divide and conquerGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Printed-Circuit BoardsGiven a series-parallel circuit described recursively, find the minimum number of connections that must be routed on the top side so every unit is reached from the top. | Medium7 | TreeDynamic programming+2 | No attempts yet | 3s | 128 MB | Judgeable |
| ChainGiven which rings of a bytish chain are on a bar, find the minimum number of legal put-on/take-off moves to remove all rings. | Medium7 | Dynamic programmingRecursion+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Binary Search Tree CodeGiven n and k, output the n-th preorder string among all BSTs built from the first k letters, listed in alphabetical order. | Medium7 | TreeRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Number of Symmetrical ChoicesGiven two word sequences of length n, count how many of the 2^n ways of picking one word per index produce a palindrome when concatenated. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TreesGiven a sequence of leaf levels, decide whether it is a valid complete binary tree; if so, output the genealogical and bracket representations. | Medium7 | TreeRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Algorithm SpeedupDecide whether a recursively defined Boolean function F on two sequences returns 1 or 0, where F strips the longest prefix and suffix that drop some value. | Medium7 | RecursionHash map+2 | No attempts yet | 8s | 128 MB | Judgeable |
| Two-Colored Towers of HanoiThe task is to compute the minimum moves to gather odd disks on peg B and even disks on peg C under Hanoi rules. | Medium7 | Dynamic programmingRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Up a TreeGiven three garbled preorder, inorder and postorder outputs from mixed-up recursive calls, list every call assignment and the smallest tree that fits each one. | Medium7 | TreeBacktracking+2 | No attempts yet | 6s | 128 MB | Judgeable |
| ChonSuGiven the distances between consecutive leaves of an unknown full binary tree, compute the distance between two specified leaves. | Medium7 | TreeDivide and conquer+1 | No attempts yet | 1s | 128 MB | Judgeable |
| King and PawnPredict whether the king captures the pawn or the pawn escapes on an 8x8 board with forbidden and danger cells when both play best. | Medium7 | Game theoryRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Making S with two cellsYou start with cells holding a and b, repeatedly add one cell to the other, and must decide whether the value S can ever appear in either cell. | Medium7 | Number theoryMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Digital Content ProtectionGiven the hacked leaves of a complete binary key tree, print the identifiers of the smallest set of unexposed node keys covering every intact player. | Medium7 | GreedyTree+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Nested PalindromeFill each question mark with a digit to build the k-th smallest nested palindrome with no equal adjacent digits, or print -1. | Medium7 | RecursionCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Decoding the HallwayFor each query, decide whether the given string appears as a contiguous substring of the turn record built after n hallway walks. | Medium7 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Super AntsAn ant on a grid cell collects its value and spawns clones along eight rays within the remaining time, and you compute the total score modulo 1e9+7. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Switch ArrayFind the fewest restricted toggles that turn each given bit string into all zeros. | Medium7 | RecursionDynamic programming+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Generalized Roman NumeralsGiven a string of Roman letters, list every distinct value it can take under all parenthesizations of the subtract-when-smaller rule. | Medium7 | Dynamic programmingIntervals+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Recursive Function zYou evaluate the recursive function at n/m by tracing its arguments into a repeating cycle and solving the linear equations exactly. | Medium7 | MathGraph+1 | No attempts yet | 5s | 256 MB | Judgeable |
| LRFill each ? with an allowed character to form a valid L and R expression with the largest possible value, or report invalid. | Medium7 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Guillotine Card GameCompute each player's final score in a three-player card game where one player secretly plays to minimize another player's score. | Medium7 | Game theoryBacktracking+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Ancient Commemorative MonolithThe program parses each bitmap into nested boxes and glyphs and prints the bracketed transliteration with mirror reading resolved. | Medium7 | MatrixRecursion+2 | No attempts yet | 8s | 256 MB | Judgeable |
| Cutting an L-shaped paperThe program cuts the given L-shaped sheet with guillotine cuts into integer-sided squares with the fewest pieces. | Medium7 | Dynamic programmingGeometry+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Array splittingRepeatedly quarter an N by M array until a side reaches 1, then list each distinct strip length with its count modulo 1234567891. | Medium7 | Divide and conquerRecursion+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Dragon curveReport the cursor position after the Xth drawn segment of the order N dragon curve generated by the given rewriting rules. | Medium7 | RecursionDivide and conquer+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Cutting BrowniesGiven a B by D brownie sheet where Harry cuts depth and Vicky cuts breadth, decide if the named starting player has a forced win. | Medium7 | Game theoryDynamic programming+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Counting Odd Binomial CoefficientsCount the pairs (m, k) with m below n whose binomial coefficient is odd. | Medium7 | Number theoryBit manipulation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Word by mouthSimulate the recursive WBM(m) vote, where faulty friends always forward cat, and report each loyal friend's majority word. | Medium7 | SimulationDynamic programming+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Hacking the ScreenParse an arithmetic formula with square roots and fractions drawn as ASCII art up to three lines high and print its integer value. | Medium7 | ImplementationRecursion+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Symmetric Trees (Large)Decide whether a color-painted tree can be drawn in the plane with a vertical line of symmetry. | Medium7 | TreeRecursion+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Bacteria Growth (Small)Apply the map x to x^x exactly B times starting from A and report the result modulo C. | Medium7 | Number theoryRecursion | No attempts yet | 5s | 512 MB | Judgeable |
| Bacteria Growth (Large)Starting from A bacteria that grow from x to x^x each hour, compute the count after B hours modulo C. | Medium7 | Number theoryRecursion+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Number GameCount the pairs in the given rectangle from which the first player wins the subtraction game where moving to zero or below loses. | Medium7 | Game theoryNumber theory+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Bribe the Prisoners (Small)Choose the release order of Q prisoners out of P cells to minimize total bribes, where each release bribes every still-occupied prisoner reachable from it until a boundary or empty cell. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Bribe the Prisoners (Large)Given prison cells in a row and a set of cells to release one per day, choose the release order that minimizes total bribes paid to prisoners who hear the news. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Sum of matrix powersCompute A + A^2 + ... + A^B for an N by N matrix A, with B up to 1e11, printing every entry modulo 1000. | Medium7 | Divide and conquerMatrix+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Stephen CookTwo players alternately assign truth values to variables of a boolean formula; Cook moves first and wins if the formula ends true. Decide the winner under optimal play. | Medium7 | Game theoryDynamic programming+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Merging treesGiven a left-handed and a right-handed ternary tree, find the minimum number of vertices in a ternary tree that is a superposition of both. | Medium7 | TreeDynamic programming+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Folding MachineGiven two integer tapes, decide whether folding one tape can ever produce the other. | Medium7 | Divide and conquerRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Crystal JailsGiven up to 27 small polycube blocks that may be rotated but not reflected, decide whether they tile a W x D x H box exactly. | Medium7 | BacktrackingRecursion | No attempts yet | 8s | 512 MB | Judgeable |
| Reading DigitsDecode the given run-length-encoded string k times, then report the digit at index pos of the original string s. | Medium7 | StringImplementation+1 | No attempts yet | 0.1s | 256 MB | Judgeable |
| Combining RiceballsGiven a row of riceballs, merge equal adjacent pairs or equal pairs with one ball between them, and find the largest size reachable. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Rather Perplexing Showdown (Large)Find the alphabetically earliest lineup of R, P and S players that lets a single-elimination tournament finish without any tie match. | Medium7 | BacktrackingDivide and conquer+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Mahjong Waiting TilesGiven a 13 tile mahjong hand numbered 1 to 9, list every tile still available that completes the hand into one head plus four bodies, or into seven distinct heads. | Medium7 | BacktrackingRecursion+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Tiling the Shower Floor (Small)Cover a 2^K by 2^K grid with L-shaped trominoes leaving one drain cell open, choosing the lexicographically smallest numbering. | Medium7 | Divide and conquerRecursion+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Grasshopper RouteGiven a tree and two vertices s and t, construct the specific valid Grasshopper route defined by a recursive rule on the path components. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Folding SheetsGiven a number X or a position P, determine its counterpart in the sequence produced by folding an N x N sheet in half alternating bottom-over-top and right-over-left until 1 x 1, then reading the resulting column bottom to top. N is 2^K, K up to 31, and there are up to 10000 queries. | Medium7 | RecursionDivide and conquer+2 | No attempts yet | 1s | 32 MB | Judgeable |
| Quick sort cnt++Count the comparisons made by a quicksort that splits each subarray around its middle-index pivot and recurses only on strictly smaller and larger elements. | Medium7 | Divide and conquerRecursion+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Folding a RibbonGiven the layer index and part index of a marked spot on a ribbon folded n times, output the unique sequence of left and right folds. | Medium7 | RecursionDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| That's One Hanoi-ed TeacherGiven a legal Tower of Hanoi layout, decide whether it lies on the optimal solution path and if so output the remaining moves to the goal. | Medium7 | RecursionDivide and conquer+1 | No attempts yet | 2s | 512 MB | Judgeable |
| ASCII Art TreesFor each prefix-encoded binary tree, draw its ASCII layout using the given slash, bar, and spacing rules and print the resulting character grid. | Medium7 | TreeRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Vera and SortingCount permutations of size N for which a recursive quicksort-like routine performs exactly K comparison steps, modulo 1e9+7. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Equals are EqualsParse multivariate polynomial expressions with integer coefficients and decide whether each student answer is equivalent to the reference expression. | Medium7 | StringImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Balanced TreesCount perfectly balanced trees of weight N, where a tree splits into k identical subtrees each of the largest weight summing within the parent's weight. | Medium7 | TreeNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Line-upCount for each soldier, looking left or right, how many nearer soldiers are visible past blocking heights. | Medium7 | StackDivide and conquer+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Nice NumberGiven n up to 10^18, find the smallest integer greater than n with no two equal consecutive digits. | Medium7 | GreedyRecursion+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Hawawa College Student-chan Goes to Hawaii~Count the ways to start at island 1 and visit all n islands exactly once using steps +1, +2, or -1 to new islands, modulo 1,000,000,009. | Medium7 | Dynamic programmingMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Arithmetic Without ParenthesesGiven an arithmetic expression without parentheses where all four operators have equal precedence, find the minimum and maximum results over all evaluation orders, using custom integer division rules. | Medium7 | Dynamic programmingRecursion+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Hano-Sam TowerGiven a Hanoi variant with one of three move rules, output the peg holding each disk after K seconds of the optimal solution. | Medium7 | RecursionMath+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Cow EvolutionGiven N distinct feature sets for cow sub-populations, decide whether they can arise from an evolutionary tree in which every feature first appears on exactly one edge. | Medium7 | TreeRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |