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,698 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Nap TimePick exactly B of N intervals arranged in a circle, maximizing sum of chosen values where the first interval of each consecutive block scores zero.Hard8Dynamic programmingGreedy+1No attempts yet2s128 MBJudgeable
Closed-Circuit SurveillanceGiven a convex polygon and a set of candidate exterior camera points with costs, find the minimum total cost of camera placements so every polygon edge is visible (strictly, not collinear) from at least one chosen camera, or report -1 if impossible.Hard8GeometryGreedy+1No attempts yet2s128 MBJudgeable
Number PairingPair adjacent grid cells whose value difference is at most T to maximize total pairing weight, which requires a general weighted matching approach exploiting the grid's bipartite structure.Hard8GraphDynamic programming+1No attempts yet2s128 MBJudgeable
MazeGiven a tree-like maze grid, compute the expected number of steps for a random depth-first exploration (choosing unvisited branches uniformly, backtracking on dead ends) to travel from entrance to exit.Hard8TreeDFS+2No attempts yet2s128 MBJudgeable
Tile GameGiven colored numbered tiles, compute the maximum score obtainable by repeatedly removing groups of at least three tiles that form a same-color numeric run or a same-number all-different-color set.Hard8Dynamic programmingCombinatorics+1No attempts yet1s512 MBJudgeable
Bicycle RaceGiven N riders each with energy E and a race of D laps, find the minimum integer number of minutes to finish, rotating who leads to share energy costs optimally.Hard8Dynamic programmingGreedy+1No attempts yet2s512 MBJudgeable
Minimum Power OperationsGiven P up to 20000, find the minimum number of multiply or divide operations using only two variables to reach x^P from x and 1.Hard8BFSDynamic programming+1No attempts yet2s128 MBJudgeable
Cheap but SimilarGiven a mineral row, decide whether equipment covering 1-3 consecutive cells can be placed to mine at least 75% of the total, and construct a valid placement if so.Hard8GreedyDynamic programming+1No attempts yet7s16 MBJudgeable
Number of TreesCount the number of rooted ordered trees whose DFS-with-repeated-parent-writes traversal string equals a given string, modulo 1e9.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
TicketsAssign seat blocks of length L to families to maximize profit, where exact preferred block gives 2, any other free block of L seats gives 1, and blocks can't overlap.Hard8Dynamic programmingGreedy+1No attempts yet2s128 MBJudgeable
Programming Language LSimulate execution of a custom esoteric language with nested loops and conditional jumps to find the maximum number of printed line executions, capping at infinity beyond 1e9.Hard8SimulationDynamic programming+1No attempts yet2s128 MBJudgeable
Six People in a CircleGiven N people and an acquaintance graph, count the number of distinct 6-cycles (arrangements around a circle up to rotation and reflection) modulo 9901.Hard8GraphCombinatorics+2No attempts yet2s128 MBJudgeable
Block StackingCount A by B height-grids with heights 0 to C that are non-increasing along both rows and columns, modulo 1e18.Hard8Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
Compressing a StringFind the minimum length of a string obtained by optimally applying nested k(S) run-length style compression to a given lowercase string of length up to 200.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
MinesweeperGiven a Minesweeper board where only border cells are revealed with numbers, determine the maximum number of mines that can be placed in the closed interior cells consistently with the border clues.Hard8Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
Jumping FencesFind a closed walk from a start point visiting exactly K points that maximizes the product of fence-jumping success probabilities over all moves, given fences that block segments between points.Hard8GraphDynamic programming+1No attempts yet2s128 MBJudgeable
Planning a TripGiven a directed graph, find the maximum number of distinct cities visitable on a walk from S to T, allowing revisits of cities and edges.Hard8GraphDFS+1No attempts yet2s128 MBJudgeable
Two SequencesPartition two sequences from the back into matched groups to minimize the total sum of products of adjusted group sums, requiring an optimized DP over prefix sums.Hard8Dynamic programmingPrefix sum+1No attempts yet2s128 MBJudgeable
Polynomial CalculatorFind the minimum number of key presses to build a given monic polynomial using a calculator that applies operations sequentially without memory.Hard8Dynamic programmingGreedy+1No attempts yet2s128 MBJudgeable
Nuclear BombSelect a subset of given segments forming a convex polygon that encloses a fixed point, minimizing total cost, or report impossibility.Hard8GeometryGraph+1No attempts yet2s128 MBJudgeable
Reducing Tree HeightGiven a weighted rooted tree, find the minimum total edge-weight reduction needed so every root-to-leaf distance is at most H.Hard8TreeDynamic programming+1No attempts yet2s128 MBJudgeable
Safe CrackingGiven N dial values that can be cyclically increased and merged when adjacent and equal, find the minimum total seconds to make all dials equal, considering rotation direction and wraparound.Hard8Dynamic programmingDivide and conquer+1No attempts yet2s128 MBJudgeable
Grid SeparatorGiven a grid graph with an initial minimal white/gray/black separator path, find the minimum size separator reachable by specific add/remove transformations.Hard8GraphDynamic programming+1No attempts yet2s128 MBJudgeable
Building Profit PlanGiven points with profits, select a subset maximizing total profit such that every chosen point sees other chosen points only in diagonal quadrant pairs (1,3) or (2,4) relative to itself.Hard8Dynamic programmingSorting+1No attempts yet2s128 MBJudgeable
Number of Expression ValuesCount the distinct values an unspaced digit/operator string can yield when each subexpression is parsed as prefix, infix, or postfix.Hard8Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Wedding ProcessionArrange all guests in a line minimizing the sum of adjacent height differences while keeping the given lion subsequence order fixed.Hard8Dynamic programmingGreedy+1No attempts yet2s128 MBJudgeable
Obstacle Course DesignCount the number of ways to arrange m distinct-height obstacles into a nested valid course whose ground-to-ground climbing difficulty equals exactly k.Hard8Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
Cutting the Stone SlabCount the number of ways to repeatedly cut an N x N stone slab with alternating horizontal/vertical straight cuts so every final piece has no impurity and exactly one crystal.Hard8Dynamic programmingRecursion+2No attempts yet2s128 MBJudgeable
Square-Substring-Free NumberGiven N up to 10^18, find the smallest number at least N whose decimal representation contains no perfect square as a substring.Hard8Dynamic programmingString matching+1No attempts yet1s1024 MBJudgeable
DriveFind a path from S to T in a weighted undirected graph minimizing extra cost incurred whenever an edge's weight falls outside the running min-max range of used edges.Hard8Shortest pathGraph+2No attempts yet2s128 MBJudgeable
Divisor Subsequence SeriesGiven N, repeatedly delete digits forming a proper divisor subsequence to build the longest possible chain, breaking ties lexicographically smallest.Hard8BacktrackingGreedy+2No attempts yet2s128 MBJudgeable
I'm a Frayed KnotGiven sequences of colored thread endpoints, count the orderings of adjacent ties that merge all threads into a single loop without prematurely closing a smaller cycle.Hard8CombinatoricsDynamic programming+1No attempts yet1s128 MBJudgeable
Drive TourFind two vertex-disjoint (except endpoints) monotonic increasing and decreasing paths between city 1 and city N that together visit the maximum number of distinct cities, and output the combined route.Hard8Dynamic programmingGraph+1No attempts yet2s128 MBJudgeable
Connecting PointsCount simple Hamiltonian polygons using all 3xN grid points with king-move adjacency, for N up to 1e9, mod 1e9.Hard8CombinatoricsDynamic programming+1No attempts yet1s128 MBJudgeable
Student GroupsPartition an ordered list of students into contiguous groups minimizing mismatches between grouping and a given friendship graph, using DP over prefix structure with an efficient cost computation.Hard8Dynamic programmingGraph+1No attempts yet1s256 MBJudgeable
Easy Group MatchingGiven a text sequence and two patterns, count group-matching positions for each pattern, then find the smallest integer n that maximizes group matches for the concatenated pattern P1·n·P2 and report that count.Hard8Dynamic programmingPrefix sum+1No attempts yet30s1536 MBJudgeable
Bulb NumberGiven wires connecting switches to bulbs where crossing wires turn bulbs off when pressed together, find the K-th smallest binary number achievable by some subset of pressed switches.Hard8Bit manipulationGreedy+2No attempts yet1s128 MBJudgeable
Tree PartitionChoose exactly K vertices in a weighted tree to minimize the total weight of edges whose endpoints share the same chosen/unchosen status, and output the chosen vertex set.Hard8Dynamic programmingTree+1No attempts yet1s128 MBJudgeable
Cargo Truck Collection RoutesGiven a tree rooted at the depot with cargo weights at nodes, plan truck trips of capacity 10 minimizing total travel distance, splitting cargo as needed, and output the routes.Hard8TreeGreedy+1No attempts yet1s128 MBJudgeable
Final Group PhotoCount the ways to fill a decreasing-width staircase of rows (back rows longer) with distinct heights so rows decrease left to right and columns decrease from back to front, essentially counting standard Young tableaux for a skew shape.Hard8CombinatoricsMath+1No attempts yet1s128 MBJudgeable
Mars Bacteria LineupGiven a repulsion matrix, choose left/right swap at every node of a complete binary tree to minimize the total sum of adjacent-pair distances in the resulting leaf permutation.Hard8Dynamic programmingTree+2No attempts yet1s128 MBJudgeable
Stack Truck DriverCount length-bounded walks from city 1 to city N in a graph where edges push or pop letters on a stack, with pops requiring a matching top element.Hard8Dynamic programmingStack+1No attempts yet3s128 MBJudgeable
Bishop DoodleSimulate two bishops on a 2N by 2N board moving K times to maximize the sum of newly-seen cells not previously visible to either bishop.Hard8Dynamic programmingSimulation+2No attempts yet1s128 MBJudgeable
I Am a Great Superstar KGiven N contestants' scores in M genres (each genre's scores listed sorted), pick K contestant-genre assignments (one genre per chosen contestant) maximizing total score, requiring a min-cost/max-flow or matroid intersection style greedy insight.Hard8GreedyGraph+1No attempts yet1s128 MBJudgeable
Black RectanglesCount unordered pairs of disjoint all-black axis-aligned rectangles (each containing at least two cells) in an up to 1000x1000 grid, modulo 10007.Hard8Prefix sumCombinatorics+1No attempts yet1s128 MBJudgeable
Buying Pancake IngredientsCount walks from node 1 back to node 1 within K minutes on a directed graph where each edge can be crossed cheaply or with a shop visit collecting a subset of 4 ingredients, requiring all four collected, using state (node, ingredient mask) matrix exponentiation over a huge K.Hard8MatrixDynamic programming+2No attempts yet1s128 MBJudgeable
Parcel DeliveryFind minimum total cell-cost to visit an ordered sequence of targets on a grid where vertical movement is restricted to the first and last columns.Hard8Shortest pathDynamic programming+1No attempts yet2s256 MBJudgeable
Watermelon Throwing GameSimulate a watermelon-throwing process over up to 1e9 periods among 20 students, where each student's throw count parity depends on watermelons received, requiring matrix exponentiation or cycle detection to compute the total thrown.Hard8MatrixDynamic programming+1No attempts yet1s128 MBJudgeable
Apple CountGiven range [A,B] up to 10^15, sum for each number a value derived from run-length groups of equal digits, using digit-DP for efficiency.Hard8Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Periodic TableCount ways to place K non-attacking pieces on a histogram-shaped grid where two cells in the same row are close only if all columns between them reach that row, modulo 1e9+7.Hard8Dynamic programmingStack+1No attempts yet1s128 MBJudgeable
GrasshopperGiven an N×N grid and a special knight-like move rule requiring strictly increasing petal counts, find the longest such path starting from a given cell.Hard8Dynamic programmingMatrix+1No attempts yet4s128 MBJudgeable
Wangnuni the FrogFind the path from leaf 1 to leaf N using only rightward or upward axis-aligned jumps costing K power each, that maximizes leftover power after eating flies along the way.Hard8Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Bicycle RaceGiven a graph where every edge belongs to at most one cycle, find the longest walk ending at city 1 using each edge at most once.Hard8TreeDynamic programming+1No attempts yet1s128 MBJudgeable
Allowed Digit MultiplesCount multiples of X within [A,B] whose decimal digits all come from an allowed digit set, with values up to 10^11.Hard8Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Buying a HighwayGiven road segment purchase costs and trucks with routes and toll fees under a per-segment per-direction traffic cap K, minimize total cost of buying segments plus tolls paid.Hard8GraphShortest path+1No attempts yet1s128 MBJudgeable
Building a WallGiven block sizes/costs and two target wall silhouettes for horizontal and vertical placement days, compute the minimum total cost to build the wall over two days.Hard8Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Mouse TrapsGiven an N x N grid of trap counts, choose K consecutive cells per row to remove so no path exists left-to-right or top-to-bottom, maximizing removed traps.Hard8Dynamic programmingMatrix+1No attempts yet1s128 MBJudgeable
ScientistGiven a grid maze and a sequence of box-shift events caused by a hidden mouse pushing box edges, compute the minimum number of mouse moves consistent with the observed box movements.Hard8BFSDynamic programming+1No attempts yet2s128 MBJudgeable
ElephantGiven N distinct 2D points, find the length of the longest strictly increasing chain in both coordinates and count how many such maximum chains exist modulo 1e9+7.Hard8Dynamic programmingSorting+1No attempts yet3s128 MBJudgeable
Tetris-Like GameGiven a score table for consecutive-letter group sizes, decide optimally which of three stack-like columns to drop each incoming letter into to maximize the total column score.Hard8Dynamic programmingImplementation+1No attempts yet1s128 MBJudgeable
Banner SchedulingGiven N banner requests with fixed relative display-day patterns spanning at most 7 days, arriving in order with non-decreasing start days, find the minimum schedule length using at most K banner slots per day.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Martian DNA FormulaCompress a DNA string into the shortest possible run-length style notation using nested parentheses with repeat counts.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Ships on a RiverGiven river fields with fish amounts and ships each needing a fixed anchor field and length placed without overlap, maximize total fish covered.Hard8Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Loading Cattle onto Freight CarsPartition a sequence of animals into up to K contiguous car groups of size at most M, resolving chained attacker/protector fights inside each car, to maximize survivors.Hard8Dynamic programmingSimulation+1No attempts yet1s128 MBJudgeable
GameGiven a grid game where two players alternately move a token down, right, or diagonally with scoring foods, determine for each starting cell which player wins under optimal play.Hard8Dynamic programmingGame theory+1No attempts yet1s128 MBJudgeable
Wedding TrainArrange N guests in a line minimizing total adjacent height difference while keeping K given family members in a fixed relative order.Hard8Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Sailing RaceFind the longest simple path on a circular arrangement of harbors using directed edges so that chords never cross except possibly one crossing involving the first stage, and report the max length with smallest starting harbor.Hard8Dynamic programmingGeometry+1No attempts yet3s32 MBJudgeable
Insertion Sort vs Quicksort ComparisonsCount permutations of 1..N where insertion sort's comparison count exceeds quicksort's by between 1 and X, modulo 1234567.Hard8Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
FenceChoose a subset of given points to form a convex polygon fence minimizing 20 times the number of posts used plus 111 times the number of trees left outside, considering all possible fences.Hard8GeometryDynamic programming+1No attempts yet1s128 MBJudgeable
Choosing Orders and Renting MachinesGiven orders with income and per-machine rent costs plus fixed machine purchase prices, choose orders and buy/rent decisions to maximize profit, solvable as a max-flow min-cut project selection problem.Hard8GraphGreedy+1No attempts yet2s128 MBJudgeable
ConnectGiven a maze-like board with figures placed in rooms, pair up all figures and connect each pair with vertex-disjoint paths minimizing total path length.Hard8GraphShortest path+1No attempts yet0.5s32 MBJudgeable
Mobile ServiceGiven a cost matrix and a request sequence, find the minimum total cost of moving three servers to serve each request in order using optimal dynamic programming.Hard8Dynamic programmingGreedy+1No attempts yet3s128 MBJudgeable
MonumentFind the maximum surface area 4ab of an axis-aligned a x a x b box of all-normal unit cubes that fits in a 3D grid with pores, where the square face can align with any of three axes.Hard8Binary searchMatrix+2No attempts yet5s128 MBJudgeable
RLE CompressionDecode a custom run-length encoding scheme and compute the minimum possible length of any code that decodes to the same character sequence.Hard8Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Moving RobotsGiven several robots each with a bounded command sequence, find the minimum total deletions so all robots can be made to stop at one common grid cell, breaking ties by lexicographically smallest position.Hard8Dynamic programmingSimulation+1No attempts yet1s128 MBJudgeable
Honeycomb Maximum Route SumFind the maximum sum path through a hexagonal grid moving diagonally down-left or down-right, allowing one row to have its maximum value moved to any position once.Hard8Dynamic programmingMatrix+1No attempts yet1s128 MBJudgeable
InsultsParse a string against a context-free grammar defining insults, then find the lexicographically next same-length valid insult or report invalid/ultimate.Hard8StringDynamic programming+2No attempts yet1s128 MBJudgeable
Hexagonal ParcelsOn a hexagonal grid with four labeled connected regions, find the minimum number of free cells to buy so all four regions become one connected component (Steiner-tree style optimization on a hex graph).Hard8GraphBFS+1No attempts yet1s128 MBJudgeable
BundlingGiven permitted bundle templates and a dependency chain among instructions, compute the minimum number of bundles to pack the sequence and, among those, the minimum number of stops needed.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Minimizing MaximizerGiven a pipeline of range-sort operations, find the minimum number of operations (kept in order) whose composition still guarantees the last position always holds the overall maximum.Hard8GreedyIntervals+1No attempts yet1s512 MBJudgeable
ChoirCompute minimum-cost assignment of singers to positions between all song pairs, then find the song ordering (TSP over at most 6 songs) that minimizes total replacements.Hard8Dynamic programmingCombinatorics+1No attempts yet3s512 MBJudgeable
Immediate DeliveryGiven a small weighted graph (n ≤ 18), split all junctions between two drivers starting from node 1 so that the larger of their two walk-covering times from node 1 is minimized.Hard8Bit manipulationDynamic programming+2No attempts yet3s256 MBJudgeable
King of OperationsGiven a custom digit-wise binary operator table, compute the repeated left-to-right combination of all numbers from a to b (up to 10^18) using digit dynamic programming per digit position.Hard8Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Cactus RevolutionDecide whether a given cactus graph can be split into k connected districts of equal size n/k, using cactus structure properties.Hard8GraphDynamic programming+1No attempts yet1s128 MBJudgeable
JourneyGiven two graphs with shortest distances to a target node, find the longest alternating walk where each move strictly decreases the current graph's distance-to-target value, or report infinite.Hard8Shortest pathDynamic programming+1No attempts yet3s256 MBJudgeable
Just Too LuckyCount integers from 1 to n (up to 10^12) whose value is divisible by its own digit sum, requiring digit-DP over fixed digit-sum targets.Hard8Dynamic programmingCombinatorics+1No attempts yet3s256 MBJudgeable
Fund ManagementGiven daily prices for up to 8 stocks over up to 100 days, decide one buy/sell/hold action per day under per-stock and total lot caps to maximize final cash after closing all positions.Hard8Dynamic programmingSimulation+1No attempts yet3s128 MBJudgeable
Cross and CrossFor a 1×n board where players alternately mark cells and the first to make three consecutive marks wins, decide the winner under optimal play for given n up to 2000.Hard8Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Domestic NetworksChoose a spanning tree of apartments and assign each edge to one of two cable types with limited total lengths to minimize cost, or report impossibility.Hard8Minimum spanning treeDynamic programming+1No attempts yet2s64 MBJudgeable
InterconnectGiven an initial graph on up to 30 towns, compute the exact expected number of random-edge additions needed until the graph becomes fully connected, as a reduced fraction.Hard8Union-findMath+2No attempts yet1s128 MBJudgeable
BridgesChoose k edges of a weighted tree to convert to a faster speed so that the sum of travel times over all pairs is minimized, breaking ties lexicographically.Hard8TreeGreedy+2No attempts yet2s64 MBJudgeable
Bee GardenGiven a tree of hives with coordinates, find which single new edge added minimizes the doubled-tree traversal, i.e. maximizes edge weight removed twice minus new edge distance, tie-broken lexicographically.Hard8TreeDynamic programming+1No attempts yet2s64 MBJudgeable
Train DelaysGiven a train timetable with hourly departures and probabilistic delays, compute the minimum expected total travel time from start to destination as an exact fraction.Hard8Shortest pathDynamic programming+2No attempts yet5s128 MBJudgeable
Selling LandFor every grid cell (as a rectangle's bottom-right corner), find the maximum perimeter of an all-grass rectangle ending there, then output counts grouped by perimeter.Hard8Dynamic programmingArray+1No attempts yet1s128 MBJudgeable
Ticket to RideGiven a weighted graph and four pairs of terminal cities, find the minimum total edge cost of a subgraph connecting all four pairs simultaneously.Hard8GraphMinimum spanning tree+2No attempts yet1s128 MBJudgeable
Secret Code: Largest NumberGiven a noisy string, find the largest decimal number it could decode to, either fixing one language for all digits or allowing a different language per digit, using digit-word subsequence matching.Hard8Dynamic programmingString matching+2No attempts yet3s128 MBJudgeable
Software Industry RevolutionGiven a wildcard pattern (with ? and *) and a text, find the minimum-complexity substring of the text that matches the whole pattern, or report impossible.Hard8String matchingDynamic programming+1No attempts yet1s128 MBJudgeable
ACGUGiven an RLE-encoded RNA-like string, find the maximum number of non-crossing A-U and C-G pairs with at most K C-G pairs, exploiting the special RLE size constraints.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Balloon CollectionGiven balloons falling at specific positions and times, find the minimum weighted travel cost for a capacity-3 robot to catch and store all balloons at the origin, or report the first uncatchable balloon.Hard8Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Twenty QuestionsGiven n objects each described by m binary features, find the minimum worst-case number of adaptive yes/no feature queries needed to identify the hidden object.Hard8Bit manipulationDynamic programming+1No attempts yet1s128 MBJudgeable