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 results868 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Kirchhoff's LawsGiven a resistor network, compute the equivalent resistance between node 1 and node N by solving Kirchhoff's laws.Hard8GraphMath+2No attempts yet2s512 MBJudgeable
It looks like the Fibonacci sequence, but...Sum F_i times i^k for i from 1 to n, where F is Fibonacci with F_1=1, F_2=2, and n can reach 10^17.Hard8MathDynamic programming+2No attempts yet2s512 MBJudgeable
Number of good treesCount labeled trees on kn nodes split into n blocks of size k, with no edge inside a block, modulo 1e9+7.Hard8CombinatoricsMath+2No attempts yet2s512 MBJudgeable
Binary StringsCount binary strings whose length lies in [L, R], is a multiple of K, and contains no two adjacent 1s, modulo 1e9+7.Hard8MathCombinatorics+2No attempts yet1s512 MBJudgeable
MaxplusGiven 3x3 integer matrices A and C, find the entrywise-largest integer matrix B with A (max-plus) B = C, or report that none exists.Hard8MathMatrix+2No attempts yet1s128 MBJudgeable
f(X) = A + X + B + X + CCount occurrences of pattern F in the K-fold string expansion f(X)=A+X+B+X+C applied to S, modulo 1e9+7.Hard8String matchingDynamic programming+2No attempts yet2s512 MBJudgeable
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.Hard8ArrayDynamic programming+2No attempts yet5s512 MBJudgeable
Counting CyclesCount all closed walks (cycles) of length less than K in a directed graph, where rotations count separately, modulo M.Hard8GraphMatrix+2No attempts yet2s512 MBJudgeable
RaspadSum the number of connected components of 1-cells over every contiguous band of rows in an n by m grid, with m at most 50 and n up to 100000.Hard8Dynamic programmingDivide and conquer+2No attempts yet6s1024 MBJudgeable
COWBASICInterpret a tiny language of assignments, nested fixed-count MOO loops, and one RETURN, all additions taken modulo 10^9+7, and print the returned value.Hard8ImplementationSimulation+2No attempts yet2s512 MBJudgeable
Nemmo Nemmo (Hard)Count subsets of occupied cells in an N by M grid (N times M at most 300) that contain no full 2 by 2 square, modulo 1e9+7.Hard8Dynamic programmingBit manipulation+2No attempts yet2s512 MBJudgeable
ACGCount assignments of N ordered problems to three solvers so A's count is a multiple of k, C never solves two in a row, and G solves at least one, modulo 10000007.Hard8Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Dango MakerChoose disjoint horizontal or vertical runs of three cells reading R, G, W in order on an N by M grid, maximizing how many such sticks fit.Hard8Dynamic programmingMatrix+2No attempts yet2s256 MBJudgeable
Blocks 4Count the tilings of an N by M rectangle using blocks of size k by N (rotatable) for k from 1 to N, modulo 1999, where M can be as large as 1e10.Hard8Dynamic programmingMath+2No attempts yet1s256 MBJudgeable
Sacred ScarecrowsCount subsets of empty cells in an R x C grid, modulo 1e9+7, such that every row has a scarecrow and every pair of consecutive columns has one.Hard8Dynamic programmingBit manipulation+2No attempts yet2s512 MBJudgeable
Word ClockPlace n distinct words left to right on an h by w grid where words may share letters, or report that no placement exists.Hard8BacktrackingImplementation+2No attempts yet2s512 MBJudgeable
CherrypickFor each cell, find the axis-aligned square containing it that maximizes the minimum cherry sweetness minus the square of its side length.Hard8MatrixBinary search+2No attempts yet2s512 MBJudgeable
Club Room ExpansionGiven each cell's count of walled directions (0 to 4), decide whether the grid can be fully partitioned into connected rooms of one to three cells fitting that wall count.Hard8Dynamic programmingBacktracking+2No attempts yet1s512 MBJudgeable
Racial DiscriminationWith up to 10 categories and 200 people, each with a selected flag, choose at most c categories and a rule on their bit patterns that misclassifies as few people as possible, and output that minimum.Hard8Bit manipulationBrute force+2No attempts yet2s512 MBJudgeable
Balcony RepairsGiven a huge R by C grid with at most 1000 blocked cells, place horizontal dominoes on free cells to maximize the count, then report that maximum and the number of ways modulo 1e9+7.Hard8Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
PlateAssign labels to odd lattice points on a quadrant-by-quadrant recursive spiral, then sum labels of points on x + y = k.Hard8MathSimulation+2No attempts yet1s512 MBJudgeable
Chemical tableGiven some cells of an n by m grid, fill the rest by purchasing cells and closing 2x2 rectangles; find the minimum number of purchases.Hard8Union-findGraph+2No attempts yet1s512 MBJudgeable
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.Hard8Prefix sumMatrix+2No attempts yet2s512 MBJudgeable
Far, Far AwayGiven an n by n cost matrix and budget m, find the maximum number of edges on a walk from vertex 1 with total cost at most m; vertices and edges may repeat.Hard8Binary searchGraph+2No attempts yet2s512 MBJudgeable
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.Hard8Prefix sumMatrix+2No attempts yet2s512 MBJudgeable
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.Hard8Dynamic programmingSegment tree+2No attempts yet5s512 MBJudgeable
Making Everything WhiteGiven an N by M black/white grid, choose for each cell one of three local color-inversion actions so that every cell ends up white, or report impossibility.Hard8GreedyImplementation+2No attempts yet1s512 MBJudgeable
Counting Spanning TreesCount spanning trees of a path graph where every pair of nodes at distance at most k is joined, k <= 5, n <= 10^15, modulo 65521.Hard8MatrixDynamic programming+2No attempts yet1s256 MBJudgeable
Third Baseman UnknownOn an N by N grid of uppercase letters, walk right or down from the top-left to the bottom-right and maximize how many times "MOLA" appears in the collected string.Hard8Dynamic programmingMatrix+2No attempts yet1s512 MBJudgeable
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.Hard8Dynamic programmingSegment tree+2No attempts yet2s256 MBJudgeable
Just Passing ThroughGrid path from the west edge to the east edge moving east, northeast, or southeast, crossing exactly n passes, minimizing total elevation.Hard8Dynamic programmingMatrix+2No attempts yet2s512 MBJudgeable
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.Hard8Prefix sumMatrix+2No attempts yet2s256 MBJudgeable
K==SCount sequences of length N over 26 letters that avoid any of Q given forbidden strings as contiguous substrings, modulo 1e9+7, where N can be up to 1e9.Hard8String matchingDynamic programming+2No attempts yet1s512 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
Fantastic FožgajCount length-m lowercase strings over 26 letters that avoid any of n forbidden patterns as a substring, modulo 1e9+7, with m up to 1e9.Hard8Dynamic programmingString matching+2No attempts yet1.5s512 MBJudgeable
Coloring a Rectangle 2Count binary colorings of an N by M grid, N up to 1e18 and M at most 5, with no 2x2 block of a single color, modulo 1e9+7.Hard8Dynamic programmingMatrix+2No attempts yet1s512 MBJudgeable
Non-Decreasing SubsequencesGiven an array of values from 1 to K, answer queries counting non-decreasing subsequences within a subarray, including the empty one, modulo 1e9+7.Hard8Dynamic programmingDivide and conquer+2No attempts yet2s512 MBJudgeable
Block BreakerBlocks drop in a grid when a knocked block has a dropped left/right neighbor and a dropped front/back neighbor; after each of q moves, report how many blocks fall.Hard8Union-findSimulation+2No attempts yet2s512 MBJudgeable
Banned WordsCount length-L strings over 26 letters avoiding a given set of banned substrings, modulo 998244353, with L up to 1e9.Hard8String matchingTrie+2No attempts yet2s512 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
Matrix SwapsGiven binary matrices A and B and a per-cell swap-count limit matrix C, find the minimum number of adjacent (including diagonal) cell swaps to turn A into B, or report impossibility.Hard9GraphShortest path+2No attempts yet2s128 MBJudgeable
All Closed-Walk LengthsGiven a directed graph, decide for every length x whether a closed walk of that length exists, then print the eventually periodic 0/1 sequence in its shortest prefix-plus-period notation.Hard9GraphMatrix+2No attempts yet2s128 MBJudgeable
District PartitioningPick X horizontal and Y vertical dividing roads from an (n+1)x(m+1) population grid so the maximum population of any resulting block is minimized.Hard9Binary searchGreedy+2No attempts yet2s128 MBJudgeable
Domino TilingFind the lexicographically smallest way to tile an N by M grid with dominoes while respecting forbidden borders between certain adjacent cells, or report impossibility.Hard9GraphBFS+2No attempts yet5s128 MBJudgeable
OrchardGiven up to 2500 non-overlapping colored rectangles, find the maximum area axis-aligned rectangle fully covered by orchards of one fruit type.Hard9GeometryMatrix+2No attempts yet2s64 MBJudgeable
Matrix and Fibonacci SumCompute the sum of Fibonacci numbers with linearly growing indices times increasing powers of a K×K matrix, modulo a prime, for N up to 10^1000.Hard9MatrixMath+2No attempts yet5s512 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
Nice PrefixesCount length-L strings over a K-letter alphabet where every prefix keeps all symbol counts within 2 of each other, modulo 1e9+7, with L up to 1e18.Hard9Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Mine the GradientGiven a grayscale grid, find the largest square subgrid whose values follow a vertical, horizontal, or diagonal uniform gradient, and report its area.Hard9Dynamic programmingImplementation+2No attempts yet10s128 MBJudgeable
The Lights Going On and OffGiven a light grid, pushing the button beside row k XORs it with the row above; count how many distinct bottom-row patterns can result from any subset and order of pushes.Hard9Bit manipulationMath+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
Overwriting GameYou repeat random prefix-rectangle repaints until the board matches the target, and report the expected total of painted cells as a reduced fraction.Hard9ProbabilityMatrix+1No attempts yet8s512 MBJudgeable
Slave to Achievements 2Repeatedly craft as many N-scrap daggers as possible and reclaim 0 to K scraps per dagger, then find the distribution of the final leftover under N scraps.Hard9ProbabilityDynamic programming+1No attempts yet3s256 MBJudgeable
Counting StringsCount strings over the lowercase alphabet whose length lies between L*K and L*K+N and in which at most K non-overlapping copies of a given pattern S can be found.Hard9Dynamic programmingString matching+2No attempts yet2s512 MBJudgeable
Number of walksGiven a directed graph as an adjacency matrix, find the smallest K such that the number of walks of length L grows as O(L^K), or -1 if none exists.Hard9GraphDynamic programming+2No attempts yet2s512 MBJudgeable
Solve this one tooGiven an N x L matrix, find windows of 3N columns split into matrices A, B, C with A*B=C; pick disjoint windows to maximize total colored cells.Hard9MatrixDynamic programming+2No attempts yet5s512 MBJudgeable
Hangar HurdlesGiven an n by n grid of blocked and empty cells, answer q queries asking for the largest centered square crate that can slide between two empty cells.Hard9Union-findBFS+2No attempts yet8s512 MBJudgeable
NPM998244353 (Hard)For every digit-sum cap from 0 to MM, count length-N digit strings divisible by P, modulo 998244353.Hard9CombinatoricsDynamic programming+2No attempts yet5s512 MBJudgeable
Counting multiples with a bounded digit sumCount length-N digit strings divisible by P with digit sum at most M, for every M up to the limit, modulo 998244353.Hard9Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Blocks 2Count the ways to tile an N x M rectangle with rotated k x N blocks (k=1..N), modulo 1999, where M can be as large as 10^10.Hard9CombinatoricsDynamic programming+2No attempts yet1s256 MBJudgeable
Colored Tiles 2Place given 1x1 and 1x2 tiles on an H by W board without overlap to maximize the total score of edges between neighboring tiles, then output every tile's coordinates.Hard9Dynamic programmingImplementation+2No attempts yet1s512 MBJudgeable
MessageCount length-n lowercase strings that contain a given pattern p as a substring, modulo m, where n can reach 10^12 and p has length at most 50.Hard9Dynamic programmingString matching+2No attempts yet5s512 MBJudgeable
Sum of Equivalent Resistances Between Every Pair of Vertices Joined by an Edge, Given a Connected Graph with Unit Resistance EdgesGiven a connected unit-resistance graph, compute the sum of effective resistances over all m edges, using the fact that each equals the probability a random walk crosses that edge in the commute.Hard9GraphMatrix+2No attempts yet1s512 MBJudgeable
Working CellsGiven T periodic N-vertex weighted digraphs, count modulo 1e9+7 the number of D-step walks from every hub i to every hub j.Hard9MatrixDivide and conquer+2No attempts yet1s512 MBJudgeable
Chessboard MovementCount paths from row 1 to row N on an N x M chessboard where odd rows restrict moves to same-colored adjacent cells and even rows allow any adjacent move, modulo 1e9+7.Hard9Dynamic programmingMatrix+2No attempts yet2s512 MBJudgeable
Good Word, Bad WordBacteria on an N by N grid can step to an orthogonal neighbor for cost a, or jump up to Chebyshev distance D from a good cell for cost b; for each meeting cell find the total minimum cost for all bacteria to reach it.Hard9Shortest pathGraph+2No attempts yet2.5s1024 MBJudgeable
Modulo-magic squaresCount n x n matrices over Z_m whose row, column, and two diagonal sums are all congruent to one constant, for n and m up to 1e9.Hard9MathCombinatorics+2No attempts yet1s512 MBJudgeable
Matrix and QueriesGiven an N x N integer matrix and Q values x, output det(A - xI) mod 998244353 for each query.Hard9MathMatrix+2No attempts yet5s512 MBJudgeable