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
TitleLevelTopicsSolvedTime limitMemory limitJudge
The Little BirdA bird jumps from tree 1 to tree n in flights of at most k and minimizes landings on trees at least as tall as the takeoff tree.Medium7Dynamic programmingStack+1No attempts yet2s256 MBJudgeable
CarpetFind the area of the largest subrectangle of a flawed carpet grid that holds at most one flaw.Medium7StackPrefix sum+1No attempts yet4s256 MBJudgeable
XH CompanyFor each query day D, report the length of the shortest suffix ending on day D-1 with the largest average.Medium7StackPrefix sum+1No attempts yet2s256 MBJudgeable
Stack Copying GameMaintain up to 300,000 persistent stack versions built by push, pop, or copy, and answer popped values and common-element counts for pairs of versions.Medium7TreeStackNo attempts yet1s64 MBJudgeable
NEOFind the largest submatrix with at least two rows and columns in which every submatrix meets the corner-sum inequality.Medium7MatrixStack+1No attempts yet1s256 MBJudgeable
CensoringRepeatedly delete the leftmost occurrence of any of N forbidden words from string S until none remains and print the result.Medium7String matchingStack+1No attempts yet1s256 MBJudgeable
SolitaireGiven the starting deck order, compute the fewest redeals needed to move every card to the goal pile using the helper as ordered storage.Medium7SimulationGreedy+1No attempts yet2s256 MBJudgeable
SunlightCompute sunlight hours for each rooftop from the sky angles blocked by taller buildings on both sides.Medium7StackGeometry+1No attempts yet4s256 MBJudgeable
Luxury burrowFind the rectangle of area at least K whose minimum cell price is largest, breaking ties by larger area.Medium7Binary searchStack+1No attempts yet2s64 MBJudgeable
K blocksSplit the array into exactly K contiguous blocks so the sum of each block's maximum is as small as possible.Medium7Dynamic programmingStack+1No attempts yet1s256 MBJudgeable
Walking in JOI KingdomN walkers start at given points and move east or west at speed 1, stopping when they meet anyone, and the task asks the positions of Q of them at time T.Medium7StackSimulation+1No attempts yet2s512 MBJudgeable
Ticket Swapping (Small)Given rider groups traveling between stations on one line, compute the largest fare loss from riders swapping entry cards, modulo 1000002013.Medium7GreedyStack+1No attempts yet5s512 MBJudgeable
Letter Stamper (Small)Print a given string of A, B and C with push, pop and print on a letter stack using the fewest operations.Medium7Dynamic programmingStackNo attempts yet5s512 MBJudgeable
Letter Stamper (Large)Find the fewest stack pushes, pops, and prints needed to print each target string of A, B, and C grades in order.Medium7Dynamic programmingStackNo attempts yet15s512 MBJudgeable
MarblesPairs of matching colors sit on a line; join each pair with a non-crossing path above y=0 and minimize the total height.Medium7StackGreedyNo attempts yet5s512 MBJudgeable
Jolly Jelly JiffyCount and lexicographically minimize total orders consistent with the final box state of an insertion-sort-like stacking process and one extra value.Medium7StackTopological sort+2No attempts yet2s256 MBJudgeable
Bracket MatchGiven a lowercase string S, find the lexicographically smallest matching bracket sequence, or print -1 if none exists.Medium7StackGreedy+1No attempts yet2s512 MBJudgeable
Interleaved Output: Part 1Given a string over I, O, i, o, find the maximum number of times the event IO could have been printed.Medium7GreedyStack+1No attempts yet20s1024 MBJudgeable
Modern Art 2Given a 1D painting, decide whether it can be built by layering one interval per color, and if so find the minimum number of Moonet's disjoint-interval rounds.Medium7StackGreedy+2No attempts yet2s512 MBJudgeable
Stack ConstructionFor each message, compute the minimum number of stack push, pop, and print operations needed to print it and leave the stack empty.Medium7Dynamic programmingString+1No attempts yet2s512 MBJudgeable
Cutting the curveGiven a simple orthogonal polygon with edges crossing the x axis, count peaks minimal under containment and peaks maximal under containment.Medium7StackGeometry+2No attempts yet2s512 MBJudgeable
Mixing CoinsGroups of equal coins are merged three at a time when three consecutive same-material coins appear, and the survivor count is requested.Medium7SimulationStack+1No attempts yet5s512 MBJudgeable
Global WarmingFind the longest subarray whose minimum value and maximum value each occur exactly once, and report its length and earliest start.Medium7Two pointersStack+1No attempts yet2s512 MBJudgeable
Line-upCount for each soldier, looking left or right, how many nearer soldiers are visible past blocking heights.Medium7StackDivide and conquer+1No attempts yet2s512 MBJudgeable
DefileMaintain minion healths under insert and delete, and after each update report how many would die in repeated 1-damage waves.Medium7MathNumber theory+2No attempts yet3s1024 MBJudgeable
StrahFor an N by M grid of '.' and '#', find the sum over all '.' cells of the number of all-'.' subrectangles containing it.Medium7StackCombinatorics+2No attempts yet1s256 MBJudgeable
DriveGiven D, tank capacity C, consumption E, and stations with distances and prices, find the cheapest way to reach distance D starting with a full tank, or report -1.Medium7GreedyStack+2No attempts yet1s256 MBJudgeable
Mount MarathonGiven up to 52 piles of one card each, repeatedly move a single-card pile onto the pile just to its right if its value is at least the right pile's top card. Find the minimum final number of piles.Medium7ArrayStack+2No attempts yet2s512 MBJudgeable
Buying Cards 3Sum, over all contiguous subarrays, of (maximum minus minimum) in the subarray.Medium7StackArray+2No attempts yet2s512 MBJudgeable
Disrupting DefenseFind a sequence of n/2 attacks removing adjacent differently valued soldiers from a circular ring until all are gone, or report impossible.Medium7GreedyStack+2No attempts yet1s512 MBJudgeable
Bad Hair Day and Expected ValueGiven N cows with heights, count the expected number of visible pairs over all N! orderings, modulo 1e9+7.Medium7CombinatoricsMath+2No attempts yet2s512 MBJudgeable
Parentheses EditorAfter each push of '(' or ')' or one backspace, print the number of balanced substrings in the current text.Medium7StackDynamic programming+2No attempts yet2s512 MBJudgeable
PilotFor each of Q altitude limits, count subarrays of heights whose maximum is at most that limit.Medium7StackSorting+2No attempts yet1s512 MBJudgeable
Visible Mountain RangeCompute the total visible area of overlapping isosceles triangular mountains that share a common baseline, given up to 100,000 triangles.Hard8GeometrySorting+1No attempts yet2s128 MBJudgeable
Programming Language LSimulate execution of a custom esoteric language with nested loops and conditional jumps to find the maximum number of printed line executions, capping at infinity beyond 1e9.Hard8SimulationDynamic programming+1No attempts yet2s128 MBJudgeable
Stack Truck DriverCount length-bounded walks from city 1 to city N in a graph where edges push or pop letters on a stack, with pops requiring a matching top element.Hard8Dynamic programmingStack+1No attempts yet3s128 MBJudgeable
Hongjun and the FenceGiven fence plank heights, find the minimum leftover area after optimally applying width-X roller strokes (each painting up to the min height of X consecutive planks) and the minimum number of strokes achieving that area.Hard8StackDivide and conquer+1No attempts yet1s256 MBJudgeable
Periodic TableCount ways to place K non-attacking pieces on a histogram-shaped grid where two cells in the same row are close only if all columns between them reach that row, modulo 1e9+7.Hard8Dynamic programmingStack+1No attempts yet1s128 MBJudgeable
Balanced Bracket SegmentMaintain a dynamic string under prefix/suffix bracket insertions and after each insertion report the shortest valid contiguous bracket substring covering the new character.Hard8StackString matching+1No attempts yet1s128 MBJudgeable
Stack MachineFor each pair of intersections, find the shortest route whose sequence of board and leave events forms a balanced stack (empty at start and end).Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
VectorsParse and evaluate a small language over scalars and 3D vectors, including mixed operators and bracket styles that can close several open groups at once.Hard8ImplementationRecursion+2No attempts yet1s128 MBJudgeable
EmpodiaGiven a permutation biosequence, find every minimal framed interval: a segment whose endpoints are its min and max and that contains no shorter framed interval.Hard8StackArray+2No attempts yet1s128 MBJudgeable
The Crayfish ScrivenerProcess type and undo commands, including nested undos, and answer queries for the character at a given position.Hard8StackTree+2No attempts yet2s512 MBJudgeable
Artificial LakeWater fills a terrain of N distinct-height platforms at 1 unit per minute; report when each platform first has 1 unit of water above it.Hard8StackSimulation+2No attempts yet1s128 MBJudgeable
Fixing DisksGiven a master stack and your own stack of N labeled disks, use three limited reorder moves on the top K disks to remove disks cheaply; minimize total cost under a removal-order constraint.Hard8Dynamic programmingStack+2No attempts yet2s512 MBJudgeable
ChandelierGiven a valid stack program that builds a chandelier, find the minimum stack capacity needed to build an identical chandelier, where ring children may be rotated cyclically.Hard8StackGreedyNo attempts yet2s128 MBJudgeable
Identity CheckerEach test case gives a reverse Polish expression in x with sin, cos, and tan; decide whether it equals zero wherever defined.Hard8MathString+2No attempts yet1s128 MBJudgeable
Tetris AttackA stack holds each of n symbols twice; adjacent equal pairs vanish on contact, and one move swaps neighboring elements. Find the minimum swaps to empty the stack.Hard8GreedyStack+2No attempts yet1s128 MBJudgeable
Untamed TreeThe task is to output for each leaf label the compressed subtree of its leaves and branching ancestors in preorder.Hard8TreeSorting+2No attempts yet1s128 MBJudgeable
Heavy BlocksTopple n distinct-weight blocks with the fewest pushes when each push fells lighter neighbors in one direction until a heavier block or gap.Hard8Dynamic programmingStack+2No attempts yet1s128 MBJudgeable
String TransformationFind the fewest adjacent swaps turning one balanced a/b string into another with every intermediate string balanced, or output -1 if impossible.Hard8TreeStack+1No attempts yet1s256 MBJudgeable
Mountainous landscapeFor each segment of a left-to-right polygonal chain, find the nearest later segment with a point strictly above the ray extending the segment.Hard8GeometryStackNo attempts yet10s256 MBJudgeable
Norma's array price sumSum min times max times length over all contiguous subarrays and print the result modulo 1000000000.Hard8Divide and conquerStackNo attempts yet3s64 MBJudgeable
Stack MazeYou move only right or down through the grid, pick up lettered jewels, and drop them into matching holes in last-in-first-out order for the most matches.Hard8Dynamic programmingStack+1No attempts yet8s256 MBJudgeable
EditorGiven up to 500000 edits and leveled undos, print the editor state after each operation.Hard8StackSegment tree+1No attempts yet3s512 MBJudgeable
Greenhouse GrowthGiven n sunflower heights and an m-day schedule of left or right lamps, compute every height after daily growth toward the taller neighbor.Hard8Segment treeStack+2No attempts yet6s512 MBJudgeable
Connecting the wiresPlace each equal-number pair above or below a row so same-side joining arcs never cross, and print the lexicographically smallest side string.Hard8GraphDFS+2No attempts yet1s64 MBJudgeable
Memory CellBuild the expression tree, find the largest pair of disjoint identical subtrees, and print the loser's postfix in lexicographic order.Hard8StackTree+2No attempts yet1s512 MBJudgeable
What NextGiven a prefix of an NZPC Speak program cut at an arbitrary point, list the symbols that can legally come next, respecting declarations, masking, and partial names.Hard8ImplementationSimulation+2No attempts yet2s512 MBJudgeable
Broadcast Tower OffersFor each offered tower height, find the best position along a row of buildings and report how many buildings to its west can receive its westward signal.Hard8StackSorting+2No attempts yet2s512 MBJudgeable
Visual Python++Match n top-left corners to n bottom-right corners so the rectangles form properly nested or disjoint blocks, or report a syntax error.Hard8SortingStack+2No attempts yet5s512 MBJudgeable
Buffalo BarricadesFor each settler arriving in order, count the buffalos inside the region bounded by rivers and fences whose upper right corner is the settler's post.Hard8SortingPrefix sum+2No attempts yet5s512 MBJudgeable
Map of the Ninja HouseReconstruct the graph of a ninja house from the counter and door records produced by a fixed DFS exploration, handling back edges, skips, and multi-edges.Hard8GraphDFS+2No attempts yet2s512 MBJudgeable
Rangers in the BusGiven each passenger's entry order and taken seat, determine which passengers could have been each of five rangers whose seat choice follows a fixed rule or a free choice.Hard8SimulationGreedy+2No attempts yet2s512 MBJudgeable
PanokseonSplit a sequence of n positive weights into groups with sum at most W to minimize the maximum of (W minus group sum) squared.Hard8GreedyBinary search+2No attempts yet1s512 MBJudgeable
ParenthesesClassify a C arithmetic expression as error, proper, or improper depending on validity and the minimality of its parentheses.Hard8StackRecursion+2No attempts yet1s512 MBJudgeable
Circular DNAGiven a circular sequence of start and end markers for many gene types, choose a cut position that maximizes how many gene types have their markers properly nested in the resulting linear subsequence.Hard8ArrayStack+2No attempts yet3s512 MBJudgeable
Pairing SocksGiven a sequence of 2n socks, find the minimum number of moves to pair all socks using two stacks with three allowed operations, or report impossible.Hard8StackGreedy+2No attempts yet1s512 MBJudgeable
Hero's HistogramGiven a histogram of n columns, for every prefix of the first j columns report the largest axis-aligned rectangle that fits inside that prefix.Hard8StackPrefix sum+2No attempts yet1s512 MBJudgeable
Rock-Scissors-Paper ExpressionCount the assignments of R, S, P to the ? symbols in a fixed arithmetic expression, under rock-scissors-paper defined operators, so that evaluation gives A.Hard8Dynamic programmingDivide and conquer+2No attempts yet2s512 MBJudgeable
Balanced SequenceReorder n bracket strings to maximize the length of the longest balanced subsequence of their concatenation.Hard8GreedySorting+2No attempts yet1s256 MBJudgeable
Fancy FenceCount axis-aligned integer rectangles lying on a histogram of N sections with heights h_i and widths w_i, modulo 1e9+7.Hard8StackDivide and conquer+2No attempts yet1s32 MBJudgeable
Counting in the OrderEach soldier looks left or right and sees past people no taller than the target; count how many soldiers each one sees.Hard8StackArray+2No attempts yet1s512 MBJudgeable
Equal MaximumsCount quadruples of indices i<=j<k<=l where the maximum of a[i..j] equals the maximum of a[k..l], modulo 1e9+7, for n up to 100000.Hard8ArrayStack+2No attempts yet1s512 MBJudgeable
Heavy BurgerMaintain a string of parentheses under range flips, and for each query on a substring report the minimum number of characters to insert so the substring becomes a balanced parenthesis sequence.Hard8Segment treeString matching+2No attempts yet3s1024 MBJudgeable
Standard ProblemGiven a 0/1 grid, answer up to a million offline queries for the largest all-zero rectangle confined to a specified row range.Hard9Segment treeDivide and conquer+2No attempts yet3s128 MBJudgeable
Brainf**k InterpreterDecide whether a given Brainfuck program halts on its input and, if it loops, report the matching bracket pair that encloses the infinite loop.Hard9SimulationImplementation+2No attempts yet7s128 MBJudgeable
PurifyRepeatedly delete forbidden substrings from P, always choosing the earliest-ending occurrence and removing the shortest such forbidden word, then print what remains.Hard9StringTrie+2No attempts yet1s64 MBJudgeable
Minimum bracketsGiven an arithmetic template with holes, delete as many brackets as possible while keeping the same value for every valid assignment of real numbers to the holes.Hard9StringImplementation+2No attempts yet1s128 MBJudgeable
Aquarium 3Place K holes on distinct horizontal floor segments to maximize the area of water that drains out.Hard9TreeGreedy+2No attempts yet1s128 MBJudgeable
Believer in I 2Over every ordering of A push, B add, and C multiply cards on an infinite stack of I, report the total of each of the top K stack values modulo 1,000,000,007.Hard9CombinatoricsDynamic programming+2No attempts yet3s256 MBJudgeable
Magical SubarraysEach query asks for the longest subarray inside [L,R] with every element between its first and last values.Hard9Divide and conquerSegment tree+1No attempts yet4s128 MBJudgeable
Bracket SubstringsCount how many distinct balanced bracket sequences appear as non-empty substrings of a given bracket string of length up to 500,000.Hard9StringHash map+2No attempts yet2s512 MBJudgeable
Intrinsic IntervalFor each query range in a permutation, find the smallest subarray containing it whose values form a set of consecutive integers.Hard9Segment treeStack+1No attempts yet3s512 MBJudgeable
GameChoose the order in which balls are manually removed so chain reactions of merging equal neighbors delete as many other balls as possible; output that maximum count.Hard9Dynamic programmingStack+2No attempts yet2s512 MBJudgeable
Gahui's Sequence Mod Play (Large)Maintain a stack under push and pop, and after each type 3 query report the shortest suffix whose remainders mod m cover every residue from 0 to m-1, printing -1 if impossible.Hard9StackTwo pointers+2No attempts yet1s256 MBJudgeable
GnalcatsDecide whether two genes, each a sequence of seven possible base transformations on proteins, produce identical results or both fail on every sufficiently long input protein.Hard9StringStack+2No attempts yet0.3s512 MBJudgeable
Holy cow, Vim! (Hard)Construct a stack-program whose lines, read normally, reversed, and lexicographically sorted, compute x, x squared, and negative x respectively.Hard9ImplementationStack+2No attempts yet1s512 MBJudgeable