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,689 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
ResortFind the path from a start clearing to any base clearing that minimizes leftover card points, where track edges are free but lift edges cost points and require enough balance.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
SkiersGiven a planar DAG whose edges leave clearings in west-to-east order, find the minimum number of downhill paths that cover every edge.Hard8GraphDynamic programming+2No attempts yet1s128 MBJudgeable
The Labyrinth of WellsGiven a colored DAG where each room has three outgoing wells, find the minimum number of rooms in a DAG producing the same color sequence for every path.Hard8GraphDynamic programming+1No attempts yet3s128 MBJudgeable
RocketsMatch the n red points to the n white points with non-crossing segments so the total Euclidean length is minimum, and report the matching.Hard8Dynamic programmingDivide and conquer+2No attempts yet1s128 MBJudgeable
PolygonGiven a convex polygon and its triangulation, find the maximum number of triangulation triangles a single elementary triangle can intersect.Hard8GeometryDynamic programming+1No attempts yet1s128 MBJudgeable
Assembler CircuitsGiven a straight-line program of register assignments, find the fewest binary-operation gates needed to compute all final register values for every initial state.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
The Lightest LanguageGiven n, k, and letter weights, find the minimum total weight of a prefixless set of exactly n words over k letters.Hard8TreeGreedy+2No attempts yet1s128 MBJudgeable
Step Traversing a TreeGiven a tree on n vertices, find the smallest c such that the vertices can be visited in some order where each consecutive pair is at distance at most c.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
SchoolsAssign a distinct number 1..n to each school within its allowed interval, minimizing the total weighted movement cost.Hard8GreedyDynamic programming+2No attempts yet3s128 MBJudgeable
SubwayGiven a tree with n stations, choose l non-branching paths (routes) to cover as many distinct vertices as possible.Hard8TreeDynamic programming+1No attempts yet3s128 MBJudgeable
PloughingGiven an m by n grid of tile difficulties, repeatedly remove a full strip of width 1 from any edge as long as the strip sum is at most k, and minimize the number of strips that remove every tile.Hard8Dynamic programmingTwo pointers+2No attempts yet1s128 MBJudgeable
Dancing in CirclesCount ways to split n labeled children into k unordered directed cycles of length at least l, modulo 2005.Hard8CombinatoricsMath+2No attempts yet3s512 MBJudgeable
CrystalsCount tuples a_i with 0 <= a_i <= m_i whose XOR is zero and whose sum is at least 1, with n <= 50 and bounds near 2^32.Hard8Bit manipulationDynamic programming+2No attempts yet1s128 MBJudgeable
Tourist AttractionsFind the shortest route from site 1 to site n that visits sites 2 through k+1 in some order consistent with given precedence constraints.Hard8Shortest pathDynamic programming+2No attempts yet3s128 MBJudgeable
Quaternary BalanceGiven n up to 1000 digits, count modulo 10^9 the distinct minimum-mass weighings of n grams with masses that are powers of four, placed on either pan or both.Hard8Dynamic programmingMath+2No attempts yet1s128 MBJudgeable
The Walk of Bytie-boyFor each consecutive pair of stops in a city of one-way lettered streets, find the shortest walk whose letter sequence is a palindrome, tie-broken by lexicographically smallest string.Hard8BFSGraph+2No attempts yet1s128 MBJudgeable
WordsGiven indices k_i, decide whether the concatenation of the words h^{k_i}(0) appears as a substring of some h^m(0).Hard8StringDynamic programming+2No attempts yet1s128 MBJudgeable
SheepCount triangulations of a convex n-gon by non-crossing diagonals such that no diagonal passes through a sheep's spot and every triangle holds an even number of spots, modulo m.Hard8Dynamic programmingGeometry+2No attempts yet3s512 MBJudgeable
Monotonicity 2Find the longest subsequence of a given array whose adjacent-comparison pattern repeats the given cyclic scheme of <, >, = symbols.Hard8Dynamic programmingSegment tree+1No attempts yet3s512 MBJudgeable
Lightning ConductorFor each building i, find the smallest integer p such that h_i + p - sqrt(|i-j|) >= h_j for every building j.Hard8Divide and conquerDynamic programming+1No attempts yet1s128 MBJudgeable
PlotPartition a sequence of n points into at most m contiguous groups, replacing each group with one point, to minimize the maximum distance from any original point to its group's representative.Hard8Binary searchDynamic programming+2No attempts yet30s128 MBJudgeable
InspectionFor each root of a tree, find the minimum time for a tour that inspects every node and returns to the root each time, with no two consecutive trips using the same first edge.Hard8TreeDFS+2No attempts yet5s128 MBJudgeable
FestivalGiven exact +1 edges and <= edges between runners' integer times, find the maximum count of distinct times consistent with all constraints, or NIE if impossible.Hard8GraphShortest path+1No attempts yet3s128 MBJudgeable
Fibonacci RepresentationFor each query k, find the fewest Fibonacci numbers whose signed sum (plus or minus, repeats allowed) equals k.Hard8Dynamic programmingMath+2No attempts yet3s128 MBJudgeable
Triumphal ArchGiven a tree rooted at town 1, find the minimum number of crews so that each town gets its arch built before the king's first arrival, where the king's walk is unknown.Hard8TreeGreedy+2No attempts yet1s128 MBJudgeable
The Byteotian WarBoth players take turns discarding one of their top two cards and passing the other to the opponent; find the final score when both play optimally.Hard8Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Cheap AirlinesChoose at most k non-overlapping contiguous segments of the array to maximize the total sum of their elements.Hard8Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Bark BeetlesTwo beetles alternate taking one end picket or both end pickets from a row; each maximizes its own total, so find both final totals.Hard8Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Declining SequencesGiven a sequence and a fixed length p, count and return the lexicographically k-th decreasing index sequence for each query.Hard8Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
VacationFind a permutation of n attractions minimizing the total capped positional distance to k given rankings (k at most 3).Hard8Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
TelescopeChoose an order for the coins and insertion times so that the paid viewing windows cover as many meteor intervals as possible.Hard8Dynamic programmingSorting+1No attempts yet5s128 MBJudgeable
MushroomsA walker starts at glade 1, moves one glade every 15 minutes for t moves, picks all mushrooms on arrival, and each glade regrows 30 minutes later; maximize the total harvest.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
TermitesTwo termites alternately eat planks adjacent to already-eaten ones, each maximizing her total; report the wood each ends up with under optimal play.Hard8GreedyGame theory+2No attempts yet2s512 MBJudgeable
The Way to BytemountainFind a walk from crossing 1 to crossing n that deviates from the signpost arrows at most k times and maximizes total trail beauty.Hard8GraphDynamic programming+2No attempts yet1s32 MBJudgeable
CardsCount binary strings with r reds and b blacks where the first card is black or some black run is preceded by a shorter-than-k-times red run, modulo a prime p.Hard8Dynamic programmingCombinatorics+1No attempts yet2s512 MBJudgeable
PermutationsCount completions of a partial permutation on 2n points that is an involution and encodes a correct bracket sequence.Hard8CombinatoricsDynamic programming+2No attempts yet2s512 MBJudgeable
Paper ClipsFind the minimum number of 180-degree turns needed to separate a chain of clips joined in two possible ways, where clips sit in four orientations.Hard8GreedyDynamic programming+1No attempts yet1s128 MBJudgeable
CliquersCount assignments of grades from 1..m to all integer partitions of n, modulo 10^9-401.Hard8CombinatoricsNumber theory+2No attempts yet1s128 MBJudgeable
JourneyCount length-d walks in a small (n<=20) graph that visit each of the first k<=7 cities at least once, modulo 1e9+9.Hard8Dynamic programmingGraph+2No attempts yet1s128 MBJudgeable
Return of the CliquersCount the number of grade assignments to all symmetric labeled cliquers on n vertices, raised to m modulo 10^9-401 with n and m up to 2*10^9.Hard8CombinatoricsNumber theory+2No attempts yet1s128 MBJudgeable
Enumeration of Road Network PlansCount the isomorphism classes of trees on n vertices whose diameter equals d, modulo a prime p.Hard8CombinatoricsTree+2No attempts yet1s128 MBJudgeable
Conference - RectificationChoose a subset of whole reservations to keep so that total income from ticket sales minus room rent is maximized.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
SubsetsCount k-element subsets of {1,...,n} in which no two chosen numbers differ by a factor of x, modulo m, with n up to 1e18.Hard8Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Courier ServicesFind all Pareto-optimal (cost, time) pairs among routes from a class-C source to a class-C destination in a network with a special office-class structure and cycles.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
Swift FawnWith energy starting at 1 and moves that double, halve, or negate the current level, find the fewest jumps to reach distance n and then stop.Hard8Dynamic programmingMath+2No attempts yet1s128 MBJudgeable
Life of the PartyGiven a bipartite acquaintance graph, list every vertex whose removal strictly decreases the maximum matching.Hard8GraphDynamic programmingNo attempts yet1s128 MBJudgeable
ChessboardCount permutations of 1..n whose i-th rook avoids row i and column i, modulo m.Hard8CombinatoricsDynamic programming+1No attempts yet1s128 MBJudgeable
ExcursionSplit a path of n weighted roads into contiguous segments of total length at most D, minimizing the sum of squared segment impression sums.Hard8Dynamic programmingSliding window+2No attempts yet1s128 MBJudgeable
Express DeliveryGiven a depot and clients with distinct x and y coordinates, find the fewest monotone (shortest-path) routes from the depot that cover all clients.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
CiągBajtek needs the shortest string over the given alphabet that is not a subsequence of the word, and the lexicographically smallest among shortest such strings.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Binary Tree Lexicographic NumberGiven binary trees with ordered left and right children, find each tree's rank in height-first lexicographic order modulo 1000000000.Hard8Dynamic programmingTree+2No attempts yet1s128 MBJudgeable
Three-Bit ComputersThe task is to decide whether a target string over a, b and c can be built from uninitialized cells with the two pair operations.Hard8Dynamic programmingStringNo attempts yet1s128 MBJudgeable
SailboatFind a path from buoy 1 to buoy n in a DAG maximizing the sum of squared differences between consecutive edge weights.Hard8Dynamic programmingGraph+1No attempts yet1s128 MBJudgeable
Staircase Function ApproximationPartition the sequence f(0..n-1) into at most k contiguous groups, each approximated by a constant, minimizing the sum of |value - f(i)|^p over all i, and output the reduced fraction.Hard8Dynamic programmingDivide and conquer+1No attempts yet1s128 MBJudgeable
RacesGiven a tree and a set of allowed endpoints, find the maximum number of vertex-disjoint paths whose endpoints both lie in the allowed set.Hard8TreeDynamic programming+2No attempts yet1s128 MBJudgeable
DiversWith a shared torch and a graph of divers who refuse to pair up, find the minimum total time to ferry everyone out under the rock, or IMPOSSIBLE.Hard8GraphDynamic programming+2No attempts yet1s128 MBJudgeable
RitualCount the subsequences of a long digit string that form a palindrome divisible by 666, then report ((count - 1) mod 666) + 1.Hard8Dynamic programmingString+2No attempts yet1s128 MBJudgeable
The Fibonacci GameDetermine whether the first player wins a game that erases Fibonacci words only from the right end of a given a/b string.Hard8String matchingDynamic programming+2No attempts yet1s128 MBJudgeable
House of CardsMarcel removes at most k cards in whole leaning pairs, clearing cards above before the cards they rest on, to maximize the recovered sum.Hard8Dynamic programmingTreeNo attempts yet1s512 MBJudgeable
StrikeChoose one train to hold for k minutes in a DAG rail network so the total delay passed on to all trains is largest.Hard8Dynamic programmingTopological sort+1No attempts yet1s128 MBJudgeable
TrainSum over all n! orders of the wagon strings the number of occurrences of their concatenation in t.Hard8Dynamic programmingString matching+1No attempts yet1s128 MBJudgeable
RobotWrite the shortest down-right program of at most k steps whose repetition exits the board without hitting an obstacle, ties broken lexicographically.Hard8Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Maximum Mean CycleFind the directed cycle with the largest mean edge weight and print it as a reduced fraction.Hard8GraphDynamic programming+1No attempts yet1s128 MBJudgeable
Heavy BlocksTopple n distinct-weight blocks with the fewest pushes when each push fells lighter neighbors in one direction until a heavier block or gap.Hard8Dynamic programmingStack+2No attempts yet1s128 MBJudgeable
SlidesCount the non-empty slide subsets that keep slide-number order and rise in both rankings, modulo 1000000007.Hard8Dynamic programmingDivide and conquer+1No attempts yet10s128 MBJudgeable
The SafeCount the ordered sequences of exactly R dial turns that leave target k at the top, modulo 1000033.Hard8MatrixDynamic programming+1No attempts yet4s128 MBJudgeable
Ski RoutesCount closed tours that chain one or more uphill lifts and then ski down to the start through strictly lower adjacent cells.Hard8Dynamic programmingGraph+1No attempts yet10s128 MBJudgeable
Paweł i Gaweł 2Two players alternately remove stones from the leftmost or rightmost pile, and you decide who takes the last stone when both play their best.Hard8Game theoryDynamic programmingNo attempts yet1s128 MBJudgeable
BricksCount prime multisets of N obtainable by splitting N in two and then splitting both sides the same number of times.Hard8Dynamic programmingNumber theory+1No attempts yet3s128 MBJudgeable
Text AlgorithmsMove a pawn from the bottom-right to the top-left of a grid where left and up steps cost 1 and diagonal steps are free when row and column colors match.Hard8Dynamic programmingString matchingNo attempts yet1s128 MBJudgeable
Hey, Better BettorGiven a refund rate on final losses and a win chance below half per dollar bet, compute the maximum expected profit over any stopping strategy.Hard8ProbabilityDynamic programming+1No attempts yet4s128 MBJudgeable
HarvardAssign each variable of a program with nested repeats to a memory bank within capacity to minimize access and select costs.Hard8BacktrackingDynamic programming+1No attempts yet10s128 MBJudgeable
Matryoshka DollsReassemble a row of dolls into complete 1 to m sets using adjacent merges while minimizing the number of doll openings.Hard8Dynamic programmingIntervalsNo attempts yet5s128 MBJudgeable
Critical 3-PathFind three vertex-disjoint paths from each start to its target in a weighted DAG with maximum total weight.Hard8Dynamic programmingGraph+1No attempts yet3s128 MBJudgeable
InstallationsOrder jobs with given service times and deadlines to minimize the sum of the two largest lateness penalties.Hard8Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
MetalCount how many simple monotone polygons use the given n points as vertices.Hard8Dynamic programmingGeometry+1No attempts yet1s128 MBJudgeable
RoommateTwo roommates follow fixed appliance orders with person-specific durations while sharing each appliance, and the task is to find the earliest time both finish.Hard8Dynamic programmingShortest pathNo attempts yet1s128 MBJudgeable
A Lazy WorkerJobs have processing times with arrival times and deadlines, and the worker picks among available jobs without idling to minimize total executed work.Hard8Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
StainsTaeyeon covers integer points off the x-axis with diamonds centered on the x-axis and minimizes the sum of their areas.Hard8Dynamic programmingGeometry+2No attempts yet1s128 MBJudgeable
Triangle WarFrom a partially filled triangular grid of 10 dots and 18 lines, decide which player wins Triangle War under perfect play.Hard8Game theoryBrute force+2No attempts yet1s128 MBJudgeable
Rotate and RewriteDecide whether two rotatable integer sequences can be reduced to a common sequence by substring rewrite rules and report the greatest such length.Hard8Dynamic programmingString matching+1No attempts yet15s128 MBJudgeable
Series-Parallel Parking LotPlace as many extra cars as possible on empty spaces of the encoded lot so every car still reaches the exit through empty spaces.Hard8Dynamic programmingTree+1No attempts yet2s256 MBJudgeable
ZZStarting from Fibonacci-like values a and b, repeat prefix sums c times and output the d-th value modulo 1000000009.Hard8CombinatoricsNumber theory+1No attempts yet15s64 MBJudgeable
Bribing the SyndicateChoose an adaptive bribery order within a fixed budget to maximize the chance of gaining at least c defectors.Hard8Dynamic programmingProbabilityNo attempts yet5s128 MBJudgeable
Correcting CuriosityGiven two strings, find the length of the shortest substitution command that rewrites the first into the second.Hard8String matchingString+1No attempts yet2s256 MBJudgeable
String PathCount the N by M letter grids where two given strings each appear on a down-right path from the top-left to the bottom-right corner.Hard8Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
Beautiful LandscapeMove blocks between neighboring stacks at unit cost so occupied positions sit at pairwise prime distances using the fewest moves.Hard8Dynamic programmingPrefix sum+1No attempts yet20s128 MBJudgeable
Electric Car RallyPlan driving and charging stops across time-dependent roads to reach the last station as early as possible.Hard8Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Leave Your NameEnter the given uppercase name with the fewest presses of letter-change, cursor-move, and insert buttons.Hard8Dynamic programmingBit manipulation+1No attempts yet12s128 MBJudgeable
Crusher's CodeCompute the expected number of loop iterations for two randomized swap sorts on arrays of up to 8 values.Hard8ProbabilityDynamic programming+1No attempts yet10s128 MBJudgeable
DictionaryGiven up to 50 short words, find the fewest vertices of an edge-labeled tree whose downward paths contain every word.Hard8TrieString matching+2No attempts yet1s128 MBJudgeable
Mixing ColoursThe player picks one colour per token and merges adjacent tokens under the rules to maximize the product of picked certainties, breaking ties in ASCII order.Hard8Dynamic programmingProbabilityNo attempts yet5s128 MBJudgeable
Moves on an Infinite Binary TreeStarting from the node reached by S, count the distinct nodes reachable by following any subsequence of T on an infinite binary tree.Hard8Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
Longest ChainFind the longest chain of triples with all three coordinates strictly increasing among up to 300,000 points per dataset.Hard8Divide and conquerDynamic programming+2No attempts yet10s128 MBJudgeable
Hidden TreeFind the longest subsequence that forms the leaves of a binary tree where each internal node has equal left and right sums.Hard8Dynamic programmingTree+1No attempts yet5s128 MBJudgeable
Palindrome TripCompute the chance that a uniform random walk from s to t spells a palindrome, stopping early when t becomes unreachable.Hard8ProbabilityGraph+2No attempts yet10s128 MBJudgeable
Increasing Shortest PathFind the cheapest A to B path using at most C edges whose weights strictly increase.Hard8Dynamic programmingShortest path+2No attempts yet15s256 MBJudgeable
The CarpenterCut two non-overlapping diagonal triangles from an n by m black-and-white board and glue them into the largest square with alternating colors.Hard8Dynamic programmingMatrix+1No attempts yet2s128 MBJudgeable
PatienceGiven n, count the unfinished-suit layouts with fewer than n high cards out of place that reach the ordered row.Hard8CombinatoricsDynamic programming+1No attempts yet2s512 MBJudgeable
RNAReport the longest contiguous block shared by both RNA strings whose parenthesis marks balance.Hard8Dynamic programmingString+1No attempts yet1s128 MBJudgeable