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 results288 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Left and RightFind the lexicographically smallest permutation of 1..n whose consecutive moves match the given L/R string. | Medium5 | GreedyStack+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Gahui's Remainder Sequence Game (Small)Maintain a sequence under push and pop from the back, and for each type-3 query report the shortest suffix whose values cover every residue 0 to mod-1, or -1 if impossible. | Medium5 | StackArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Next Greater ElementFor each element of a sequence, output the nearest greater value to its right, or -1 if none exists. | Medium5 | StackArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Frequency-Greater Next ElementFor each position, find the nearest value to its right whose total frequency in the array exceeds the frequency of the current element, or -1 if none exists. | Medium5 | StackHash map+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Bracket SequenceEvaluate a bracket sequence where nesting alternates between addition and multiplication, printing the result modulo 10^9+7. | Medium5 | StackImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Configuration FileParse a brace-delimited configuration file where assignments to variables are scoped to their block, and report the value assigned by each variable-to-variable assignment. | Medium5 | StackHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| A Simple Sequence of DigitsGiven n and k, build the digit string formed by concatenating the first n primes, then delete exactly k digits to leave the largest possible number. | Medium5 | GreedyStack+2 | No attempts yet | 1s | 512 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 |
| UndoSimulate a text editor whose undo command reverts every command from the previous t seconds, where undos themselves can be undone, and find the final text. | Medium6 | StackSimulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Deleting DigitsGiven a digit string and a required count of each digit to delete, remove exactly that many occurrences of each digit to leave the numerically largest possible string. | Medium6 | GreedyStack+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Largest Zero SubmatrixGiven a binary matrix, find the maximum area rectangle of consecutive rows and columns that contains only zeros. | Medium6 | StackDynamic programming+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 |
| HistogramGiven bar heights of a histogram, find the maximum-area rectangle that fits inside it using a stack-based approach. | Medium6 | StackArray+1 | No attempts yet | 0.7s | 128 MB | Judgeable |
| Card BundlesGiven a shuffled permutation of 1 to N, output N-1 adjacent merges that combine bundles into a single bundle where each intermediate bundle holds consecutive integers. | Medium6 | StackGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Easy SkylineGiven the sequence of skyline breakpoints, find the minimum number of axis-aligned rectangular buildings that could produce that exact skyline. | Medium6 | StackGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing a Subarray 2Find a contiguous subarray maximizing (sum of elements) times (minimum element), and output that maximum score with the interval bounds. | Medium6 | StackPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing a SubarrayGiven an array, find the contiguous subarray that maximizes the product of its sum and its minimum element. | Medium6 | StackPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Apple TreeGiven a DFS 0/1 traversal string of a tree and two marked positions, find the smallest subtree (by matching visit/return indices) that contains both marked vertices. | Medium6 | TreeStack+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Sum of Sequence ValuesGiven an array, compute the sum over all contiguous subarrays of (max - min) efficiently for up to 300,000 elements. | Medium6 | StackArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Oasis ReunionGiven a line of heights, count pairs who can mutually see each other using a monotonic stack while handling equal-height ties correctly. | Medium6 | StackArray | No attempts yet | 1s | 256 MB | Judgeable |
| Doubly Linked ListGiven a sequence of doubly linked list move operations, output the minimum number of operations that reverse them and restore the original order. | Medium6 | Linked listStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| String CensorshipRepeatedly delete the first then last occurrence of a pattern string from a text until it's absent, and output the final text. | Medium6 | String matchingStack+1 | No attempts yet | 1.5s | 128 MB | Judgeable |
| BracketsCount, modulo 1e9+9, the ways to turn some matching '(' '(' pairs back into '[' ']' so the bracket string becomes valid with at least one square pair. | Medium6 | Dynamic programmingStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Magic ParenthesisGiven a bracket string with wildcard characters ']' that each consume one or more open parentheses, determine feasibility and output the lexicographically largest assignment of counts for each wildcard. | Medium6 | GreedyStack+1 | No attempts yet | 5s | 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 |
| City GameGiven several grid maps of free and reserved cells, find the largest all-free rectangle in each grid and print its area times three. | Medium6 | StackDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Stupendous ManGiven a sequence where each label 1..N appears twice, decide whether the labels can trace one closed loop of a self-crossing path or not. | Medium6 | StackImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| HTML EditorGiven a valid HTML string and a range, output that substring wrapped with the tags needed to preserve its formatting. | Medium6 | StringStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ChemistryParse a chemical formula with nested parentheses and multipliers, then output each element's total atom count in lexicographic order. | Medium6 | StackString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Removing ParenthesesGiven an expression of single-letter variables with addition and multiplication, remove every pair of parentheses that can go without changing the value, and print the result. | Medium6 | StackString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| XML ValidatorDecide for each input line whether it is valid XML: matching open and close tags, allowed plain text, and proper escape sequences. | Medium6 | StringStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ResistorsParse a nested expression of series and parallel resistor connections and output the exact resistance as a reduced fraction. | Medium6 | StringStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Binary Search TreeGiven the preorder traversal of a binary search tree, print its postorder traversal. | Medium6 | TreeDivide and conquer+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Time TravelProcess add, pop, and rewind-to-earlier-query operations on a recorded list, printing the last element after each query. | Medium6 | StackTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Leaking DikeGiven building heights in a row, water pours over a dike on the left at 1 square meter per minute; find how long until a given building's roof sits 1 meter under water. | Medium6 | ArraySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Instant ComplexityParse a small nested-loop program, compute its running time as a polynomial in n, and print the collected polynomial from highest degree down. | Medium6 | ImplementationStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A Well-Formed ProblemParse a series of XML documents and decide whether each one satisfies six well-formedness rules, reporting the verdict per document. | Medium6 | StringStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Largest Rectangle in a HistogramGiven a histogram of unit-width bars with varying heights, find the area of the largest rectangle that fits inside it, processing several test cases until a 0 terminates input. | Medium6 | StackArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Bug CatcherFor each code line, repeatedly remove the first occurrence of a given bug string until no occurrence remains, then print the result. | Medium6 | StackString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ReorganizationGiven each employee's rank in ID order, decide whether a binary hierarchy exists where every non-root has a supervisor with a smaller ID and a better rank. | Medium6 | GreedyTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Remove Redundant ParenthesesGiven valid arithmetic expressions over single uppercase variables with + and -, remove every matching parenthesis pair whose removal keeps the expression's value unchanged. | Medium6 | StackString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BracketsGiven a bracket string, find the maximum length of a regular bracket sequence obtainable as a subsequence. | Medium6 | Dynamic programmingIntervals+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PetrolGiven fuel prices at ordered stations and distances between them, find the minimum fuel cost to travel from A to B with a fixed tank capacity. | Medium6 | GreedyStack | No attempts yet | 1s | 128 MB | Judgeable |
| Bracket ExpressionsThe task is to count substrings of a bracket string that are correct bracket sequences. | Medium6 | StackDynamic programming | No attempts yet | 1s | 512 MB | Judgeable |
| Turtle GraphicsSimulate the direction-digit moves, erasing each loop or overlap as it forms, then report the remaining segment count and total length. | Medium6 | SimulationStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| KTXDecide whether a departure permutation can be reordered into ascending grade order using a direct main line and two LIFO bypass tracks. | Medium6 | StackBacktracking+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cartesian TreeBuild the Cartesian tree whose inorder follows one key and heap order follows the other, printing parents and children, or NO when impossible. | Medium6 | StackSorting+1 | No attempts yet | 2s | 64 MB | Judgeable |
| Bob's House SiteCount the subrectangles of an N by M elevation grid whose covered cells all have equal height. | Medium6 | StackMatrix+1 | No attempts yet | 1s | 64 MB | Judgeable |
| MarkleftThe program converts each input line with nested markup rules for uppercase, quote escaping, decimal to hex, reversal, and verbatim copying. | Medium6 | StackString+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Red RectanglesCount the subrectangles of an N by M red and blue grid that contain only red cells. | Medium6 | StackDynamic programming+1 | No attempts yet | 1s | 512 MB | Judgeable |
| InterpreterRun small integer programs with arithmetic, comparisons, if/else branches, while loops, and print statements. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Slon's ExpressionParse a linear expression in x and find the smallest non-negative x with the expression congruent to P modulo M. | Medium6 | Number theoryMath+1 | No attempts yet | 1s | 64 MB | Judgeable |
| Largest Rectangle of OnesFind the area of the largest all-ones subrectangle in each binary matrix given until 0 0. | Medium6 | StackMatrix+1 | No attempts yet | 3s | 512 MB | Judgeable |
| A Scary Part-Time JobGiven daily wages, choose a contiguous range maximizing (length of range) times (minimum wage in that range). | Medium6 | StackGreedy | No attempts yet | 1s | 512 MB | Judgeable |
| MarathonGroups at distinct coordinates move right at speed 100/size and merge on contact; simulate until stable and report final sizes left to right. | Medium6 | StackSimulation+2 | No attempts yet | 0.2s | 256 MB | Judgeable |
| Cutting the puzzleGiven the heights of a histogram, find the area of the largest axis-aligned rectangle contained in it. | Medium6 | StackArray | No attempts yet | 2s | 256 MB | Judgeable |
| Flow Graph ComplexityParse a comma-separated flow-graph string of S, B(...), L(...) nodes, count forward and backward edges and nodes, and print |EF| + W*|EB| - |V| + 2 or -1 if malformed. | Medium6 | StringImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Tree Country Tour GuideGiven the move sequence of a shortest round trip that visits every node of an unknown rooted tree, reconstruct each city's parent. | Medium6 | StackTree+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Building a SpaceshipPartition the ordered parts into contiguous groups, paying for each group the product of its maximum weight and maximum energy; minimize the total cost. | Medium6 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hyunwook Is the Parenthesis King!!Given a string of parentheses, find the length of the longest contiguous substring that forms a correct parenthesis string. | Medium6 | StackString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ChainFor each position, repeatedly jump to the first strictly greater element on its right and report the length of that chain. | Medium6 | StackDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Generalized German QuotationGiven a string of << and >> marks, decide whether it forms nested conventional or reversed German quotes and rewrite every mark as an opening [ or closing ], or report that none exists. | Medium6 | StackImplementation+1 | No attempts yet | 3s | 512 MB | Judgeable |
| New GameSimulate a board game where K stacked pieces move in numbered order and reverse, redirect, or merge based on cell color, and report the turn a stack reaches 4 pieces or -1. | Medium6 | SimulationImplementation+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| One of EachGiven a sequence containing every value 1 to k at least once, find the lexicographically smallest subsequence that includes each value exactly once. | Medium6 | GreedyStack+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Unique CalculatorEvaluate an arithmetic expression by repeatedly reducing the operator at either end with the highest precedence and largest result, following the stated tie-break rules. | Medium6 | ImplementationSimulation+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Modified HanoiSimulate a modified Tower of Hanoi with a no-repeat-move rule and a fixed move priority order, counting moves until all disks gather on one pole. | Medium7 | SimulationRecursion+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tilted Square DisplayPlace 45-degree tilted squares along the x-axis one by one without overlap, then find which squares are visible when viewed from directly above. | Medium7 | GeometrySimulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Warehouse PolygonGiven pillar positions and heights, compute the minimum area of a roof polygon that covers all pillars while forming a shape without concave water-collecting dips, using a monotonic stack over the skyline. | Medium7 | StackGeometry+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Connecting Black and White PointsPair n black and n white points on a line with non-crossing arcs of chosen height, minimizing total arc length, and output the pairing. | Medium7 | GreedyStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Attractive FenceArrange purchased plank heights to match a given up/down pattern while maximizing the sum of absolute differences between adjacent planks. | Medium7 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Alien Guitar PerformanceSimulate finger presses and releases on a 6-string guitar to play a melody in order with minimum total finger movements, keeping only pressed frets that could still be the highest useful one. | Medium7 | StackGreedy+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Clearing the BeadsFind the minimum number of beads to insert between colored beads so every bead can eventually be cleared by removing runs of length at least K. | Medium7 | Dynamic programmingStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| HousewarmingGiven a grid with blocked cells, find the maximum rectangle of empty cells and output twice its width plus height (the perimeter). | Medium7 | Dynamic programmingStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| FenceGiven overlapping rectangular planks forming a skyline, select the minimum subset of planks that reproduces the exact same skyline. | Medium7 | SortingStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Interval GroupsGiven a permutation of 1..N arranged on a board, decide if adjacent groups can be merged repeatedly into intervals until one group remains, and output the merge sequence if possible. | Medium7 | GreedyStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| After the Contest: BalloonsSimulate balloons inflated left to right on a line, each stopping at its max radius or when it touches an earlier balloon, and output the final radii efficiently. | Medium7 | Binary searchGeometry+1 | No attempts yet | 1s | 128 MB | Judgeable |
| SubmarinesMaintain a sequence under adjacent swaps and repeatedly report the maximum in-degree in the 'nearest deeper element behind' functional graph. | Medium7 | StackSegment tree+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Time Limit ExceededParse nested loops with arguments x, y, or integers, compute the Big-O polynomial of basic operations, and print terms sorted by degree. | Medium7 | StackImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Airplane ParkingGiven N time intervals (arrival, departure), find the largest subset that can be scheduled in a stack, so planes leave in last-in first-out order. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Two-Stacks SolitaireGiven a stock pile dealt in order, decide whether the top card can be moved to intermediate pile 1 or 2 or popped to the foundation so all cards end non-decreasing. | Medium7 | Dynamic programmingStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fuel EconomyFind the cheapest way to buy fuel along a route with a tank of capacity G, visiting stations with given prices, or report that the trip is impossible. | Medium7 | GreedyStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BookshelfPartition the books, in order, into shelves of total width at most L to minimize the sum of each shelf's max height. | Medium7 | Dynamic programmingSegment tree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Rooftop Garden BenchmarkingCount, over every building, how many strictly shorter buildings stand to its right before a building at least as tall blocks the view. | Medium7 | StackArray+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 |
| Pyramid Message SchemeGiven a chronological list of message recipients from a sequential tree traversal, reconstruct the tree and compute the time saved by a parallel traversal. | Medium7 | TreeStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CaveGiven floor and ceiling heights along a cave, find the maximum total area of settled fuel ponds that stay below the ceiling. | Medium7 | StackGreedy+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Connectivity of a Permutation GraphRead a permutation of up to one million elements and report the connected components of the graph joining i and j whenever i < j and a_i > a_j. | Medium7 | StackGreedy+2 | No attempts yet | 2s | 256 MB | Judgeable |
| ParcelGiven an n by n grid of 0 (arable) and 1 (waste), find the largest all-zero rectangle and print its area. n can be up to 2000. | Medium7 | StackDynamic programming+2 | No attempts yet | 3s | 512 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 |
| PosteringGiven adjacent buildings with widths and heights, find the minimum number of non-overlapping rectangles needed to cover the whole skyline shape. | Medium7 | StackGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Railway SidingAssign each arriving car to one of two stack-like sidetracks so all cars leave in increasing order. | Medium7 | StackGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Farmer's FieldCount placements of a c-by-d or d-by-c rectangle fully inside a field whose every row is one contiguous segment. | Medium7 | Sliding windowStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| VisibilityGiven a sequence, count pairs whose relationship is in the transitive closure of the direct-visibility relation defined by strictly smaller intervening elements. | Medium7 | StackGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AptekaPay each swapped person by distance times their fee and reach the front with the smallest total cost. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Chemicals MonitoringVictor admits the maximum-priority subset of streams that one shared output unit can report in stack order. | Medium7 | Dynamic programmingStack+2 | No attempts yet | 4s | 256 MB | Judgeable |
| Go up the UltrasThe program reads an altitude profile of up to 100000 points and prints the indices of every peak with prominence of at least 150000 centimeters. | Medium7 | StackSegment tree | No attempts yet | 1s | 128 MB | Judgeable |
| Sequence MergingRepeatedly replace an adjacent pair with its larger value and pay that value, ordering the merges to leave the smallest total cost. | Medium7 | Divide and conquerStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Circle RegionsCount how many regions N circles with centers on the x-axis and no crossings cut the plane into. | Medium7 | StackSorting+2 | No attempts yet | 1s | 256 MB | Judgeable |
| CATSGiven X, L and N, simulate the buggy two-stack counter program with global bit flips and output the number it prints. | Medium7 | SimulationStack+2 | No attempts yet | 2s | 512 MB | Judgeable |