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 results388 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
MatryoshkaFor each query (A, B), take the dolls with R >= A and H <= B and find the minimum number of chains needed to store them all nested, i.e. the size of the largest antichain under the containment partial order.Hard8SortingDynamic programming+2No attempts yet2s512 MBJudgeable
ScarecrowsCount pairs of scarecrows that can be the SW and NE corners of an axis-aligned rectangle whose interior contains no other scarecrow.Hard8SortingDivide and conquer+1No attempts yet4s512 MBJudgeable
3D Points and QueriesCount points inside axis-aligned 3D boxes, where each query's box coordinates are decoded by XOR with the running sum of previous answers.Hard8Segment treeSorting+2No attempts yet7s1024 MBJudgeable
Computer CacheMaintain a mutable byte array over m pieces, support range increments modulo 256 on a piece, cache loads of whole pieces into fixed cache positions, and point queries of cache bytes.Hard8Segment treeArray+2No attempts yet5s512 MBJudgeable
Cut Inequality DownFor many range queries [B,E] and starting wealth X, simulate monthly income with wealth clamped into [L,U] after each month and report the final wealth.Hard8Segment treeImplementation+2No attempts yet0.7s512 MBJudgeable
Shortest Paths and QueriesGiven a grid with up to 5 rows and 100,000 columns, answer queries for the minimum-weight monotone-free path between two cells.Hard8Dynamic programmingMatrix+2No attempts yet5s512 MBJudgeable
Black DebtContestants get point increases over time; after each update, report the total count of (yellow, black) pairs where the black contestant has strictly more points.Hard8Segment treeBinary search+2No attempts yet1s512 MBJudgeable
Movie-goerChoose a contiguous block of days maximizing the sum of weights of movies that appear exactly once in the block.Hard8ArrayTwo pointers+2No attempts yet5s512 MBJudgeable
Bad DoctorEach doctor prescribes a set of medicines over a day interval; ignoring one doctor, compute the total cost of distinct medicines needed per day summed over all days.Hard8Segment treeSorting+2No attempts yet3s512 MBJudgeable
Glad You CameApply m range-max updates (a_j = max(a_j, v_i)) to a zero array, where each l, r, v comes from a fixed 32-bit RNG, then output the XOR of i*a_i.Hard8Segment treeImplementation+2No attempts yet4s512 MBJudgeable
Snowy SmileGiven up to 2000 weighted points, find an axis-aligned rectangle maximizing the sum of weights of points inside or on its border, allowing an empty rectangle for zero.Hard8Dynamic programmingSorting+2No attempts yet3s512 MBJudgeable
AlakazamGiven an array and range shuffle operations that permute a segment uniformly at random, answer point queries for the expected value at a position.Hard8MathProbability+2No attempts yet2s512 MBJudgeable
Crazy LCPGiven N strings and Q range queries, for each range [L, R] report the maximum longest common prefix over all pairs of distinct strings in that range.Hard8StringTrie+2No attempts yet2s512 MBJudgeable
Non-Decreasing Subarray GameFor each query range, Yuto picks an integer to minimize and Platina then picks one to maximize the count of non-decreasing subarrays inside the interval they bound; output the resulting score.Hard8Game theoryDynamic programming+2No attempts yet2s256 MBJudgeable
Nutella's LifeChoose a subsequence of contests with nondecreasing values, where skipping x contests in a row costs x+1 each, to maximize total fun.Hard8Dynamic programmingSegment tree+1No attempts yet2s512 MBJudgeable
Biggest NumberAfter each of Q point updates to the digits on N cards, report the largest base-D number obtainable by rearranging the cards, modulo 1e9+7.Hard8Segment treeSorting+2No attempts yet0.5s256 MBJudgeable
Addition RobotMaintain a binary string under range flips and answer queries that apply the range's A/B operations to a pair of numbers, modulo 1e9+7.Hard8Segment treeMatrix+2No attempts yet3s512 MBJudgeable
ADD, DIV, MAXMaintain an array under range add, range floor-divide, and range maximum queries, with N and Q up to 200000.Hard8Segment treeLinked list+2No attempts yet5s256 MBJudgeable
Hacker Cups and BallsGiven a permutation and range sort operations that go ascending or descending depending on whether l < r, find the value in the middle cup at the end.Hard8Binary searchSegment tree+2No attempts yet3s512 MBJudgeable
Array and OperationsMaintain an array under range add, range floor-square-root, and range sum queries, printing each sum.Hard8Segment treeBinary search+2No attempts yet1s512 MBJudgeable
Urban BlightGiven points and weighted segments, find a horizontal line whose intersection with the segments maximizes the total weight of segments it touches.Hard8GeometrySorting+2No attempts yet2s1024 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
Admiral Yi Sun-sinMaintain a dynamic graph of national roads (union-find) and acyclic expressways (link-cut style tree), updating region comfort values tied to region 1's component and answering path/sum queries online.Hard9Union-findTree+2No attempts yet1.216s512 MBJudgeable
Wake Up!Count the distinct points where any two of up to 20,000 line segments intersect, using an efficient computational geometry sweep.Hard9GeometryDivide and conquer+2No attempts yet1s128 MBJudgeable
ShotGiven columns of black/gray/white cans stacked in fixed color order, repeatedly shoot a height to remove one layer from every tall-enough column and report the collapsing score after each shot.Hard9Segment treeBinary search+2No attempts yet2s256 MBJudgeable
Hyeonju's Pizza ShopGiven jobs with desired completion times and processing times on a single machine, compute the maximum total tip (sum of signed lateness against desired times) after each of many update operations that change a job's parameters, requiring an efficient dynamic scheduling data structure.Hard9GreedySegment tree+1No attempts yet2s128 MBJudgeable
FPSGiven N players and Q candidate additions, count ways to pick K bots with distinct speeds/ranges each dominated by some human, modulo 10009.Hard9CombinatoricsMath+2No attempts yet5s128 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
Hanging HatsSimulate mages hanging triangular hats on a wall, tracking nail visibility and expulsion under coverage rules that require an advanced geometric data structure.Hard9GeometrySegment tree+2No attempts yet3s128 MBJudgeable
Cow HopscotchChoose an outbound path of jumps (each at most K squares) and a return path that only lands on squares one less than an outbound square, maximizing collected values.Hard9Dynamic programmingSegment tree+2No attempts yet1s128 MBJudgeable
A Romantic Movie OutingMaintain a dynamic set of occupied seats across a huge theatre, answer queries for the combined field-of-vision inconvenience of two seats, and at the end find the minimum over far unoccupied seat pairs.Hard9Segment treeDynamic programming+2No attempts yet2s512 MBJudgeable
Move that Mouse AGAINGiven up to 50,000 axis-aligned rectangles in a fixed bottom-to-top stacking order, process 50,000 point clicks, printing the topmost window at each point and moving it to the top of the stack.Hard9Segment treeGeometry+2No attempts yet3s128 MBJudgeable
Longest Paths in a TreeA rooted tree has weighted edges. Handle point updates to edge weights and queries that ask for the maximum-weight downward path from a vertex inside its subtree.Hard9TreeSegment tree+2No attempts yet5s1024 MBJudgeable
Falling BallsGiven slanted platforms whose endpoints move over time, find the final x-coordinate reached by a ball dropped at a given x.Hard9Segment treeTree+2No attempts yet2s1024 MBJudgeable
Bus TourChoose a sequence of attractions with strictly increasing construction times maximizing attractiveness collected plus Manhattan travel distance.Hard9Dynamic programmingSorting+2No attempts yet1s128 MBJudgeable
Ski RentalGiven daily snowfall amounts with point updates, answer queries asking for the maximum average snowfall over a consecutive run starting at a given day, reported as an irreducible fraction.Hard9Segment treeGeometry+1No attempts yet1s128 MBJudgeable
JourneysGiven m batches, each joining every town in one interval to every town in a disjoint interval, find the shortest path in highway count from town p to all towns.Hard9GraphBFS+2No attempts yet1s128 MBJudgeable
HighwaysMaintain a layered graph where each province has a few cities and highway lane counts change over time, answering route-count queries modulo d after each update.Hard9MatrixSegment tree+1No attempts yet1s128 MBJudgeable
PeaksFor each query, starting from a peak and using only edges up to a difficulty limit, report the k-th highest reachable peak height or -1.Hard9GraphUnion-find+2No attempts yet2s128 MBJudgeable
GenomeBuild the lexicographically smallest sequence that is l adjacent swaps from the first genome and k-l swaps from the second.Hard9GreedySegment tree+1No attempts yet1s128 MBJudgeable
WombatsFind the cheapest southbound path across a grid with free east-west moves and south-only vertical roads under weight updates and escape queries.Hard9Segment treeShortest path+1No attempts yet20s256 MBJudgeable
It Takes a VillageProcess online trading-post additions that spread through biconnected blocks and capital dominators, and answer revenue queries for single villages.Hard9GraphDFS+2No attempts yet20s128 MBJudgeable
CakeStarting from piece a, Leopold always eats the less delicious piece next to the empty interval, and each query asks how many pieces are eaten before piece b.Hard9Segment treeDivide and conquer+2No attempts yet2s1024 MBJudgeable
Solar LampsCompute each lamp turn-on time from its place in the power-on order and the count of already lit lamps shining on it.Hard9GeometrySegment tree+1No attempts yet1s256 MBJudgeable
MuseumA burglar picks guards to bribe to maximize the value of exhibits no remaining guard sees minus bribe costs under downward cone views.Hard9GraphGeometry+1No attempts yet1s256 MBJudgeable
Tile CuttingFor each query range, find the area with the largest count of inscribed parallelogram cuts and report that count, breaking ties by the smaller area.Hard9Number theoryMath+1No attempts yet15s256 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
CircusFind the smallest starting hold depth on a temporary rope at D that reaches distance M by hopping between ropes within swing range.Hard9Shortest pathSegment tree+1No attempts yet2s512 MBJudgeable
Covering postersFor each new axis-aligned rectangle, compute the total area of the given union of rectangles that it covers.Hard9Segment treePrefix sum+2No attempts yet2s1024 MBJudgeable
Half-plane land grab 2Maintain a dynamic set of lines under insertions and deletions and answer maximum-at-x queries online.Hard9Dynamic programmingDivide and conquer+2No attempts yet4s512 MBJudgeable
Smallest Unpayable AmountFor each query interval, find the smallest positive amount that cannot be formed as a subset sum of the coins in that interval.Hard9GreedySorting+2No attempts yet4s512 MBJudgeable
ArrayStart with array a_i = i, apply up to 300000 queries that reverse or rotate subarrays and ask for range min, max, sum, value at index, or index of a value, then print the final array.Hard9ArrayImplementation+2No attempts yet1s512 MBJudgeable
PostersCompute the visible area of each of N rectangles pasted in order on the plane, where later rectangles cover earlier ones.Hard9GeometryDivide and conquer+2No attempts yet2s512 MBJudgeable
Trees and Queries 10Given a tree with vertex weights, answer path maximum-subarray-sum queries and path range-assign-weight updates.Hard9Segment treeTree+2No attempts yet2s512 MBJudgeable
XOR QueriesMaintain an array under appends, rollbacks of the last k elements, and range queries for max XOR, count <= x, and k-th smallest.Hard9TrieSegment tree+2No attempts yet2s512 MBJudgeable
Sequence and Queries 0For each query range [i,j] of a ±1 sequence, report the length of the longest contiguous subarray inside it whose sum is 0, or 0 if none exists.Hard9Segment treePrefix sum+2No attempts yet2.5s512 MBJudgeable
Sequence and Queries 6For each query range [i, j], report the highest number of occurrences of any single value inside that range.Hard9Segment treeDivide and conquer+2No attempts yet2s512 MBJudgeable
Sequence and Queries 9For each query range [i,j] and value k, count ordered pairs (p,q) from that range with A[p]*B[q] <= k.Hard9Divide and conquerSegment tree+2No attempts yet6s512 MBJudgeable
Sequence and queries 12Maintain a dynamic sequence under point updates, deletions, and insertions, answering range queries for distinct count and the sum of triple products of distinct values.Hard9Segment treeHash map+2No attempts yet2s512 MBJudgeable
HackerSimulate substring comparisons, substring copy from a fixed string, and range letter-increment operations on a mutable string of length N.Hard9Segment treeHash map+2No attempts yet4s512 MBJudgeable
Rides 2Each day one child grows by 1 or 2, and we must report how many of Q fixed child-pair and ride triples become valid that day.Hard9Segment treeSorting+2No attempts yet2s256 MBJudgeable
Smallest unreachable subsequence sumFor each subarray, find the smallest non-negative integer that no subsequence sums to.Hard9Segment treeGreedy+1No 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
GarageMaintain a sequence under point updates, and for each range query count subarrays whose elements share a common divisor greater than 1.Hard9Segment treeNumber theory+2No attempts yet4s256 MBJudgeable
Imelda's Shopping SpreeMaintain a sequence of prices under range-add and range-reverse, and after each update output the number of contiguous segments whose values are strictly increasing.Hard9Segment treeArray+2No attempts yet5s512 MBJudgeable
GardenerMaintain N gardens under plantings, range deletions of plants taller than h, and range count queries, all with time-dependent growth.Hard9Segment treeBinary search+2No attempts yet3s128 MBJudgeable
New HomeStores of k types each occupy a point and an open year interval; for each (location, year) query, report the maximum over types of the distance to the nearest open store of that type, or -1 if some type is missing.Hard9Segment treeBinary search+2No attempts yet5s1024 MBJudgeable
International Cow Lineup Photo ContestGiven a 0/1 array and up to 1e5 adjacent swaps, after each swap report the longest subarray with equal numbers of 0s and 1s.Hard9Segment treePrefix sum+2No attempts yet2s512 MBJudgeable
mex and QueriesMaintain a set of natural numbers under range add, range remove, and range toggle queries, then output the mex after each of up to 100000 queries with values up to 1e18.Hard9Segment treeIntervals+1No attempts yet2s512 MBJudgeable
Query and QueryEach query swaps two sequence values; after every swap, pair up the M left-pocket indices and M right-pocket indices to minimize the largest range maximum. Output that minimized maximum.Hard9Segment treeGreedy+2No attempts yet2s512 MBJudgeable
Build a WorkbookMaintain a dynamic precedence relation among N problems under edge inserts and deletes, and answer whether the subgraph induced by problems x through y is acyclic.Hard9GraphDynamic programming+2No attempts yet2s512 MBJudgeable
Sequence and Queries 26Maintain a sequence under range chmin updates, range maximum queries, and range sum queries, with up to a million elements and queries.Hard9Segment treeDynamic programming+2No attempts yet4s512 MBJudgeable
Traveling MerchantGiven weekly price cycles at n towns, answer q queries for the max profit from buying and later selling during a trip from town s to town t.Hard9Segment treeDivide and conquer+2No attempts yet10s1024 MBJudgeable
HotelMaintain an array under point height updates; after each update answer queries for the longest subsegment inside [l, r] that contains no strict interior valley.Hard9Segment treeArray+2No attempts yet2s512 MBJudgeable
Dynamic DiameterMaintain a weighted tree under edge weight updates and report the diameter after each of q updates, decoding each query with the previous answer.Hard9TreeDivide and conquer+2No attempts yet5s512 MBJudgeable
EmploymentGiven candidate evaluation values with point updates, answer queries asking for the number of maximal contiguous blocks of hired candidates whose value is at least a threshold.Hard9Segment treeDivide and conquer+2No attempts yet5s512 MBJudgeable
Sequence and Queries 32Maintain a sequence under point updates and answer whether it can be split into contiguous blocks whose xors all lie in a small given set.Hard9Dynamic programmingPrefix sum+2No attempts yet10s512 MBJudgeable
Sequence and Queries 34Maintain two integer sequences under updates and range queries: for a suffix of a compute the longest match against b and how many suffixes achieve it, compare suffixes of b, and test whether a concatenation of two b-substrings is itself a substring of b.Hard9String matchingSegment tree+2No attempts yet2s512 MBJudgeable
Colored Paper and QueriesGiven N axis-aligned rectangles and M axis-aligned query rectangles, report for each query the maximum number of input rectangles covering any single point inside it.Hard9Segment treeDivide and conquer+2No attempts yet1s512 MBJudgeable
Seven NeversFor every window of k consecutive elements in a permutation, compute the LIS length after deleting that window.Hard9Dynamic programmingSegment tree+2No attempts yet2s512 MBJudgeable
Make Rounddog HappyCount subarrays whose elements are all distinct and whose maximum minus length is at most k, for arrays up to 300,000 with values bounded by n.Hard9Divide and conquerTwo pointers+2No attempts yet2s512 MBJudgeable
OR and QueriesProcess range bitwise-OR updates on an array and count how many positions in a range currently equal a fixed K.Hard9Segment treeBit manipulation+2No attempts yet1.5s256 MBJudgeable
Deja VuMaintain an array under point updates and answer queries asking for the earliest position d that ends an increasing subsequence of length 4 starting at or after l.Hard9Segment treeDynamic programming+2No attempts yet5s512 MBJudgeable
Dirt RatioChoose a contiguous subarray to minimize (number of distinct values)/(subarray length); print the minimum ratio.Hard9Binary searchPrefix sum+2No attempts yet2s512 MBJudgeable
Sequence and Queries 39Maintain an array under range updates that add an arithmetic progression, and answer queries for the longest arithmetic-progression subarray inside a range.Hard9Segment treeMath+2No attempts yet2s512 MBJudgeable
JumpGiven cities at integer grid points and portals that jump from one city to any city inside an axis-aligned rectangle at a given cost, find the shortest time from city 1 to every city.Hard9Shortest pathGraph+2No attempts yet1s512 MBJudgeable
AtomsMaintain a sequence of charges under range add updates, and after restricting to a query segment, report the longest run of consecutive positions where each next charge exceeds the previous by exactly one.Hard9Segment treeDynamic programming+2No attempts yet2s512 MBJudgeable
Tree and Queries 20Maintain a dynamic forest with link/cut and weighted edges, supporting toggling a vertex weight and querying the minimum weighted sum of tree distances from any vertex, with encrypted vertex indices.Hard10TreeSegment tree+1No attempts yet5s512 MBJudgeable