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 results6,365 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Low Range-Sum MatrixFlip signs of at most K cells in an N by M matrix (both at most 10) so that no horizontal or vertical contiguous segment sums to more than S.Hard9Brute forceDynamic programming+2No attempts yet2s512 MBJudgeable
Magic TrianglesGiven up to 100000 counter-clockwise triangles, compute the area of their common intersection.Hard9GeometryDivide and conquer+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
Africa 2Submit code that matches the judge on exactly half its hidden test cases while passing the sample, a problem about exploiting judge behavior rather than a computable answer.Hard9ImplementationBrute force+2No attempts yet1.357s1357 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
ValleysGiven an N x N grid of distinct heights, sum the sizes of all non-holey edgewise-contiguous regions whose cells are strictly lower than every orthogonally adjacent border cell.Hard9Union-findGraph+2No attempts yet2s512 MBJudgeable
Maintaining a SequenceMaintain a sequence under insert, delete, range assign, reverse, range sum, and global maximum subarray queries.Hard9Dynamic programmingImplementation+2No attempts yet2s256 MBJudgeable
Parameterized Pattern MatchingFind every substring of text T that p-matches pattern P, where parameter names must correspond under a bijection and tokens match exactly.Hard9StringString matching+2No attempts yetNot set16 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
CalculatorStarting from X=0, reach a given N by pressing +2, -2, *2, /2 (floor) at most 99 times while X stays in [0, 2^63-1], or report that it is impossible.Hard9Binary searchMath+2No attempts yet1s256 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
Two TransportationsTwo programs, each holding one set of weighted edges, exchange at most 58000 bits to compute single-source shortest path distances from city 0 in the union graph.Hard9Shortest pathGraph+2No attempts yet10s256 MBJudgeable
CandiesFor each j, find the maximum sum of j non-adjacent values chosen from N candies in a row.Hard9Dynamic programmingGreedy+2No attempts yet5s512 MBJudgeable
CityAssign small integer codes to nodes of a tree where depth from node 0 is at most 18, so that a decoder with only the two codes can tell which of two cities lies on the path from 0 to the other.Hard9TreeBit manipulation+2No attempts yet2s512 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
MessengerDesign strategies for two players who alternately move a piece on a 4x4 grid, knowing neither the call order nor its timing, so B can deduce the secret value X within 10000 moves.Hard9ImplementationSimulation+2No attempts yet2s512 MBJudgeable
DivModuloCompute C(M,N) after removing every factor of D, and report the remainder modulo D, for M up to 4e18 and D up to 1.6e7.Hard9MathNumber theory+2No attempts yet3s1024 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
Six WordsGiven a connected graph whose vertex i has potential i and edge i has weight i, find the total weight of a minimum spanning tree of the line graph of the line graph.Hard9GraphMinimum spanning tree+2No attempts yet2s512 MBJudgeable
Um_nik's AlgorithmGiven an undirected bipartite graph with up to 2e6 vertices and edges per side, output a matching whose size is at least 0.95 times the maximum matching size, with heavy constant-factor optimization required.Hard9GraphGreedy+2No attempts yet4s512 MBJudgeable
FFT AlgorithmGiven m and k, find a primitive 2^k-th root of unity modulo m, or report that none exists.Hard9Number theoryMath+2No attempts yet1.5s512 MBJudgeable
Bracket Euler TourFind an Euler tour of an undirected graph whose vertex bracket labels, read in traversal order, form a correct bracket sequence, or report that none exists.Hard9GraphDFS+2No attempts yet2s512 MBJudgeable
One RootCount pairs (p, q) with |p|, |q| <= m for which x^n + px + q has exactly one real root.Hard9MathNumber theory+2No attempts yet2s512 MBJudgeable
Another Coin Weighing PuzzleGiven m weighings and k coins per bag, find the maximum number of bags whose unique heavy bag can be identified, modulo 998244353.Hard9CombinatoricsMath+2No attempts yet1s512 MBJudgeable
Counting Edit DistancesCount the number of distinct strings over 'A' to 'Z' whose Levenshtein distance from a given string s is exactly d, modulo 998244353.Hard9Dynamic programmingString+2No attempts yet10s512 MBJudgeable
Basis ChangeGiven one linear recurrence with coefficients a_i, find the unique recurrence with prescribed lags b_i that every sequence satisfying the first also satisfies.Hard9MathImplementation+2No attempts yet2s512 MBJudgeable
Long GamePlayers alternately cut a strip of a permutation while every cut must leave at least one strip containing an inversion; decide the winner with optimal play.Hard9Game theoryGreedy+2No attempts yet1s512 MBJudgeable
FarawayCount lattice points (xe, ye) in [0, m]^2 such that for each of up to 10 constraints, (|xi - xe| + |yi - ye|) mod ki equals ti, with ki at most 5 and m up to 1e9.Hard9MathNumber theory+2No attempts yet1s512 MBJudgeable
Decimal ExpansionFor each query n up to 10^18, find the n-th digit after the decimal point of the infinite product (9/10)(99/100)(999/1000)...Hard9MathNumber theory+2No attempts yet1s512 MBJudgeable
Linear Congruential GeneratorGiven a linear congruential generator and two index ranges, sum X_i mod (X_j+1) over all pairs i in the first range and j in the second.Hard9MathNumber theory+2No attempts yet2s512 MBJudgeable
IneqGiven a finite set S of integer lattice points, decide whether S can be cut out as exactly the integer points lying strictly below every line of some finite family of half-planes.Hard9GeometryMath+2No attempts yet2s512 MBJudgeable
Delightful (Hard)Write a program of at most 5000 commands for a ternary computer with 26 forty-trit registers that sets Y to 1 if the input X (0 to 109) is prime and 0 otherwise.Hard9Number theoryImplementation+2No attempts yet1s512 MBJudgeable
Xorshift32Given a starting value x and a target t, find the index at which t first appears in the Xorshift32 pseudorandom sequence.Hard9MathBit manipulation+2No attempts yet1s256 MBJudgeable
814 - 2Print an 8 by 14 grid of digits so that every number from 1 up to some X can be traced as an adjacent-cell path, maximizing X.Hard9GraphDFS+2No attempts yet0.814s814 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
Nonogram QRSolve a chain of 2000 nonograms to reconstruct QR codes, decode them, follow indicator links, and recover a flag.Hard9BacktrackingSimulation+2No attempts yet1s512 MBJudgeable
CerealGiven a queue of cows each with a favorite and second-favorite cereal, report for every prefix removal how many cows still get a box.Hard9GreedySimulation+2No attempts yet1s512 MBJudgeable
Integer Equation CheckerClassify an equation string as correct, format error, math error, or a typo fixable by replacing at most two characters with a valid correct equation.Hard9Brute forceImplementation+2No attempts yet1s512 MBJudgeable
Yet Another Problem on EmpodiaCount, for each length i up to N, the number of equivalence classes of permutations of length i under the relation that agrees on which intervals are framed (max minus min equals length minus one), modulo a prime.Hard9CombinatoricsDynamic programming+2No attempts yet2s512 MBJudgeable
Continue the SequenceGiven n values, extend the sequence by m terms so that it agrees with a polynomial of the smallest possible degree modulo 998244353.Hard9MathNumber theory+2No attempts yet4s256 MBJudgeable
AdditionDesign a short string-rewriting script in a custom language that reads two binary numbers joined by + and rewrites them into their binary sum.Hard9String matchingSimulation+2No attempts yet1s256 MBJudgeable
Array ChallengeGiven a linear recurrence h and closed-form arrays b and a, compute floor(sqrt(a_n)) modulo 1e9+7 for n up to 1e15.Hard9MathNumber theory+2No attempts yet1s512 MBJudgeable
Master Zhu and Magic NumbersGiven sparse positions of ones in a triangular binary layout, simulate a bitwise dependency program to get values b_j, then answer queries asking for the popcount of ORs of selected b_j.Hard9Bit manipulationImplementation+2No attempts yet1s512 MBJudgeable
Master Zhu and CandiesGiven n candy heaps, players may remove any positive number from one heap or split one heap into three non-empty heaps; decide the winner under optimal play.Hard9Game theoryMath+2No attempts yet3s512 MBJudgeable
Master Zhu and RootFor each query (x, y), find the smallest k >= 0 with x^k congruent to y modulo some prime divisor p of n, or report -1.Hard9Number theoryMath+2No attempts yet3s512 MBJudgeable
Flip a CoinTwo players each pick a heads/tails string of length up to 20; a fair coin is flipped until one or both strings appear, and we must output the probabilities of Alice winning, Bob winning, and a tie.Hard9ProbabilityDynamic programming+2No attempts yet1s256 MBJudgeable
K-th StringCount permutations t of n distinct letters whose k-th smallest non-empty substring equals s, modulo 1e9+7.Hard9StringCombinatorics+2No attempts yet1s256 MBJudgeable
Ascent Sequences Avoiding Pattern 201Count ascent sequences of length n that avoid the pattern 201, modulo a prime p, with n up to 500.Hard9Dynamic programmingCombinatorics+2No attempts yet2s512 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
Navigation GameConstruct a 100x100 arrangement of the numbers 1 to 10000 that maximizes a navigation score, where jumps off the current row or column cost points.Hard9GreedyImplementation+2No attempts yet1s256 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
Holy cow, Vim! (Easy)Construct a stack-language program that outputs x, but outputs 2x when its lines are reversed and -x when its lines are sorted lexicographically.Hard9ImplementationSimulation+2No attempts yet1s512 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
The Potion of Great PowerGiven a graph whose edges change once per day with degree at most D, answer queries online for the minimum altitude difference between a neighbor of x and a neighbor of y on a given day.Hard9GraphSorting+2No attempts yet3s256 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
Fermat's Last TheoremOrder all positive quadruples (a,b,c,n) with n>=3 by max element then lexicographically, and print the sign of a^n+b^n compared to c^n for positions l through r.Hard9MathCombinatorics+2No attempts yet2s512 MBJudgeable
Coalescing ContinentsGiven K rectangles with total area 25 on a 20x20 grid, decide if they can be translated to tile a square, and find the minimum total moves.Hard10Brute forceMath+2No attempts yet1s128 MBJudgeable
GeneratorRead an index 0 to 10 and output the exact contents of the matching recovered file gen_i.out from the archive.Hard10ImplementationString+2No attempts yet2s256 MBJudgeable
LogoGiven up to five polyomino patch shapes (each a subset of a 3x3 grid, flippable and rotatable) and up to three grid designs up to 55x5, decide if each design can be tiled exactly by non-overlapping patches and find the minimum patch count, or report NIE.Hard10Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
String Palindrome QueriesMaintain a lowercase string under block moves, reversals, and single-character insertions, answering after each change whether a given substring reads the same forwards and backwards.Hard10StringString matching+1No attempts yet2s256 MBJudgeable
RobotsDesign two robots' instruction tables so they classify a binary string as fine or coarse from its middle third's A and B counts, using four-bit memories, exact-then-wildcard dispatch, and 1000n steps.Hard10ImplementationBit manipulation+2No attempts yet2s512 MBJudgeable
Natural ParkReconstruct the exact edge set of a sparse connected graph with degree at most 7 using at most 45,000 connectivity queries over chosen subsets.Hard10GraphBFS+2No attempts yet2s512 MBJudgeable
Dungeon 2Explore an unknown connected graph through a move-and-color oracle and report, for each i, how many room pairs have shortest-path distance exactly i.Hard10GraphBFS+2No attempts yet1s256 MBJudgeable
Shadow CompanionConstruct a fixed program over a bit tape with a shadow that transforms every input n < 2^10 into n squared.Hard10SimulationBit manipulation+2No attempts yet2s512 MBJudgeable
Delightful (Easy)Write a program of at most 100 commands for a ternary computer with 26 40-trit registers that computes the length of the longest non-decreasing prefix of the input in register X and leaves the answer in Y.Hard10ImplementationSimulation+2No attempts yet1s512 MBJudgeable