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 results3,705 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| The Great Spamway StrikeChoose a rooted tree over zombies with allowed bidirectional links, minimizing the round-trip time for a gather broadcast that includes each node's per-message read lag. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SegmentsOn each row of an n by n grid you must walk the whole interval [L(i), R(i)], moving only left, right, or down; find the shortest path from (1,1) to (n,n). | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Hockey ScoresGiven unordered score pairs x-y, find the fewest monotone lattice paths from (0,0) that pass through all of them, since each hockey game is such a path. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cheap GasOn an m by n grid with a fuel tank of capacity f, find the cheapest way to buy gas at priced stations while driving from (1,1) to (m,n), or report that the trip is impossible. | Medium7 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pit Stop StrategyGiven lap and fuel burn formulas plus pit-stop costs, find the minimum race time for L laps without running out of fuel. | Medium7 | Dynamic programmingMath | No attempts yet | 1s | 128 MB | Judgeable |
| Snowball FightGiven fixed alternating throwing order and hit probabilities, players choose targets to maximize their team's win chance; compute win and draw probabilities under optimal play. | Medium7 | Game theoryProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Patisserie ACMGiven a hole-free connected polyomino of # cells, find the minimum number of axis-aligned rectangles whose union is exactly the shape, cutting only along grid lines. | Medium7 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Shopping OffersGiven regular item prices and bundle offers, find the minimum cost to buy exactly the listed quantities without buying extras. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Hidden CodesGiven code words and a long text, choose non-overlapping covering sequences, each at most 1000 long, maximizing the total length of the code words used. | Medium7 | Dynamic programmingString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Walk the TalkCount the number of distinct monotone paths (only right and/or up hops) through an H by W letter grid whose visited letters spell one of N given words. | Medium7 | Dynamic programmingTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Two SawmillsPlace two extra sawmills along a road so that every tree's downhill haul to the first mill at or below it is minimized. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TripGiven two strings, print all longest common subsequences in lexicographic order without duplicates. | Medium7 | Dynamic programmingBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Air RaidGiven a DAG, find the minimum number of vertex-disjoint paths that together cover every vertex. | Medium7 | GraphDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ReadingCount non-empty lowercase words whose total adjacent-letter difference is at most N, modulo 1e9+7. | Medium7 | Dynamic programmingCombinatorics | No attempts yet | 5s | 128 MB | Judgeable |
| RequestsGiven a cache of capacity K and N timed requests with expiration times, compute the minimum number of fetches over all offline replacement strategies. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sailing RaceGiven sign positions on a line, find the visiting order minimizing the sum of cumulative distances, where each next sign adds the distance from the previous sign. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Task ExecutionGiven a DAG of N unit-time tasks, find the minimum completion time with unlimited processors, then the fewest processors that still achieve it. | Medium7 | GraphTopological sort+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Restore the Expense IndentationGiven pre-order amounts where each parent equals the sum of its immediate children, recover the lexicographically smallest 0-based indentation depth for every line. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Multi-Element Binary Search TreeGiven sorted search probabilities and level-dependent node capacities, find the minimum expected number of comparisons for a multi-element BST. | Medium7 | Dynamic programmingTree+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| RallyChoose a subset of at most 25 stations and fuel amounts to minimize total driving time plus refueling stops. | Medium7 | Dynamic programmingImplementation+1 | No attempts yet | 6s | 128 MB | Judgeable |
| Changing DigitsFind the largest number reachable from N by changing one digit at a time so that each new value's remainder modulo M strictly increases. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| Swimming CompetitionGroup N swimmer times into consecutive sorted blocks of size between A and B, minimizing the largest within-group time difference. | Medium7 | SortingDynamic programming+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| IOI PhotosEach order lists photo ranges on named rolls; choose for every roll to print individually, print the whole roll, or buy all rolls, minimizing total cost. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| An Old Stone GameFor each of up to 10 general trees, compute the minimum number of stones needed so that starting from the bucket you can place a stone on the root by combining stones at fully occupied siblings. | Medium7 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PipesGiven a grid of modules with costs on interior walls, find the minimum-cost cycle that visits every module exactly once, starting and ending at the service module. | Medium7 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Minimax TriangulationFind the triangulation of a simple polygon minimizing the largest triangle's area, and report that area. | Medium7 | Dynamic programmingGeometry+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Team Them UpSplit N people into two teams where teammates must mutually know each other, minimizing the size difference, and report the two team sizes. | Medium7 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Shortest Regular Brackets SequenceGiven a string of brackets, find the length of the shortest regular bracket sequence that contains it as a subsequence. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GangstersChoose a door state over time that changes by at most 1 per unit, starting at 0, to maximize the prosperity of gangsters whose stoutness matches the state at their arrival time. | Medium7 | Dynamic programmingSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Collecting BugsFind the expected number of days until a stream of random (category, subsystem) pairs has covered all n categories and all s subsystems. | Medium7 | Dynamic programmingProbability+2 | No attempts yet | 2s | 64 MB | Judgeable |
| Drawing WindowsGiven the boundary of a hole-free rectilinear polygon, compute the minimum number of non-overlapping axis-aligned rectangles that exactly partition it. | Medium7 | GeometryDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Banal TicketsGiven a length-2N ticket pattern with unreadable digits, count how many fillings make the first half product equal the second half product, and how many do not. | Medium7 | CombinatoricsDynamic programming+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Longest Common Increasing SubsequenceGiven two integer sequences, find the length of the longest common increasing subsequence of both. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| The Very Greatest Common DivisorEach input value is the determinant of a tridiagonal n by n matrix with 1 on the diagonal, 1 above, -1 below; find the gcd of two such determinants. | Medium7 | Number theoryMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Dictionary of Obscene WordsGiven dictionary words and a text, find the length of the shortest prefix of the text containing some word as a subsequence. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| EscapeFind the earliest time in the window [t, t+d) that James can reach the pickup cell, moving one cell per second with no U-turns and no waiting. | Medium7 | BFSGraph+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Bargain or No BargainGiven prize values and a budget M, decide whether optimal play maximizing expected log utility yields expected prize money above M. | Medium7 | Dynamic programmingProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Boy ScoutGiven N points in general position, find the longest closed route that always turns strictly left at every step, counting distinct points visited. | Medium7 | GeometryDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Edit DistanceGiven strings A and B up to length 17000, find the minimum number of insert, delete, and substitute operations to turn A into B. | Medium7 | Dynamic programmingString | No attempts yet | 8s | 128 MB | Judgeable |
| Ball PaintingCount paint orders on a 2 by N grid where each new ball must touch an already painted ball, modulo 1e9+7. | Medium7 | Dynamic programmingCombinatorics | No attempts yet | 2s | 512 MB | Judgeable |
| Matryoshka Dolls, AgainGiven N dolls each with three dimensions, nest them so every inner doll is strictly smaller on all three axes; minimize the number of outermost dolls. | Medium7 | Dynamic programmingGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| G-Avoiding SequenceCount permutations of a set where consecutive elements never differ by a multiple of G, modulo a prime. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| RectanglesFind the longest chain of rectangles where each rectangle's upper-right corner is strictly below and left of the next rectangle's lower-left corner. | Medium7 | Dynamic programmingSorting | No attempts yet | 1s | 128 MB | Judgeable |
| Making ChangeChoose the fewest coins whose subsets can form every amount from 1 to C given bounded supplies of each denomination. | Medium7 | GreedyDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| RobotFind the shortest travel time for a robot that moves at speed 1 and turns 1 degree per second, hopping between points within distance R. | Medium7 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum Sum of K Non-Overlapping SubmatricesPick exactly K pairwise non-overlapping rectangular submatrices from an N x M matrix to maximize the sum of their elements. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 32 MB | Judgeable |
| Tree GameOn a tree, players alternately move a token to an unchosen neighbor from Manco's start vertex; find all start vertices where Manco wins with optimal play. | Medium7 | TreeGame theory+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Book-casePartition the books in alphabetical order across shelves of fixed width, allowing vertical books or horizontal stacks, to minimize total height. | Medium7 | Dynamic programmingImplementation+1 | No attempts yet | 1s | 64 MB | Judgeable |
| TriangulationGiven n and m, compute the sum of triangulation counts T_3 + ... + T_n of convex polygons, reduced modulo m. | Medium7 | CombinatoricsMath+2 | No attempts yet | 1s | 32 MB | Judgeable |
| Coloured LeavesGiven an unrooted tree whose leaves have fixed colors, choose an internal vertex as root and place the fewest labels so each leaf's color matches its last labeled vertex. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Map GeneratorGiven N planets each edge appears independently with probability P, find the probability that the resulting random graph is connected. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Map Generator Returns (MG-II)Given N places and independent edge probability P, find the probability that the random graph on N vertices is connected. | Medium7 | ProbabilityDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| B-MatrixFind two non-overlapping all-zero rectangles in a binary grid maximizing the total number of cells they cover. | Medium7 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Superstitious Skylab TowerGiven a valid floor label with no digit 4 and no substring 13, count how many forbidden numbers precede it, then multiply by the floor height. | Medium7 | MathDynamic programming | No attempts yet | 1s | 128 MB | Judgeable |
| Central TreeFor each weighted tree, find the vertex minimizing the sum of weighted distances to all other vertices and output that minimum sum. | Medium7 | TreeDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Serial NumbersGiven up to 10 forbidden digit substrings, find the b-th smallest positive integer whose decimal form contains none of them as a substring. | Medium7 | Dynamic programmingString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Texture TileGiven an N x N image, find the largest square subimage whose top row equals its bottom row and left column equals its right column. | Medium7 | Dynamic programmingHash map+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Bank NotesWith bounded supplies of each note denomination, find the fewest notes that sum exactly to k. | Medium7 | Dynamic programmingGreedy | No attempts yet | 3s | 128 MB | Judgeable |
| The BusFind a path from (1,1) to (n,m) moving only east and north that collects the maximum total of passenger weights at visited intersections. | Medium7 | Dynamic programmingSorting+1 | No attempts yet | 3s | 512 MB | Judgeable |
| SpiesGiven a functional graph where spy k shadows a_k, choose the largest subset S such that every member of S is shadowed by at least one spy outside S. | Medium7 | GraphGreedy+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Printed-Circuit BoardsGiven a series-parallel circuit described recursively, find the minimum number of connections that must be routed on the top side so every unit is reached from the top. | Medium7 | TreeDynamic programming+2 | No attempts yet | 3s | 128 MB | Judgeable |
| ParcelGiven an n by n grid of 0 (arable) and 1 (waste), find the largest all-zero rectangle and print its area. n can be up to 2000. | Medium7 | StackDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| MinusesGiven a signed sum of distinct variables, find the fewest bracket pairs needed to turn the all-minus chain into an equivalent expression. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BracketsCount the ways to fully bracket a minus chain so that the result equals a target expression with given signs, modulo 1e9. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ChainGiven which rings of a bytish chain are on a bar, find the minimum number of legal put-on/take-off moves to remove all rings. | Medium7 | Dynamic programmingRecursion+2 | No attempts yet | 3s | 512 MB | Judgeable |
| StripesGiven stripe lengths c, z, n, decide for each board length p whether the first player wins the impartial placement game. | Medium7 | Game theoryDynamic programming | No attempts yet | 3s | 512 MB | Judgeable |
| MusketeersGiven a tournament matrix on n people in a circle, determine everyone who can be the last survivor when adjacent duels are scheduled in any order. | Medium7 | Dynamic programmingGame theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MapPartition n populations into m groups to minimize the sum over each group of |value - group median|, where the median can be any value meeting the half-half condition. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 3s | 128 MB | Judgeable |
| PrimitivusGiven a set of ordered pairs, find the shortest sequence in which every pair appears consecutively at least once. | Medium7 | GraphShortest path+2 | No attempts yet | 3s | 128 MB | Judgeable |
| The Number of Symmetrical ChoicesGiven two word sequences of length n, count how many of the 2^n ways of picking one word per index produce a palindrome when concatenated. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GenotypesGiven budding rules A1 -> A2 A3, decide for each target word whether it can be derived from some number of supergenes S, and report the minimum count. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Even Palindrome DecompositionDecide whether a string can be split entirely into even-length palindromes, and if so report the minimum and maximum number of parts. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Professor SzuCount walks in a directed multigraph from each cottage to the main building, cap at 36500, and report which cottages have the most routes (or are unbounded). | Medium7 | GraphDynamic programming+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Aesthetic TextSplit a sequence of words into lines of length at most m, minimizing the total absolute difference between consecutive line lengths. | Medium7 | Dynamic programmingPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Railway NetworkGiven a connected edge-weighted graph and at most 8 terminals, find the minimum cost edge set that keeps all terminals mutually connected. | Medium7 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Great EscapeCount escape routes on an n by m grid where the driver enters at the bottom-left corner heading north, only goes straight or turns right, and never revisits an intersection. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Ticket InspectorChoose k of the n-1 travel segments so that the total number of passengers present on at least one chosen segment is maximized. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| HexerFind the shortest walk from town 1 to town n where each road can be used only after collecting swords for all monster kinds on it. | Medium7 | Shortest pathGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GuildsSplit the towns into two sets so that each set is a dominating set and the sets are disjoint, or decide it is impossible. | Medium7 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MonotonicityFind the longest subsequence of a sequence whose adjacent comparison symbols repeat a given pattern of <, >, = of length k. | Medium7 | Dynamic programmingBinary search+2 | No attempts yet | 3s | 512 MB | Judgeable |
| The Minima GameTwo players alternately take any positive number of cards and score the minimum value in the taken set; find the optimal final score difference for the first player. | Medium7 | GreedySorting+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Letter Frequency DifferencePick any contiguous fragment of a lowercase word to maximize the gap between its most and least frequent letters. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree RotationsGiven a binary tree with distinct leaf labels, find the minimum number of inversions in the left-to-right leaf sequence reachable by swapping children at branchings. | Medium7 | Divide and conquerDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CloakroomFor each query (m, k, s), decide whether some items with a_i <= m and b_i > m+s have values summing to exactly k. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Around the WorldFind the cheapest closed walk from city 1 whose total eastward longitude differs from its westward longitude. | Medium7 | GraphShortest path+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Winter Snow PlowingOn a tree, each edge must be traversed at least d_i times by one continuous walk; find the minimum total traversal count. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Alien InvasionFind the maximum total residents the aliens can abduct, given that a warning from an attacked city reaches city k one day later per unit distance. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| OrchardGiven an n by n grid of trees and empty cells, decide whether the whole grid can be split into exactly k axis-aligned rectangles, each containing at least one tree. | Medium7 | Divide and conquerDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ClimbingEach of n pairs of climbers sits on adjacent routes with two positions a and b; maximize the number of adjacent climbers (across neighboring routes) that can share the same height under the rope constraints. | Medium7 | Dynamic programmingGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Squared WordsGiven a lowercase string, delete the fewest letters so the remaining letters, in order, form a squared word xx. | Medium7 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| Bytie's DisplayReorder the digits of a seven-segment display and flip at most n segments so the result reads as the lexicographically largest l-digit number. | Medium7 | GreedyDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Variable SubsequencesCount distinct nonempty subsequences, identified by position sets, in which every two consecutive terms differ. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| DiceGiven n and k, find the number of ways n fair dice can sum to k, then output the integer part of 100 times that probability. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Type Two de Bruijn SequencesGiven a binary string, append the fewest digits so that every length-n binary word appears as a subsequence. | Medium7 | GreedyString+1 | No attempts yet | 2s | 512 MB | Judgeable |
| StudiesGiven a directed graph with edge weights, find every vertex that lies on a closed walk of positive total weight. | Medium7 | GraphShortest path+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PotatoA convex polygon loses one piece per straight cut; maximize the remaining area after at most k cuts while removing every original rind point. | Medium7 | GeometryDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BarricadesOn a tree, for each size k find the minimum number of edges to cut so that some connected component has exactly k vertices and no edges leave it. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SunsetsFor each cell of an n x n grid, output the tallest height among all cells within Manhattan distance k. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| WordsGiven a word of length n, find the smallest number of blocks in a word that differs from it in at most k positions. | Medium7 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| AntCount walks of exactly k edges from one cube vertex to another, never reusing the edge just used, modulo p. | Medium7 | MatrixDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |