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
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| B-Smooth NumbersCount B-smooth numbers (no prime factor above B) in the interval [n, n+m], with n up to 2e9, m up to 1e8, and B up to 1e6. | Hard8 | Number theorySegment tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ice SkatesAfter each of m membership events, decide whether every current member can be assigned skates, given k pairs of each size and foot sizes with tolerance d. | Hard8 | Segment treeGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Monotonicity 2Find the longest subsequence of a given array whose adjacent-comparison pattern repeats the given cyclic scheme of <, >, = symbols. | Hard8 | Dynamic programmingSegment tree+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Painting the WallGiven n axis-aligned rectangles, find the total area of the plane covered by at least n-1 of them. | Hard8 | SortingSegment tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PermutationFor a sequence a and each of m point updates, report whether a permutation p with p_i <= a_i for all i exists. | Hard8 | GreedySegment tree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Fibonacci MachineMaintain registers under range increment, answering range queries of the sum of Fibonacci values at the register entries, modulo 1e9+7. | Hard8 | Segment treeMatrix+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Interval Partition GeneratorThe task is to decode each given lexicographic interval index on the remaining set and report the total interval count with the chosen endpoints. | Hard8 | Segment treeBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Company ChoirGiven a rooted tree where each node has a pitch and a distinct ability score, answer queries that ask for the k highest-ability subordinates of a node whose pitch lies in a range [a,b]. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| KingdomRoads merge cities into connected states over time, and each query asks how many states a horizontal line meets and how many cities those states contain. | Hard8 | Union-findSegment tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| KkunglishFor each query range, the program reports the case-insensitive occurrence of T with the most case differences, or -1 if none, then flips the case of the range. | Hard8 | Segment treeString matching | No attempts yet | 2s | 128 MB | Judgeable |
| Longest ChainFind the longest chain of triples with all three coordinates strictly increasing among up to 300,000 points per dataset. | Hard8 | Divide and conquerDynamic programming+2 | No attempts yet | 10s | 128 MB | Judgeable |
| Wedding HallFind the largest L-shaped hall of three equal squares that fits inside a walled garden without enclosing any tree. | Hard8 | GeometryBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| WallApply k range raise-to-at-least and lower-to-at-most updates on n columns and print each final height. | Hard8 | Segment tree | No attempts yet | 3s | 256 MB | Judgeable |
| CardsThe program decides after each swap of two two-sided cards whether one face per card can show numbers that never decrease left to right. | Hard8 | Segment treeDynamic programming | No attempts yet | 3s | 256 MB | Judgeable |
| RallyFind the vertex whose removal minimizes the longest directed path in a DAG and report that minimum length. | Hard8 | Topological sortDynamic programming+1 | No attempts yet | 1s | 256 MB | Judgeable |
| TribesRepeatedly merge axis-aligned rectangles whose overlap has positive area into their bounding box, then print the remaining boxes in lexicographic order. | Hard8 | Union-findSegment tree+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| FertilizingEach day the C_i shortest of N trees grow by the day number and the K_i-th shortest height is recorded; report the sum over all days. | Hard8 | Segment treeSorting+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Fantastic ProblemYou count size-k windows where some pair shares a factor, refresh the count after each point update, then print the final sum. | Hard8 | Segment treeNumber theory+1 | No attempts yet | 10s | 256 MB | Judgeable |
| Journey through the kingdomFind the cheapest carriage-hopping cost between consecutive target cells on a grid where each cell rents a ride to any cell in its rectangle range. | Hard8 | Shortest pathSegment tree | No attempts yet | 3s | 256 MB | Judgeable |
| MokiaPoint updates add customers to grid cells and each query asks for the total inside a rectangle using only earlier updates. | Hard8 | Divide and conquerSegment tree | No attempts yet | 1s | 128 MB | Judgeable |
| ImprovementsReposition ships on a line from a station so no two ropes joining consecutive ships cross, keeping as many ships as possible in place. | Hard8 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 256 MB | Judgeable |
| The j-th NumberAfter copying each insert value into every array of its interval, each query asks for the j-th smallest value collected from an interval of arrays. | Hard8 | Binary searchSegment tree+2 | No attempts yet | 10s | 512 MB | Judgeable |
| EditorGiven up to 500000 edits and leveled undos, print the editor state after each operation. | Hard8 | StackSegment tree+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Forming TeamsFor each planned day, decide whether students with accepted size ranges can fill all requested teams of the given sizes. | Hard8 | GreedyIntervals+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Selling horsesOne horse multiplies by X[i] each year and any held horses sell at price Y[i]; report the maximum revenue after each point update modulo 1e9+7. | Hard8 | Segment treeGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| ExchangeCount the swaps performed by running the first M passes of selection sort on each array. | Hard8 | Segment treeSorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Call a CabPartition the ordered points into the fewest rides where each ride meets one type's minimum total distance and heading range limit. | Hard8 | Dynamic programmingSegment tree+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Colored painting salesEach client buys a_i colored or b_i black-and-white paintings, and after each update count the sales with at least C colored buyers modulo 10007. | Hard8 | Dynamic programmingSegment tree+1 | No attempts yet | 4s | 32 MB | Judgeable |
| Pyramid BaseFind the side length of the largest axis-aligned square on a grid that avoids all given rectangular obstacles. | Hard8 | Binary searchGeometry+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Cow ConfinementEach cow moves only down or right across a large grid and cannot cross rectangular fences, and the task asks how many flowers each cow can reach. | Hard8 | Segment treeSorting+1 | No attempts yet | 10s | 512 MB | Judgeable |
| 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. | Hard8 | Segment treeStack+2 | No attempts yet | 6s | 512 MB | Judgeable |
| Text ProcessorCount the distinct substrings inside each fixed-width window of a lowercase string for many queries. | Hard8 | String matchingSliding window+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Niya's HappinessTrack insertions and deletions in a banknote multiset and report after each update whether every amount up to the total is payable exactly. | Hard8 | Segment treeSorting+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Sunlight on a TreeReport all nodes on the tree path from u to v whose dot product with the query direction is minimal. | Hard8 | TreeSegment tree+1 | No attempts yet | 5s | 256 MB | Judgeable |
| New Year TrainAssign each wagon in input order to one of M queue tracks so wagons exit numbered 1 to N, choosing the lexicographically smallest assignment. | Hard8 | GreedyQueue+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Rain AgainFind the fewest leading drops so every W by H rectangle inside the L by L pot contains a drop strictly inside, or report -1. | Hard8 | Binary searchSegment tree+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Counting palindromesCount the palindromic substrings fully contained in each query interval of a lowercase string. | Hard8 | String matchingSegment tree+2 | No attempts yet | 2s | 64 MB | Judgeable |
| K-th smallest weight on a tree pathAnswer each query with the K-th smallest vertex weight on the path between two vertices in a tree. | Hard8 | Segment treeTree+1 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Fortune Telling 2N two-sided cards start showing A_i and each threshold T_j flips every card whose visible number is at most T_j; compute the final visible sum. | Hard8 | Segment treeSorting+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Mowing the FieldCount interior crossings of perpendicular mower segments cut at least T days apart. | Hard8 | Segment treeGeometry+1 | No attempts yet | 5s | 512 MB | Judgeable |
| FaultGiven diagonal fault shifts with surface erosion, report the original depth of the layer exposed at each unit of the surface. | Hard8 | Segment treeGeometry | No attempts yet | 2s | 256 MB | Judgeable |
| Fairland (Large)Keep the largest rooted connected subtree containing the CEO so all kept salaries fit within a range of width D. | Hard8 | TreeSliding window+2 | No attempts yet | 10s | 512 MB | Judgeable |
| The Great Wall (Large)Count how many moving interval attacks pierce a wall that rises after each success to the strength that would have stopped it. | Hard8 | Segment treeIntervals+1 | No attempts yet | 15s | 512 MB | Judgeable |
| Increasing Speed Limits (Large)Generate a sequence from a recurrence, then count modulo 1e9+7 how many non-empty strictly increasing subsequences it has. | Hard8 | Dynamic programmingSegment tree | No attempts yet | 5s | 512 MB | Judgeable |
| Dynamic memory allocationSimulate a memory allocator over n bytes: allocate the leftmost run of l free bytes, or free a range and count how many bytes were actually freed. | Hard8 | IntervalsSegment tree+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| Hongjun Loves PaintingBricks start with color equal to their index and colorfulness 0; range paint operations add the absolute color change to each brick, and queries ask for the total colorfulness over a range. | Hard8 | Segment treeImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Range GCDSupport range add and range GCD queries on an array by tracking a difference array with a segment tree and one prefix sum. | Hard8 | Segment treeNumber theory+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Minho's WishFor each of Q range queries on an array, count how many distinct values occur at least three times within the queried index range. | Hard8 | Segment treePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TreeMaintain a rooted tree under vertex deletions (children reparent to grandparent) and answer distance queries between two live vertices. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Calculation mistakeMaintain a string of digits and plus or minus signs under range replacements, and evaluate the arithmetic value of any substring with the calculator's operator rules. | Hard8 | Segment treeString+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Farthest White Pair in a TreeMaintain a tree whose vertices flip between white and black, and after each flip report the largest distance between two white vertices, where edge lengths may be negative. | Hard8 | TreeDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 1Given a static sequence, answer M queries counting how many values in range A[i..j] are greater than k. | Hard8 | Segment treeSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Palindromes and QueriesSupport range character assignments and count palindromic substrings of length at most K inside a queried range. | Hard8 | Segment treeString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 3Given a static sequence, answer queries (decoded with the previous answer via XOR) counting how many elements in a subarray exceed k. | Hard8 | Segment treeBinary search+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Sequence and Queries 10For each query with ranges [x1,y1] and [x2,y2], find the maximum subarray sum A_i+...+A_j where i is in the first range and j is in the second. | Hard8 | Segment treePrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Emission SpectrumMaintain an integer array under adjacent swaps and answer k-th smallest value queries over subarrays online. | Hard8 | Binary searchDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 13Maintain an array under range add, range multiply, and range assign modulo 1e9+7, answering range sum queries. | Hard8 | Segment treeLinked list+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ShoppingGiven an array of prices and a sequence of queries (money, l, r), simulate a shopper who spends as much as possible at each product from l to r and report the leftover money. | Hard8 | ArraySegment tree+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Demilitarized ZoneFor each protected point, count how many starting mines eventually trigger a blast covering it, given chain reactions over intervals. | Hard8 | IntervalsSorting+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Maximum Bitwise OR by Window LengthFor each window length K from 1 to N, output the maximum bitwise OR over all K consecutive elements of the array. | Hard8 | Bit manipulationDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PoklonFor each query interval, count distinct values that occur exactly twice within it. N and Q go up to 500,000. | Hard8 | Prefix sumHash map+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Why Did the Cow Cross the Road 11Given a permutation of breeds on each side of a road, connect pairs whose breed numbers differ by at most 4 using non-crossing edges, maximizing the count. | Hard8 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 18Maintain an array under point updates and answer range queries counting elements greater than k. | Hard8 | Segment treeSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Weather ForecastMaintain N snow depths under point increments and decrements, then answer range-count queries (depth between L and R) and T-th largest value queries online. | Hard8 | Segment treeBinary search+2 | No attempts yet | 2s | 128 MB | Judgeable |
| RMT Subway Load TestEach subway line is a cycle of stations; line operations rotate passenger counts around the cycle, and range-sum surveys must be answered online. | Hard8 | Segment treePrefix sum+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Cups and MarblesAfter m range-sort spells (ascending or descending) on a permutation, report the marble in the middle cup. | Hard8 | Binary searchSorting+2 | No attempts yet | 4s | 256 MB | Judgeable |
| Goodness of a sequenceFor every contiguous block, subtract the maximum increasing-subsequence sum from the block sum, then report the best value and how many shortest blocks achieve it. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 19Maintain an array under range add, range floor-division by d, and report the minimum and sum over a range. The division step needs a segment tree with min and sum. | Hard8 | Segment treeLinked list+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Sheets and PaintballsGiven axis-aligned rectangles and colored points, count the distinct color labels that reach each rectangle along the vertical stacking order. | Hard8 | SortingSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Intergalactic ChordsMaintain an array of N notes (0 to 8); for each chord [a,b] find the most frequent note in the range, break ties by largest, then add it modulo 9 to every note in the range. | Hard8 | Segment treeImplementation+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Daunting deviceApply N range-recolor operations whose endpoints depend on the current count of a query color, then report the highest cell frequency. | Hard8 | Segment treeImplementation+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Joker's Card TrickAfter each point update to a row of nonzero integers, find the smallest prefix index maximizing the running sum of values scaled by the total positive and total negative sums. | Hard8 | Segment treePrefix sum+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Posters on the wallGiven up to 50000 non-overlapping axis-aligned rectangles, answer online queries that ask for the total rectangle area inside a query rectangle, with coordinates decoded from the previous answer. | Hard8 | Segment treeSorting+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| The Infosci Pirate CrewGiven N islands with coordinates, treasure values, and safe hardness, choose a monotone northeast path and a hardness interval to maximize collected value minus interval length. | Hard8 | Dynamic programmingSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| The Grand Noi and ICPC BattleMaintain a sequence of N ones under range assignment and queries for the sum of A_i A_j A_k over all i<j<k in a range, modulo 10^8, with N up to 1e9 and Q up to 1e5. | Hard8 | Segment treeDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Maximum Interval Sum 2For a sequence with point updates, answer range queries for the maximum of U times a subarray sum plus V times its length minus one. | Hard8 | Segment treeDivide and conquer+2 | No attempts yet | 1s | 256 MB | Judgeable |
| SprinklersGiven a permutation of N sprinklers, count axis-aligned integer rectangles whose every point lies both northeast of some sprinkler and southwest of another, modulo 1e9+7. | Hard8 | CombinatoricsDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Global warmingChoose one contiguous interval and a shift d with |d| <= x, then find the maximum possible length of a strictly increasing subsequence of the modified sequence. | Hard8 | Dynamic programmingBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Zoning HousesFor each query range of houses, find the side length of the smallest axis-aligned square covering all points in the range, with the option to drop one point. | Hard8 | Segment treeDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Coloring RoadsColor every edge on a root path with a given color and then count colors used on exactly m edges, answering Q updates online. | Hard8 | TreeSegment tree+2 | No attempts yet | 4s | 1024 MB | Judgeable |
| Masha and CactusChoose a maximum-weight subset of extra edges whose tree paths keep each vertex in at most one cycle, by a subtree DP with lazy updates on the path to the root. | Hard8 | TreeDynamic programming+2 | No attempts yet | 4s | 512 MB | Judgeable |
| RectanglesGiven up to 100,000 axis-aligned rectangles drawn by XOR-flipping pixels on a white field, find the total count of black pixels. | Hard8 | Segment treePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| King Kog's ReceptionKnights join or cancel reservations with a start time and duration; after each change, a query asks how long a visitor arriving at time t must wait, since she yields to a knight arriving at the same instant. | Hard8 | Segment treeBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Three Primary ColorsGiven up to 25,000 colored rectangles painted one at a time without repainting already covered pixels, report the total area of each of the seven resulting color regions. | Hard8 | Divide and conquerSegment tree+2 | No attempts yet | 3s | 256 MB | Judgeable |
| IlluminationChoose a subset of trees to decorate, maximizing total beauty, so that for each of M given intervals at most one tree inside it is chosen. | Hard8 | Dynamic programmingSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 22Given a sequence and a stream of updates and range-sum queries, answer each query for the sequence state after its k-th update only, where k can be any earlier prefix of updates. | Hard8 | Segment treeDivide and conquer+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Maximum Subarray Sum and QueriesGiven an array, answer queries that ask for the maximum subarray sum inside a given index range. | Hard8 | Segment treeDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Intersecting RectanglesGiven n axis-aligned rectangles with all x and y coordinates distinct, decide whether any two boundaries cross or touch. One rectangle fully containing another does not count. | Hard8 | SortingSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cow LandOn a weighted tree, support point value updates and path XOR queries between any two nodes, returning the XOR of enjoyment values along the unique route. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| KisikChoose K of N distinct buildings, arrange them side by side on the ground, and minimize the area of the enclosing bounding rectangle. | Hard8 | SortingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Truth TellersGiven N people each stating a range for the number of truth tellers, find the maximum consistent truth-teller count after each of Q point updates. | Hard8 | ArraySegment tree+2 | No attempts yet | 3.5s | 256 MB | Judgeable |
| Raider Choragi and Queries (Normal)A donut-shaped ring of 2N zones holds prisoner counts that change over Q updates; after each change, print the minimum number of squads, each covering one zone or two adjacent zones with total at most W. | Hard8 | Dynamic programmingSegment tree+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Card Factory (Large)Each of N cards shows its front initially; given M queries K that flip every card whose visible number is at most K, report the final visible sum. | Hard8 | SortingBinary search+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Sequence and Queries 24Maintain an array under point updates and range queries that ask for the largest sum of two distinct elements within a subarray. | Hard8 | Segment treeDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 2xN Tiling with QueriesMaintain the count of tilings of a 2xN grid by 1x2 and 2x1 tiles while cells get blocked and unblocked by queries. | Hard8 | Dynamic programmingSegment tree+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Fox QuizGiven answer strings S and T over O/X, answer range queries and point flips: for a range, choose positions to mark F to maximize A times correct answers plus B times occurrences of the consecutive pattern F,O,X. | Hard8 | Segment treeDynamic programming+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Sequence and Queries 25Maintain an array under range bitwise AND, range bitwise OR, and range maximum queries, each value below 2^20. | Hard8 | Segment treeBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 28Maintain an array under range add, range floor-sqrt, and range sum queries, and report each range sum. | Hard8 | Segment treeMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Sequence and Queries 31Maintain a 0/1 sequence under range reversals, and answer queries for the longest run of 1s inside a given range. | Hard8 | Segment treeIntervals+2 | No attempts yet | 2s | 512 MB | Judgeable |
| XORangesMaintain an array under point updates and answer queries for the XOR of every contiguous subarray inside [l, u]. | Hard8 | Bit manipulationSegment tree+2 | No attempts yet | 1s | 512 MB | Judgeable |