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 results1,178 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Flyswatter placementsCount the integer translations of a fixed polygon that keep it inside an axis-aligned rectangle and avoid all given points, including points on the boundary. | Hard8 | GeometryPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| LefkaritikaGiven a grid with blocked points, count the maximum number of axis-aligned square items of any side length that can be placed without covering blocked points, respecting placement order and same-size non-overlap rules. | Hard8 | ArrayDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Delight for a CatChoose sleep or eat each hour to maximize total delight, with at least ms sleep and me eat hours in every window of k consecutive hours. | Hard8 | Dynamic programmingSliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Jenga BoomSimulate removals from a Jenga-like tower and report whether it falls, and at which removal, when a level's center of mass leaves the convex hull of the blocks still supporting it. | Hard8 | GeometrySimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Solar FlightFor a line segment query, find the maximum total intercept-weight above a given ray over all x in a length-K window. | Hard8 | GeometrySorting+2 | No attempts yet | 15s | 512 MB | Judgeable |
| 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. | Hard8 | StackSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| FenceSum x! times y! over all unit cells inside an axis-aligned polygon, modulo 1e9+7, with coordinates up to 1e9. | Hard8 | MathPrefix sum+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Beautiful PathsOn a tree with capitals 1 and 2, sum over all pairs of cities of the minimum distance-to-nearest-capital along their path. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| IvoizationSum the Ivoization values of every K by K submatrix, where Ivoization is the pairwise absolute-difference sum of all K^2 entries, modulo 10007. | Hard8 | SortingPrefix sum+2 | No attempts yet | 1.5s | 128 MB | Judgeable |
| TrufflesGiven a grid of per-meter values, compute for each of M slanted lines the weighted length integral of the line through the grid, rounded to five decimals. | Hard8 | GeometryPrefix sum+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Scout GatheringsOn a tree, support adding a member at a city and querying the sum of weighted distances from all members to the current gathering city, which moves along edges. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Titteop LandPartition the line into K consecutive groups so the sum of pairwise awkwardness inside every group is minimized. | Hard8 | Dynamic programmingDivide and conquer+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Splitting Game LevelsPartition n levels into k consecutive groups to minimize the expected total time of a random coin-draw process, and print it to six decimals. | Hard8 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Wolves 2Count binary strings of length N in which every given interval contains at most two ones, modulo 1e9+7. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Company Culture 4On a rooted tree, praise spreads downward from an employee to all descendants or upward to all ancestors, the direction flips over time, and queries ask for an employee's accumulated praise. | Hard8 | TreePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Safe Squares (Large)Count all grid-aligned square regions of any size that contain no monster, given a sparse set of at most K monster cells on an R by C board. | Hard8 | ArrayDynamic programming+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Sherlock and Permutation Sorting (Large)For each N and modulus M, sum f(p)^2 over all permutations of 1..N, where f(p) is the maximum number of blocks that can be sorted independently; output the sum mod M. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 10s | 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 |
| PianoGiven N equally likely piano tones, find the expected number of presses until a fixed M-tone sequence appears, for every prefix of it. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 1s | 64 MB | Judgeable |
| SemiexpressChoose exactly K stops for a new train so that the number of stations reachable from station 1 within T minutes is maximized. | Hard8 | GreedyBinary search+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Rides 1Each day one child grows by 1 cm; after each growth, count how many of Q given pairs (i,j) can ride their specified ride, where the pair's combined height meets the ride's limit. | Hard8 | SortingBinary search+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Tidying the Plush ToysGiven a row of N toys of M types, find the fewest toys to remove so that after reinserting them all toys of each type form one contiguous block. | Hard8 | Dynamic programmingBit manipulation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Modern Art (Platinum)Given the final N x N canvas painted by N^2 nested rectangles, count how many colors could have been painted first. | Hard8 | ImplementationPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Segment Friends (Large)Given N segments on a line, build the intersection graph and answer Q shortest-path queries between segment pairs, or report -1. | Hard8 | GraphBFS+2 | No attempts yet | 2s | 256 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 |
| Product of GCDsCompute the product of gcd(i, j) over all pairs 1<=i<=N, 1<=j<=M, modulo 1e9+7, with N and M up to 15 million. | Hard8 | Number theoryMath+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Sum of least common multiplesSum lcm(x, y) over all pairs 1<=x<=n, 1<=y<=m that share no squared prime factor. | Hard8 | Number theoryMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Gathering clamsGiven an N by N grid of clam limits, compute after each of N single-cell +1/-1 updates the sum over all cells of the maximum-weight monotone staircase path to the top-left. | Hard8 | Dynamic programmingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| MonstersGiven a binary N x M grid, choose one intact cell to destroy so that the number of all-1 submatrices remaining is minimized, and report that minimum count. | Hard8 | ArrayDynamic programming+2 | No attempts yet | 1s | 32 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 |
| Even substringsFor each query listing up to 5 letters, count substrings of S in which every listed letter occurs an even number of times. | Hard8 | Bit manipulationHash map+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Airport CoffeeGiven spaced coffee carts along a corridor, choose where to buy cups so the total walking time with alternating slow and fast phases is minimized, output as a fraction. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 6s | 512 MB | Judgeable |
| BrincadeiraGiven an LFSR over N up to 30 bits, find a contiguous run of at least Y generated values whose sum is divisible by X, minimizing the end index then the start index. | Hard8 | Prefix sumHash map+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| LinearvilleFor each query, find the length of a shortest path between two grid crossings when the path must alternate directions at every crossing. | Hard8 | Shortest pathGraph+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 |
| Corporate life after a hostile takeoverGiven two rooted trees on the same n employees, count for each employee how many others are descendants in both trees. | Hard8 | TreeDFS+2 | No attempts yet | 0.5s | 1024 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 |
| 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. | Hard8 | SortingPrefix sum+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Donut DroneSimulate a drone on a toroidal grid where each step moves to the highest of three rightward neighbors, handling up to 1e9 steps per move query and elevation updates. | Hard8 | SimulationBinary search+2 | No attempts yet | 8s | 512 MB | Judgeable |
| The Great WallEach design picks two length-r intervals whose overlap height adds extra cost; find the k-th smallest total wall height over all interval pairs. | Hard8 | Binary searchPrefix sum+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Medical CheckupGiven n students in a fixed queue and their per-item service times, report the item each student is on or waiting for at time t+0.5. | Hard8 | SimulationMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Starting a Scenic Railroad ServiceFor n travel segments, compute the minimum seats needed under arbitrary online seat choices and under optimal offline assignment. | Hard8 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Winning SegmentsGiven a permutation of 0..2^M-1, count the nonempty subarrays whose XOR can be made equal to 2^M-1 by one mandatory swap of two elements. | Hard8 | Bit manipulationPrefix sum+2 | No attempts yet | 4s | 256 MB | Judgeable |
| K-summaryGiven segment lengths K_i, count how many array positions are pinned down by all the K_i-summaries. | Hard8 | MathNumber theory+2 | No attempts yet | 0.5s | 64 MB | Judgeable |
| Guardians of the LunaticsSplit a row of L cells into at most G contiguous nonempty blocks, where a block of length k multiplies each member's craziness by k, to minimize the total cost. | Hard8 | Dynamic programmingDivide and conquer+2 | No attempts yet | 7s | 512 MB | Judgeable |
| Computer ScienceFind the smallest L such that for each a_i we can pick an interval [x_i, x_i+L] covering a_i and containing at least K of the given integers. | Hard8 | Binary searchSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| HH CountryFor each query set of tree vertices, output twice the sum of pairwise tree distances. | Hard8 | TreeDFS+1 | No attempts yet | 10s | 512 MB | Judgeable |
| K-Uniform StringCount binary strings of length N where, for each of M given intervals, every length-K substring inside it contains the same number of ones, modulo 1e9+7. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Äventyr 2On a tree, timelines get marked over time, and after each mark you must report the distance from a queried vertex to the nearest marked vertex. | Hard8 | TreeBFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| SlingshotFor each of M queries (a, b), find the minimum time to move manure from a to b using the tractor (cost equals distance) plus at most one slingshot that flies from x to y in time t. | Hard8 | Divide and conquerSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| MagicCount substrings of an N-character string in which all K distinct letters of the whole string appear an equal number of times, modulo 1e9+7. | Hard8 | Hash mapPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ANTSGiven a tree and a set of up to 50 marked nodes per query, find the node minimizing the sum of distances to all marked nodes, for up to 5000 queries. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Nordic CampingGiven a grid with rocky cells blocked, answer queries each asking for the area of the largest all-usable square subgrid that contains a specified water source cell. | Hard8 | Dynamic programmingBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Split and MergeGiven two tilings of a 1xL board by 1x1 and 1x2 pieces, find the minimum number of split/merge operations to transform one into the other and count the ways. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Harmonious MatrixGiven a 2xN or 3xN matrix of distinct integers, find the largest subset of columns whose orderings within each row are identical, and report its column count. | Hard8 | SortingHash map+2 | No attempts yet | 5s | 768 MB | Judgeable |
| ShootingsGiven non-overlapping axis-aligned rectangles and shots that are vertical or 45-degree half-lines, compute for each shot the squared total length of its intersection with all rectangles. | Hard8 | GeometrySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fair ShareGiven n weighted points around the origin, choose a line through the origin that splits them into two half-planes, minimizing the absolute difference of the two half-plane weight sums. | Hard8 | GeometrySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Injecting DNAFor every suffix of a string, compute its toxicity from the number of out-of-order suffix pairs, then output the length of the suffix with the largest effectiveness. | Hard8 | StringSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CherrypickFor each cell, find the axis-aligned square containing it that maximizes the minimum cherry sweetness minus the square of its side length. | Hard8 | MatrixBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Number Theory and Applications: RecitationGiven n up to 1e9 and v up to 100, compute the sum over i=1..n and u=1..v of Jordan's totient function modulo 1e9+7. | Hard8 | Number theoryMath+2 | No attempts yet | 4s | 512 MB | Judgeable |
| ClustersPartition companies 1..N into contiguous clusters, each led by its first or last company whose limit L_i caps the size, minimizing the sum of C_i*S + T_i over leaders. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Array StudyFor each of q subarray queries on an array of 1 and -1, find the longest zero-sum subarray inside it, and print the sum of these lengths. | Hard8 | Prefix sumDivide and conquer+2 | No attempts yet | 2s | 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 |
| Metro LinesA tree is given, and for each query with two pairs of terminals, count the stations shared by the two paths between those pairs. | Hard8 | TreeLinked list+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Pixel TrianglesGiven up to four million right isosceles triangles on a 2000x2000 grid, count the total number of grid cells covered by at least one triangle. | Hard8 | Prefix sumMatrix+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Dropping BlocksGiven pile heights, decide whether prefix-wise operations (add 1 to a prefix or a suffix starting at k) can produce exactly that array, and say valid or invalid. | Hard8 | GreedyMath+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 |
| Sequential YahtzeeGiven up to 195 sequential dice rolls, assign consecutive segments to the 13 Yahtzee categories in order to maximize the total score. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| XOR SubmatrixBuild the N by M matrix with A[i][j] = V[i] xor U[j] and find the submatrix whose elementwise xor is maximal. | Hard8 | Bit manipulationTrie+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 |
| Piece of CakeGiven a convex polygon with n vertices in clockwise order, compute the expected area of the convex polygon formed by picking k of the vertices uniformly at random. | Hard8 | CombinatoricsGeometry+2 | No attempts yet | 2s | 512 MB | Judgeable |
| RedistrictingGiven a string of H and G representing a line of cows, split it into contiguous districts of length at most K minimizing the number of districts where G outnumbers or ties H. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cow DatingGiven probabilities p_i, choose a contiguous interval maximizing the chance that exactly one bull accepts, and print 10^6 times that probability rounded down. | Hard8 | MathTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Painting the Barn (Gold)Given N painted axis-aligned rectangles on a 200x200 grid, add up to two disjoint rectangles to maximize the total area covered by exactly K coats. | Hard8 | Prefix sumMatrix+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Artifact RestorationGiven a grid with some unknown cells, fill unknowns with 0 or 1 so that the total number of people summed over all subrectangles is divisible by K. | Hard8 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Broken DataDelete some integers from a sequence so the rest reads as N M U1 V1 ... UM VM with 1 <= Ui,Vi <= N; among all valid restorations, maximize N, then M. | Hard8 | ImplementationGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Ants on a CircleAnts move on a circle of N points, reversing on collision; for each query (P, X) find the earliest time point P has been visited at least X times. | Hard8 | MathSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | ArrayStack+2 | No attempts yet | 3s | 512 MB | Judgeable |
| ZooGiven a string, count for each prefix the non-overlapping prefix-suffix matches and output the product of (count+1) modulo 1e9+7. | Hard8 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Highway CyclingChoose a constant speed for each of N road segments so the total energy spent stays within EU and the total travel time is minimized. | Hard8 | Binary searchMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Super PianoPick k distinct subarrays whose lengths lie between L and R, maximizing the total sum of their elements. | Hard8 | HeapPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Union of BallsAll ball centers lie on the x-axis, so the union is a solid of revolution; compute its volume as p/q times pi and output p times q inverse mod 1e9+7. | Hard8 | GeometrySorting+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Making a FlyswatterGiven a simple polygon, find the expected squared distance between two points chosen independently and uniformly inside it. | Hard8 | GeometryMath+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Paris by NightGiven N graded points in general position, pick two boundary monuments and split the rest by the line through them to minimize the absolute difference of the two side sums. | Hard8 | GeometrySorting+2 | No attempts yet | 15s | 512 MB | Judgeable |
| Stop Counting!Given a deck of integers, choose one contiguous block to skip so the average of the remaining cards is maximized. | Hard8 | MathPrefix sum+2 | No attempts yet | 7s | 1024 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 |
| ExamFor each of Q threshold triples, count students with S>=X, T>=Y, and S+T>=Z, where N and Q reach 100000. | Hard8 | SortingPrefix sum+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| IOIOI CardsGiven a row of I/O cards and interval flip operations with per-length costs, decide whether all cards can be turned face up and find the minimum total flip time. | Hard8 | Shortest pathGraph+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fibonacci MusicBuild a digit string from Fibonacci numbers reduced mod M and answer queries for the N-th digit, with N up to 10^15. | Hard8 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Ranch CCTVFor each query, sheep in a grid shift one cell per day in a fixed direction for K days; report the XOR of the daily maximum over the CCTV rectangle. | Hard8 | Prefix sumMatrix+2 | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Hard8 | Segment treeSorting+2 | No attempts yet | 7s | 1024 MB | Judgeable |
| Strike ZoneGiven weighted point sets P1 (+c1 each) and P2 (-c2 each) with distinct x and y coordinates, find an axis-parallel rectangle maximizing c1*s minus c2*b. | Hard8 | Dynamic programmingSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| True/False WorksheetCount binary strings of length n that satisfy range hints, where each hint says a range is all equal or not all equal, modulo 1e9+7. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Water Tanks of Seongdae CountryA tree of water tanks rooted at a capital. Adding water at city A adds 1,2,3,... along the root-to-A path. Answer queries about how much water a given city currently holds. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingMatrix+2 | No attempts yet | 5s | 512 MB | Judgeable |
| GrudanjeGiven a word and Q substrings, find the first snowball throw index (in a given order of positions) after which no substring contains two uncovered equal letters. | Hard8 | ArrayBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Close NumbersGiven a permutation p and q range queries [l, r], find the minimum absolute difference between any two values in the subarray p[l..r]. | Hard8 | ArraySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | Segment treeBinary search+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | StackPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |