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,706 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
AntCount walks of exactly k edges from one cube vertex to another, never reusing the edge just used, modulo p.Medium7MatrixDynamic programming+2No attempts yet1s128 MBJudgeable
Supernumbers in a PermutationGiven a permutation, find every value that appears in some longest increasing subsequence, and print them in increasing order.Medium7Dynamic programmingBinary search+1No attempts yet1s128 MBJudgeable
Physical EducationJasio can skip up to k duels where he is the left student; find the leftmost final position he can reach.Medium7ArrayDynamic programming+2No attempts yet1s128 MBJudgeable
Land SwindleFor each meadow square choose at most one rectangle ending there, maximize the total perimeter, where each rectangle must contain only meadow squares.Medium7Dynamic programmingPrefix sum+1No attempts yet1s128 MBJudgeable
TramsGiven a weighted tree, pair up the leaf nodes choosing disjoint simple paths to minimize or maximize the total length.Medium7TreeDynamic programming+1No attempts yet1s128 MBJudgeable
Divisor GameFor each divisor d of N below N, players Bajtus and Bitus get scores a(d), b(d) when they write d; find the first player's advantage under optimal play when each boy starts.Medium7Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
VacationChoose vacation days from a 3n-day forecast, taking at most k days in every window of n consecutive days, to maximize the total temperature.Medium7Dynamic programmingSliding window+2No attempts yet1s128 MBJudgeable
TowerPartition the sequence of brick widths into consecutive blocks so that block sums do not increase from bottom to top, maximizing the number of blocks.Medium7Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Two PostmenSplit the edges of a tree rooted at node 1 between two postmen starting at the root so the later finishing time is minimized.Medium7TreeDynamic programming+2No attempts yet1s128 MBJudgeable
Amusement ParkCount how many distinct longest common subsequences two lists of up to 10000 numbers share, modulo 1000000007.Medium7Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
Returning BlocksCount the ways to fill empty cells of a 2-by-n board with distinct blocks so every row and column reads in increasing order.Medium7Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
Error CorrectionGiven letter-to-bits codebook and binary strings, decide if exactly one letter sequence encodes to within one bit flip.Medium7Dynamic programmingString matching+1No attempts yet1s128 MBJudgeable
AllianceGiven a bipartite graph, pick the smallest set of edges so that every vertex which has any edge has at least one chosen incident edge.Medium7GraphGreedy+2No attempts yet1s128 MBJudgeable
Two-Colored Towers of HanoiThe task is to compute the minimum moves to gather odd disks on peg B and even disks on peg C under Hanoi rules.Medium7Dynamic programmingRecursion+1No attempts yet1s128 MBJudgeable
AptekaPay each swapped person by distance times their fee and reach the front with the smallest total cost.Medium7Dynamic programmingGreedy+1No attempts yet1s512 MBJudgeable
OfficialsIn a rooted tree of officials, match each denouncer with a distinct descendant subordinate to maximize the number of executed officials.Medium7GreedyTree+1No attempts yet1s512 MBJudgeable
HalloweenGiven the sequence of required costumes, find the fewest put-ons when costumes stack and removals are free.Medium7Dynamic programmingIntervalsNo attempts yet1s128 MBJudgeable
ABCFind the length of the longest nondecreasing common subsequence of two strings over a, b, and c.Medium7Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Room NumbersCount the distinct numbers formed by flipping each 6 or 9 in n independently that are at most h, modulo 9999997.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
TagA pursuer at K always steps toward an evader at J on a tree while the evader moves or waits to maximize the capture time.Medium7TreeGame theory+2No attempts yet5s128 MBJudgeable
Number of Obtainable AmountsCount the distinct totals formable from bounded banknotes where each denomination is a multiple of the previous one, modulo 1e9+7.Medium7Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
HamsterSchedule food packages with spoil days, meal counts and qualities to maximize total meal quality over M days.Medium7Dynamic programmingSortingNo attempts yet2s128 MBJudgeable
Paper StripsCount the sets of dyadic pieces from repeated halving that exactly tile sectors a to b, modulo m.Medium7Dynamic programmingDivide and conquer+1No attempts yet1s128 MBJudgeable
Magic RectangleCount the ways to fill a 3 by N grid with 1 to 3N so each row and column increases, matching the prefilled cells, modulo 1000007.Medium7Dynamic programmingCombinatoricsNo attempts yet2s128 MBJudgeable
Banner RepairTransform one uppercase banner string into another with block insertions and deletions where each block of length S costs X plus S times Y.Medium7Dynamic programmingStringNo attempts yet10s128 MBJudgeable
VisasChoose visa requests and give each a distinct day inside its window for the largest total payment.Medium7Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
AcceleratorMatch every red point on a discrete circle to a distinct blue point so the sum of shorter-arc distances is as small as possible.Medium7Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Slicing TreePlace the rotated rectangles under the slicing-tree constraints so the enclosing rectangle has minimum area.Medium7Dynamic programmingTreeNo attempts yet1s128 MBJudgeable
Color LengthMerge two color strings while keeping each order so the sum of first-to-last spans of all colors is as small as possible.Medium7Dynamic programmingNo attempts yet10s128 MBJudgeable
LaptopPlace each unit-time task inside its release time and deadline so idle gaps between tasks are as few as possible.Medium7Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Pizza DeliveryChoose which houses on a road to visit and in what order so earnings minus delivery times give the largest total profit.Medium7Dynamic programmingIntervalsNo attempts yet1s128 MBJudgeable
Popping GroupsDecide whether a string of a and b can be fully erased by repeatedly deleting maximal runs of at least two equal letters.Medium7Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Cellular NetworkYou sort n cells by their probabilities and split them into w ordered zones to minimize the expected number of paged cells.Medium7Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
SticksYou keep a connected set of sticks that meet only at endpoints without crossing to maximize total length.Medium7Dynamic programmingGraph+2No attempts yet1s128 MBJudgeable
ParentsPick from 1 to K nodes of a valued tree with no parent-child pair so the sum of picked values is as large as possible.Medium7Dynamic programmingTreeNo attempts yet5s128 MBJudgeable
Nile River Dam ReleasesSchedule dam releases so every forecast window gets a release and cascades flow downstream, at the lowest total cost.Medium7Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
SightseeingCount the routes from city S to city F whose length equals the shortest distance or is exactly one unit longer.Medium7Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Oh, Those Achin' FeetSplit each route's pedestrian load evenly across all shortest street paths and print every square's total load.Medium7Shortest pathBFS+2No attempts yet1s128 MBJudgeable
Bulletin boardsArrange ordered framed pictures into consecutive strips with shared frames and centering to fit the smallest area rectangle.Medium7Dynamic programmingSimulationNo attempts yet1s128 MBJudgeable
Young, Poor and BusyTwo travelers starting from Hakodate and Tokyo meet in one city for at least 30 minutes and both return home between 08:00 and 18:00 at the lowest total fare.Medium7Shortest pathGraph+1No attempts yet1s128 MBJudgeable
NimDecide whether the moving-first team wins the team take-away game with per-player take limits where the last take loses.Medium7Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Lottery TicketsCount numbers from 0 to M-1 whose zero-padded decimal form matches Z in some length-r block at the same positions.Medium7Dynamic programmingString matchingNo attempts yet1s128 MBJudgeable
The jury is outSelect k of up to 100 candidates with the closest prosecution and defence totals, breaking ties by larger combined score then smaller index list.Medium7Dynamic programmingNo attempts yet1s128 MBJudgeable
Russian DollsArrange all dolls into nested chains where each doll fits only inside a strictly roomier one to minimize the total cost of leftover empty space.Medium7Dynamic programmingSorting+1No attempts yet3s128 MBJudgeable
Let's go on an adventurePlan a route from the start to the destination within a fuel limit that collects the largest possible total of region values, counting each visited region once.Medium7Dynamic programmingShortest path+1No attempts yet1s128 MBJudgeable
Dreaded Alternating GamePick the side, even or odd, that wins a token-moving game on a directed board when both players play perfectly.Medium7Game theoryGraph+2No attempts yet1s128 MBJudgeable
Chemicals MonitoringVictor admits the maximum-priority subset of streams that one shared output unit can report in stack order.Medium7Dynamic programmingStack+2No attempts yet4s256 MBJudgeable
Movie Theater SeatingDecide whether S solo guests and C couples fit into R rows of 8 seats with reserved seats while keeping neighbors and front seats empty.Medium7Dynamic programmingBit manipulation+1No attempts yet2s64 MBJudgeable
You Shall Not Pass!!Choose up to C coaching subtrees in a forest to maximize the number of teams covered by at least one chosen subtree.Medium7Dynamic programmingTreeNo attempts yet1s128 MBJudgeable
CipherGiven total character volume, word count, and rank, reconstruct the I-th message in lexicographic order or report corruption.Medium7Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
Hurry PlotterMaximize the number of horizontal segments a sweeping plotter draws within a time limit, where drawn moves cost double and the final row skips the return trip.Medium7Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
ACM CoalitionPick parties whose seats cover the shortage and grant one demand each so ACM's remaining board votes are maximal.Medium7Dynamic programmingNo attempts yet1s128 MBJudgeable
Royal GemsFill each cell of an n by m board with one of four gems to maximize the ruby count while every ruby, emerald, and sapphire neighbors the required higher gems.Medium7Dynamic programmingBacktracking+2No attempts yet1s128 MBJudgeable
DiamondsArthas opens boxes outward from his starting keys to collect every diamond with the fewest openings.Medium7Dynamic programmingIntervals+1No attempts yet1s128 MBJudgeable
Border ConflictChoose the shortest subsequence polyline through the given points so every original point lies within distance D of it.Medium7Dynamic programmingGeometry+1No attempts yet1s128 MBJudgeable
Array GameThe player shifts all numbers left or right each turn to maximize the total signed value collected when numbers land on fixed plus and minus cells.Medium7Dynamic programmingIntervalsNo attempts yet1s128 MBJudgeable
ACM RevengeCompute the number of deaths before the first hunter reaches a treasure room in a binary tree with traps and toggling exits.Medium7TreeDynamic programming+1No attempts yet1s128 MBJudgeable
Jeju Island TourPick two vertex-disjoint directed paths in a DAG so the total number of vertices on both paths is as large as possible.Medium7Dynamic programmingGraph+1No attempts yet1s128 MBJudgeable
Flight Boarding OptimizationYou split the rows into k contiguous zones and order their boarding phases, keeping queue order inside each zone, to minimize total boarding difficulty.Medium7Dynamic programmingIntervals+1No attempts yet2s256 MBJudgeable
Geometric PatternsFor each given n, print the numbers of spanning trees of the 2 by n rectangular grid and the 2 by n circular grid modulo 10007.Medium7CombinatoricsDynamic programming+1No attempts yet1s128 MBJudgeable
SkyscrapersCount permutations of 1 to n whose visible building counts from the left and right equal the given values.Medium7CombinatoricsDynamic programmingNo attempts yet6s512 MBJudgeable
Treasure ChestsOpen up to 12 treasure chests in the order that leaves the most keys, spending colored keys before wild ones to fill each lock.Medium7Dynamic programmingBit manipulation+1No attempts yet1s128 MBJudgeable
Delta QuadrantStarting anywhere on a weighted tree, find the shortest closed tour that visits all but k planets and returns to the start.Medium7Dynamic programmingTreeNo attempts yet5s128 MBJudgeable
Erasing GameCount the ordered sequences A whose entries can each be matched to a distinct entry of S that is at least as large.Medium7CombinatoricsSorting+2No attempts yet1s128 MBJudgeable
NP-hardFind the shortest route that visits each of up to 1500 cities once when every city keeps all lower-numbered cities on one side of it.Medium7Dynamic programmingIntervalsNo attempts yet2s256 MBJudgeable
Anagrams divisible by 11Count distinct digit permutations of N with no leading zero that are multiples of 11, modulo 1e9+7.Medium7Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
SubwayFind a subway route that uses the fewest line boardings and, among those, takes the most minutes.Medium7Shortest pathGraph+2No attempts yet8s128 MBJudgeable
Catch the BombGiven forbidden left and upper neighbor pairs over 26 letters, find the largest fillable square grid, capped at 20.Medium7GraphTopological sort+1No attempts yet2s128 MBJudgeable
Lock PatternCount valid lock patterns on a 3 by 4 grid whose Manhattan segment lengths sum to L while avoiding the dots in S.Medium7Dynamic programmingBit manipulationNo attempts yet5s128 MBJudgeable
Math HomeworkCount N-digit strings, leading zeros allowed, whose divisibility by each of 1 to 6 matches a given pattern, modulo 1e9+7.Medium7MatrixNumber theory+1No attempts yet1s128 MBJudgeable
No ChangePay the ordered purchases with distinct coins, each covering one consecutive group within its value, to maximize unused value, or print -1.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Pogo-CowStarting from any target and hopping in one direction with non-decreasing jump lengths, collect the maximum total points from visited targets.Medium7Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Bonus CardsDmitry compares his chance of winning a seat when he enters with a double-slot card and with a single-slot card.Medium7ProbabilityDynamic programming+1No attempts yet1s128 MBJudgeable
Factorials with an even number of trailing zeroesCount how many k from 0 to n have a factorial ending in an even number of zeros for each query.Medium7Number theoryDynamic programming+1No attempts yet1s128 MBJudgeable
BoxCount left-packed orderings of boxes with total width at most W so no unpacked box still fits the leftover space.Medium7Dynamic programmingCombinatoricsNo attempts yet5s128 MBJudgeable
Distance Between Two IntegersSum the digitwise absolute differences over every ordered pair of integers from A to B, modulo 1,000,000,007.Medium7Dynamic programmingCombinatorics+1No attempts yet3s128 MBJudgeable
Cup of CowardsChoose hits from five bounded characters to reach at least L damage at minimum cost, breaking ties by smaller damage.Medium7Dynamic programmingSortingNo attempts yet3s128 MBJudgeable
Super AntsAn ant on a grid cell collects its value and spawns clones along eight rays within the remaining time, and you compute the total score modulo 1e9+7.Medium7Dynamic programmingPrefix sum+1No attempts yet1s128 MBJudgeable
Card TrickGiven the cards on the observed hopping path, compute the chance that a random start among positions 1 to 10 ends on the same final card.Medium7Dynamic programmingProbability+1No attempts yet2s128 MBJudgeable
Young diagrams and Young tableauxCount the fillings of the given Young diagram with numbers 1 to N that rise weakly across rows and strictly down columns.Medium7Dynamic programmingCombinatorics+1No attempts yet3s128 MBJudgeable
Infix to PrefixGiven a prefix expression with spaces and parentheses removed, compute the smallest and largest values over all valid parses.Medium7Dynamic programmingIntervals+1No attempts yet5s128 MBJudgeable
Jingle BallsMove as few balls as possible so the two sides of every split differ by at most one ball, or report impossible.Medium7Dynamic programmingTreeNo attempts yet1s128 MBJudgeable
The course Mirko winsFind the directed cycle where Mirko beats Slavko with the fewest roads, breaking ties by the largest time difference.Medium7Shortest pathGraph+1No attempts yet3s128 MBJudgeable
TraitorCover as many marked nodes of a forest as possible by assigning each a distinct neighboring watcher with no two marked nodes watching each other.Medium7Dynamic programmingTreeNo attempts yet1s128 MBJudgeable
Speed CamerasPlace the most cameras on the intersections of a tree so no simple route passes more than k cameras.Medium7GreedyTree+1No attempts yet1s128 MBJudgeable
Genetic engineeringDelete the fewest elements so the rest splits into blocks of k equal values, and print the lexicographically smallest among the longest such genomes.Medium7Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Sum of all numbers made from even digitsAdd up every distinct number that can be formed from the available copies of digits 2, 4, 6 and 8, modulo 1,000,000,007.Medium7Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
The Urge to MergeYou pick disjoint adjacent pairs in a 3 by n grid to maximize the sum of the products of paired values.Medium7Dynamic programmingBit manipulationNo attempts yet5s128 MBJudgeable
XenospeakGiven words per page and a page number, print the first and last words on that page over tilings of a, ab and bb ordered by length then alphabetically.Medium7CombinatoricsDynamic programming+1No attempts yet1s128 MBJudgeable
Optimal MilkingEach day one machine value changes, then choose nonadjacent machines with maximum total output and add it to the overall sum.Medium7Segment treeDynamic programmingNo attempts yet1s128 MBJudgeable
Ride the dominoes on a chessboardPlace exactly K non-overlapping dominoes on an N by 3 board of integers to maximize the sum of covered cells.Medium7Dynamic programmingBit manipulationNo attempts yet3s128 MBJudgeable
The Four Towers of HanoiMove all N disks to the last peg with four pegs in the fewest moves and print the count per test case.Medium7Dynamic programmingMathNo attempts yet3s128 MBJudgeable
Cow DecathlonAssign each cow to one event to maximize base scores plus prefix bonuses that cascade when thresholds are met.Medium7Dynamic programmingBit manipulationNo attempts yet1s128 MBJudgeable
Secret MessageCount the operation sequences that build the given string by repeatedly prepending or appending a proper prefix or suffix.Medium7Dynamic programmingString+1No attempts yet1s128 MBJudgeable
BytecomputerRepeatedly add an entry to its right neighbor in a -1, 0, 1 sequence to make it non-decreasing with the fewest operations, or report BRAK if impossible.Medium7Dynamic programmingArrayNo attempts yet3s512 MBJudgeable
LaserChoose up to K rays from the origin to hit the most first-quadrant segments, with no segment hit by two rays.Medium7Dynamic programmingGeometry+2No attempts yet3s512 MBJudgeable
Code BreakingCount digit assignments to a rooted tree that place at least one of M forbidden 5-digit strings on its specified upward path, modulo 1234567.Medium7Dynamic programmingTree+1No attempts yet1s128 MBJudgeable
Xiao Long BaoChoose the order to eat N dumplings in a row to maximize total flavor, with each eaten dumpling adding its bonus to uneaten dumplings within its reach.Medium7Dynamic programmingIntervalsNo attempts yet1s128 MBJudgeable
SkiingStarting at (0,0) with fixed downhill speed and bounded lateral acceleration, choose the longest reachable target sequence with smallest indices on ties.Medium7Dynamic programmingMath+1No attempts yet2s128 MBJudgeable
Split the sequenceSplit the sequence into k+1 contiguous parts so the total product score from the cuts is maximal, and print the score with one optimal cut list.Medium7Dynamic programmingDivide and conquer+2No attempts yet2s128 MBJudgeable