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,373 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Interleaved Periodic StringGiven a binary string S, find the minimum total length of two binary strings whose repeated copies can be interleaved to produce S. | Hard8 | Brute forceDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| NM and K (1)Choose exactly K non-adjacent cells from an N by M grid, at most 10 by 10, to maximize the sum of their values. | Hard8 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| NM and K (2)Choose exactly K non-adjacent cells from an N by M grid, each with a value, to maximize the total sum. | Hard8 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Bird WatchingGiven a digraph P known to contain the true edge set G plus some path-shortcut edges, list all in-neighbors a of T such that every path from a to T uses the edge (a, T). | Hard8 | GraphDFS+2 | No attempts yet | 3s | 512 MB | Judgeable |
| SealGiven a binary document grid and a binary seal stamp, decide whether the document is exactly the union of non-overlapping (and non-rotated) placements of the stamp. | Hard8 | ImplementationSimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| VisitsGiven a tree, a visiting order, fuel prices, and tank capacities, compute the refueling cost of each trip in the order. | Hard8 | TreePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Collecting Stamps 3On a circular lake, N stamps sit at given positions with individual collection deadlines; find the maximum number of stamps JOI-kun can collect starting from position 0. | Hard8 | Dynamic programmingIntervals+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Farm of MonstersYou and a fixed greedy opponent alternate attacking monsters; you choose targets to maximize the number of monsters you personally kill. | Hard8 | GreedySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Face Recognition AlgorithmGiven a planar straight-line embedding of a connected graph, decide whether every face, including the outer one, is bounded by exactly three edges. | Hard8 | GeometryGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Euclid's AlgorithmGiven d and k, find the largest integer that divides (a+d)^k - a^k for every positive integer a. | Hard8 | Number theoryMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Segment treeSorting+2 | No attempts yet | 3s | 512 MB | Judgeable |
| ProgramGiven a sequence of assignment and conditional assignment instructions starting from X=1, delete the fewest instructions so the final value is k, for every k. | Hard8 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Game XGiven n and k, decide whether exactly k pairs of nonzero, distinct-magnitude integers can have positive sum, and if so maximize the number of pairs whose product is positive. | Hard8 | MathGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Segment treeImplementation+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Cake DistributionChoose up to 5000 positive integer cake pieces so that for each of A, B, C guests they can be split evenly, labeling each piece with its recipient for each case. | Hard8 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Union-findSimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ChallengeConstruct a tree with at most n vertices whose recursive center-removal decomposition puts some vertex in at least floor(sqrt(n)) different pieces. | Hard8 | TreeGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| BaklawaGiven a huge cuboid with up to 100 poisonous unit cells, players alternate cutting off a safe cuboid half; decide who wins under optimal play. | Hard8 | Game theoryGeometry+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Exciting MenusGiven N strings with a joy value per position, maximize over all substrings the product of its length, the joy at its end, and the number of strings having it as a prefix. | Hard8 | TrieString+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Invited SpeakersGiven n red and n blue points in the plane with distinct x and y coordinates and no three collinear, draw n disjoint polygonal chains pairing each red point with a blue point. | Hard8 | GeometryGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Help Yourself (Gold)Sum the number of connected regions in the union of segments over all 2^N subsets, modulo 1e9+7. | Hard8 | CombinatoricsSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| O Life of My YouthGiven N pairs of happiness and fatigue with some values missing (0), find the largest K < N such that all young-day pairs can exceed all old-day pairs in happiness and stay below them in fatigue. | Hard8 | SortingGreedy+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| HaircutFor each threshold j from 0 to N-1, clip every value above j down to j and count the resulting inversions. | Hard8 | SortingPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Printer's HeadGiven a permutation of heights 1..n to print in order, find the minimum number of left-to-right or right-to-left sweeps, where each sweep prints positions in order with heights dropping by 1. | Hard8 | GreedyDynamic programming+1 | No attempts yet | 1.5s | 64 MB | Judgeable |
| PasswordsGiven n rows of m letters, permute the columns so the rows become lexicographically nondecreasing, choosing the smallest such permutation or reporting NIE. | Hard8 | GreedySorting+2 | No attempts yet | 1.5s | 64 MB | Judgeable |
| Hidden GraphFind a hidden undirected graph on n vertices, where every induced subgraph has a vertex of degree at most k, using at most 2nk+n independence queries that return an edge when the set is not independent. | Hard8 | GraphDivide and conquer+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Tree HullMaintain a set of tree vertices under insertions and deletions, and after each query report the total edge weight of the minimal subtree spanning the current set. | Hard8 | TreeDFS+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Bag of BagsProcess bags one by one; keep a bag unless its equality class merges two classes that were already equal, and report the decision for each. | Hard8 | IntervalsUnion-find+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Exact ArithmeticSimulate a stack calculator whose values are sums of rationals and rational multiples of square roots, and print each result in a canonical exact form. | Hard8 | ImplementationMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Oleg and Data ScienceCount positive integers X such that ((S mod Q) mod X) equals (S mod X) for every S in [L, R], or report infinity. | Hard8 | Number theoryMath+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Christmas GarlandGiven a garland of n bulbs with colors, each query flips the state of every bulb of one color, and after each flip you report the number of maximal lit segments. | Hard8 | ArrayImplementation+2 | No attempts yet | 2s | 256 MB | Judgeable |
| FaintSum the absolute differences between consecutive rows of a fixed column in the lexicographically ordered list of k-subsets of {1,...,n}, modulo 1e9+7. | Hard8 | CombinatoricsMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Segment treeSorting+2 | No attempts yet | 0.5s | 256 MB | Judgeable |
| Hotter-colderAn interactive problem: locate a hidden point in a d-dimensional integer grid using at most 100d queries that only report whether the latest Chebyshev distance got smaller or larger. | Hard8 | Binary searchImplementation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| PrimesAnswer online queries that ask for the sum of shared distinct prime counts over all pairs in a range [a, b] up to 10^6. | Hard8 | Number theoryPrefix sum+2 | No attempts yet | 8s | 256 MB | Judgeable |
| SchedulingDecide whether n preemptible tasks with release times, deadlines, and processing times can be scheduled on m identical processors within their windows. | Hard8 | GreedySorting+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 2x+2Given n up to 10^100, choose the largest subset of {1,...,n} with no x and 2x+2 both present. | Hard8 | MathGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Simple PolygonGiven a perimeter l and area s, construct a simple rectilinear polygon with exactly that perimeter and area, or report that none exists. | Hard8 | GeometryMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| GaloisGiven a permutation p, count permutations q with p(q(i)) = q(p(i)) for all i, that have an even number of inversions, modulo 1e9+7. | Hard8 | CombinatoricsMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Segment treeMatrix+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Yet Another Problem About PermutationsGiven a permutation, write it as a product of the fewest simple permutations, where each simple permutation has only cycles of length one or two, and output one optimal factorization. | Hard8 | CombinatoricsGreedy+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Teenage SharkSimulate a 4x4 board where numbered fish rotate and swap, and a shark moves along its direction eating fish; find the maximum total value eaten. | Hard8 | SimulationBacktracking+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Game of ChairsChoose a starting chair to minimize the expected distance to the nearest chair of a uniformly random color, and output the expectation as a reduced fraction. | Hard8 | MathPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ADD, DIV, MAXMaintain an array under range add, range floor-divide, and range maximum queries, with N and Q up to 200000. | Hard8 | Segment treeLinked list+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Piecewise LinearityDecide whether a piecewise linear function given by n+1 increasing x-coordinates can be written as a real linear combination of absolute value terms |x - a_i|. | Hard8 | MathGeometry+1 | No attempts yet | 1s | 512 MB | Judgeable |
| AftermathGiven the integer arithmetic mean a and integer harmonic mean h of the divisors of an unknown n up to 10^15, recover any valid n. | Hard8 | Number theoryMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| The Catcher in the RyeGiven a rectangle split into three vertical strips with different travel speeds, find the fastest route from the bottom-left to the top-right corner. | Hard8 | GeometryBinary search+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Edge-Disjoint Spanning TreesGiven N and K, output K edge-disjoint spanning trees of the complete graph on N vertices, or -1 if impossible. | Hard8 | GraphGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | Binary searchSegment tree+2 | No attempts yet | 3s | 512 MB | Judgeable |
| ImmigrationPeter moves along the x-axis while tracking an object whose velocity changes n times; find the maximum absolute angular speed of his gaze from time t0 onward. | Hard8 | GeometryMath+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Array and OperationsMaintain an array under range add, range floor-square-root, and range sum queries, printing each sum. | Hard8 | Segment treeBinary search+2 | No attempts yet | 1s | 512 MB | Judgeable |
| ChampionshipsFind the largest set S of vertices such that the induced subgraph on S is connected and every vertex in S has degree at least d within S. | Hard8 | GraphGreedy+2 | No attempts yet | 1.5s | 256 MB | Judgeable |
| Taking ItemsEach item may require others first, cycles mean all-or-nothing; pick a feasible set of items maximizing total mood change. | Hard8 | GraphDynamic programming+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Internet ProblemGiven a directed graph, find all vertices lying on every walk from 1 to n, and only on walks from 1 to n, so a walk passes through each chosen vertex exactly once. | Hard8 | GraphDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Cash GapGiven payments with allowed day ranges, decide whether some placement and ordering of the payments forces the balance below zero. | Hard8 | GreedySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Jet TrainsMaintain a growing friendship graph and a growing train-route graph; each query asks how many friends of v lie in v's current connected component. | Hard8 | Union-findGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Flexible SegmentsFor each n up to 10000, decide whether some n consecutive positive integers admit a +1/-1 choice per element preserving the product, and output the start and signs. | Hard8 | Number theoryMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Counting in the OrderEach soldier looks left or right and sees past people no taller than the target; count how many soldiers each one sees. | Hard8 | StackArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Right-hand obstructionCars arrive in four queues at a crossroad; a front car passes only if the queue on its right is empty, so simulate second by second and report each car's crossing time or -1. | Hard8 | SimulationQueue+2 | No attempts yet | 1s | 512 MB | Judgeable |
| A Strange ExhibitGiven the inversion counts of every window of length k in an unknown permutation of 1..n, reconstruct any valid permutation. | Hard8 | ImplementationGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Planet NineDecide whether a register can go from a to b using operations that add 9x and operations that delete leading digits, all of which are 1. | Hard8 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Similar ArraysGiven pairs of positions, decide whether there is an array with all distinct values and an array with a repeated value that agree on every listed comparison, and output both arrays. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Equal MaximumsCount quadruples of indices i<=j<k<=l where the maximum of a[i..j] equals the maximum of a[k..l], modulo 1e9+7, for n up to 100000. | Hard8 | ArrayStack+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Segment treeString matching+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| BusSimulate bus boarding with passengers sitting in the closest free seat or standing over an occupied one, and choose Anton's seat minimizing the total time someone stands over him. | Hard8 | SimulationGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Good NumbersGiven a set S of forbidden integers, rank positive integers by how many good intervals (ranges containing only non-S values) contain each one, then print the first n. | Hard9 | CombinatoricsMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Folded Paper PaintingSimulate K rounds of folding a W by H rectangle along a vertical line and several horizontal folds, painting one rectangle each round through all layers, and report the unpainted area at the end. | Hard9 | GeometrySimulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Robot ArmGiven a rectilinear factory polygon and five candidate fixed points, decide for each whether an L-shaped two-segment robot arm confined to the polygon can reach every interior point. | Hard9 | GeometryIntervals+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Paper FoldingGiven a colored paper strip, determine the sequence of folds that minimizes final length while respecting a color-matching constraint on folded layers. | Hard9 | SimulationGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Gates of LogicParse an ASCII-art diagram of logic gates and wires with grid tracing rules (junctions, crossings, negation, ports) and compute values propagated to every named output. | Hard9 | SimulationGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| K’ak’-u-pakal and the Maya ScriptParse a recursive grammar for Maya glyph compositions and render a minimal-size ASCII-art box layout respecting horizontal/vertical grouping and bracket-doubling size rules. | Hard9 | RecursionString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TantrixSimulate the hexagonal tile game Tantrix and count all legal placements of hand tiles given complex forced-space and controlled-side rules. | Hard9 | SimulationGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cubic ColoniesGiven a 3x3x3 arrangement of unit cubic blocks (some missing) and two surface points, compute the length of the shortest path on the colony's outer surface between them, allowing passage through zero-width edge or vertex gaps. | Hard9 | GeometryGraph+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Origami Through-HoleSimulate repeated paper folds with layered segments and reflection/overlap propagation rules, then count how many layers a pin punch pierces. | Hard9 | GeometrySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Crossing PrismsCompute the surface area of the solid formed by intersecting two identical prisms (one along the x-axis, one along the y-axis) whose cross section is a given simple polygon. | Hard9 | GeometryMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Brainf**k InterpreterDecide whether a given Brainfuck program halts on its input and, if it loops, report the matching bracket pair that encloses the infinite loop. | Hard9 | SimulationImplementation+2 | No attempts yet | 7s | 128 MB | Judgeable |
| OutsourcingGiven two directed labeled graphs (factories) with start and final nodes, decide whether the two sets of label sequences realizable as paths from start to final are identical. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Museum GuardsAssign each guard repeating daily intervals on half-hour boundaries within their availability and minute limits so the minimum number of guards on duty is maximized. | Hard9 | Binary searchGreedy+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Asteroid RangersGiven n moving points, count how many times the minimum spanning tree over all future times changes, plus the initial build. | Hard9 | Minimum spanning treeGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Affine MessGiven three integer start points and three integer end points, decide whether a snapped integer rotation, integer scaling, and integer translation map one set onto the other, and if so whether all such maps agree on the whole plane. | Hard9 | GeometryMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Cubic RubeGiven two connected 5x5 height maps of unit cubes, decide whether the pieces can be rotated and translated in 3D to assemble a full 5x5x5 cube. | Hard9 | ImplementationGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A to Z NumeralsConvert each positive integer up to 7e17 into its unique A to Z numeral, where letters a to r and A to R stand for powers of ten and their quintuples. | Hard9 | GreedyMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GuardPlace g guards on segments so every valuable point is seen, minimizing the largest value-times-distance risk, or report too few guards. | Hard9 | GeometryBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Triangle CutsGiven a large triangle and four small triangles as angle triples in clockwise order, decide whether three straight cuts can produce exactly those four pieces. | Hard9 | GeometrySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PotholesPlace a straight rope across a rectangular lot without crossing any pothole so the total pothole area is split as evenly as possible, with tie-breaking rules. | Hard9 | GeometrySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Planning Rolling BlackoutsPartition an h by w grid by recursive guillotine cuts so that the heaviest set of groups left powered stays within capacity, maximizing the group count and then the reserve. | Hard9 | Dynamic programmingPrefix sum+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Twirl AroundA bar inside a simple polygon rotates clockwise, pivoting on the wall whenever a new contact point appears; report the final position of one end, or the position when it jams. | Hard9 | GeometrySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| KindergartenSplit n students into three classes so nobody keeps their old teacher and every classmate sits in each other's top T, minimizing T. | Hard9 | GraphBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Floor BricksCover a column-height profile of a bare floor with rotated 3x3 polyomino bricks of given prices, minimizing total cost. | Hard9 | Dynamic programmingImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ASCII ArtRender triangles with ASCII characters, projecting 3D vertices through a camera onto an S by S screen grid with depth-based visibility. | Hard9 | GeometryImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Giant CoverGiven axis-aligned boxes on a rectangular campus, find the minimum surface area of a convex solid above the ground that covers all boxes and is anchored to the campus boundary. | Hard9 | GeometryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TablesCount the tilings of a polyiamond on a triangular grid by isosceles trapezoids made of three unit triangles, given the shape's boundary as a sequence of grid nodes. | Hard9 | Dynamic programmingGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Farmer JohnGiven start, goal, and up to 100 disjoint line-segment fences, find the shortest path that cannot cross any fence, touching allowed, and print the length to six decimals. | Hard9 | GeometryGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ArcheryPlace Seungwon into one of 2N gaps so that after R tournament rounds his final target number is minimized, breaking ties by the largest starting target. | Hard9 | MathSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TeleportersPlace up to M new teleporters between given endpoints so the forced eastward walk triggers as many teleports as possible. | Hard9 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Success Probability of the Card-Pile GameGiven n decks of k cards each shuffled into n piles, find the probability that the follow-the-number drawing game succeeds within m restarts, printed to r decimals. | Hard9 | ProbabilityCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Version-Controlled IDEMaintain a versioned text buffer under insert and delete operations, answering substring queries against any past version, with all commands encoded by a running counter. | Hard9 | TreeImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Apparent Twin PrimesFor each query (n, t), find the smallest n-digit p such that neither p nor p+2 has a prime factor at most t. | Hard9 | Number theoryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Synnerg LifeformGiven rewriting rules that merge adjacent synnergs with multiplicative lifetimes, find all maximum-lifetime synnergs obtainable by fully unifying some contiguous block of each input sequence. | Hard9 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ballroom LightsGiven point lightbulbs and disjoint circular columns inside a rectangle, compute the total length of the wall perimeter that some lightbulb can reach with a straight, unblocked ray. | Hard9 | GeometryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |