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,704 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Placing TilesGiven a grid with blocked cells, cover every empty cell with 1 x k horizontal or vertical tiles (k is any positive integer, chosen per tile) and minimize the number of tiles.Medium7BacktrackingDynamic programming+2No attempts yet2s512 MBJudgeable
Tofu Seller Jang Hongjun 3Given an N by M grid of letter grades, pick disjoint horizontal or vertical dominoes to maximize the sum of pairwise prices from the price table.Medium7Dynamic programmingBit manipulation+1No attempts yet1s512 MBJudgeable
Junoh Is a Grump!!Count how many distinct strings can be made from a given name by shifting distinct positions total s, each shift 1 to 25.Medium7CombinatoricsDynamic programming+1No attempts yet1s256 MBJudgeable
Longest Palindromic SubstringGiven a lowercase string of up to 100,000 characters, report the length of its longest palindromic substring.Medium7StringString matching+2No attempts yet2s512 MBJudgeable
Why Did the Cow Cross the Road 8Two rows each hold a permutation of N breeds; pair friendly pastures across the road without crossings to maximize the number of crosswalks.Medium7Dynamic programmingIntervals+1No attempts yet2s512 MBJudgeable
Card CollectingCompute the minimum expected time to collect all n cards, choosing when to trade d cards for a chosen card or play for a random pack.Medium7Dynamic programmingProbability+1No attempts yet2s512 MBJudgeable
Counting Palindromes (Small)Count how many subsequences of a string of length up to 30 are palindromes, treating subsequences that use different positions as distinct.Medium7Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Heaps from TreesGiven a rooted tree with a value at each node, find the largest subset in which every ancestor-descendant pair has the ancestor's value strictly larger.Medium7TreeDynamic programming+2No attempts yet2s512 MBJudgeable
Counting Palindromic Subsequences (Large)Count subsequences of a string (positions distinguish repeats) that read as palindromes, modulo 10007.Medium7Dynamic programmingStringNo attempts yet2s512 MBJudgeable
Subin and the Melting CandyStarting at the origin and moving only right or up, visit baskets over time to maximize total candies collected, where a basket's candies shrink by one per time unit.Medium7Dynamic programmingSortingNo attempts yet1s64 MBJudgeable
KUBC League (Large)Given a tournament graph on N players, find the lexicographically smallest longest path starting at player 1.Medium7GraphGreedy+2No attempts yet1s256 MBJudgeable
Zero health with minimum manaEach use of a skill costs more than its previous use by K; find the minimum total mana to remove exactly M health.Medium7Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Junoh is top talent!!In a weighted tree, find a simple path with the maximum number of nodes, then among those pick the one with the smallest total edge weight, and report that weight divided by T rounded up.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
Rainfall StorageGiven N pillars, arrange them in any order and list every total rain volume obtainable, where volume sums the water trapped above each pillar.Medium7Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Hiking GwanaksanOn a graph with distinct vertex heights, each hiker at a vertex must move along an edge to a strictly higher neighbor, repeating until stuck; for every start vertex find the longest such strictly increasing path length.Medium7GraphDynamic programming+2No attempts yet1s512 MBJudgeable
Milk CityOn an N by N grid of milk shops, walk from the top-left to the bottom-right cell moving only right or down, buying packs along the way so the drink types cycle 0,1,2,0,..., and maximize the number of packs bought.Medium7Dynamic programmingMatrixNo attempts yet1s256 MBJudgeable
Delivering GoodsGiven a directed weighted graph and a set of client junctions, find the minimum number of trucks so each client is reached at its shortest-path time.Medium7GraphShortest path+2No attempts yet5s512 MBJudgeable
Nice NumbersInsert digits 2, 4, or 8 anywhere into a given string so repeated right pushes collapse it to one entry, minimizing length.Medium7GreedyDynamic programming+1No attempts yet1s512 MBJudgeable
Stack ConstructionFor each message, compute the minimum number of stack push, pop, and print operations needed to print it and leave the stack empty.Medium7Dynamic programmingString+1No attempts yet2s512 MBJudgeable
Parenting PartneringSplit the 1440 minute day between two parents, respecting fixed busy blocks, so each gets exactly 720 minutes with fewest custody switches.Medium7GreedyIntervals+1No attempts yet5s512 MBJudgeable
Parenting Partnering (Large)Split a daily circle into baby-care blocks for two parents, respecting fixed activity intervals, so each covers 720 minutes with the fewest exchanges.Medium7GreedyDynamic programming+2No attempts yet5s512 MBJudgeable
Fresh Chocolate (Large)Order the groups to maximize how many receive only freshly opened packs, given leftovers must be consumed first and P is at most 4.Medium7GreedyMath+2No attempts yet5s512 MBJudgeable
Mountain Tour (Small)Choose the order for a daily Euler tour of a 2-regular directed multigraph so the finish time, with waits, is minimized.Medium7GraphDynamic programming+2No attempts yet5s512 MBJudgeable
Dice Straight (Large)Each die shows six distinct numbers; choose at most one number per die so the chosen values form a consecutive run, and maximize its length.Medium7GraphDynamic programming+2No attempts yet30s512 MBJudgeable
Good RectanglesPrecompute an answer table so each query asks how many all-zero subrectangles fit inside a given rectangle of an n by m binary grid.Medium7Dynamic programmingPrefix sum+1No attempts yet4s256 MBJudgeable
Coin tossingGiven head counts from tossing two coins whose head probabilities are independent uniform on [0,1], compute the probability that the first coin's probability is smaller.Medium7ProbabilityMath+2No attempts yet2s512 MBJudgeable
Coprime triplesCount index triples i < j < k whose three values have gcd 1, with values up to 10^6 and n up to 10^5.Medium7Number theoryCombinatorics+2No attempts yet2s512 MBJudgeable
Cooking CoursesChoose an academy for each of M courses in order, keeping each academy run between S and E long, avoiding one forbidden switch per academy, and paying a switch fee, to minimize total cost.Medium7Dynamic programmingSliding window+2No attempts yet2s512 MBJudgeable
Moving 2Given an N by N grid of candy amounts, collect the most candy over K monotone paths from (1,1) to (N,N), counting each cell only once.Medium7Dynamic programmingImplementation+1No attempts yet2s512 MBJudgeable
Boolean Expression CompressorGiven a Boolean expression over four variables, find the length of the shortest equivalent expression using NOT, XOR, and AND.Medium7Dynamic programmingBrute force+2No attempts yet2s512 MBJudgeable
Horror Film NightGiven the sets of days each of two people likes films on, find the longest subsequence with no two consecutive films disliked by the same person.Medium7GreedyTwo pointers+1No attempts yet2s512 MBJudgeable
Intelligence InfectionFind the minimum number of spies to message so that every non-enemy spy receives the message and no enemy spy does, given a directed contact graph and a set of enemy spies.Medium7GraphDFS+2No attempts yet2s512 MBJudgeable
Journal EditingGiven theorems that depend on other theorems and multiple possible proofs with costs, find the minimum total cost to prove Theorem 0.Medium7Dynamic programmingGraph+2No attempts yet2s512 MBJudgeable
Going DutchGiven each person's net balance from the receipts, find the minimum number of money transfers that settles everyone to zero.Medium7Dynamic programmingBit manipulation+2No attempts yet2s512 MBJudgeable
Manhattan MorningsChoose a monotone shortest path from house to workplace on the Manhattan grid that passes through as many errand points as possible.Medium7Dynamic programmingSorting+1No attempts yet2s512 MBJudgeable
Most Distinctive CharacterChoose a length-k bit string minimizing the maximum number of agreeing bits with any of n given strings, breaking ties lexicographically.Medium7Bit manipulationDynamic programming+1No attempts yet4s512 MBJudgeable
Flipping CoinsGiven N coins all tails and exactly K fair tosses chosen adaptively, find the maximum expected number of heads at the end.Medium7ProbabilityDynamic programming+1No attempts yet4s512 MBJudgeable
Knightsbridge RisesAssign cranes to buildings so each building's tower ends with lifting power at least its target, minimizing the output lexicographically.Medium7GreedySorting+2No attempts yet4s512 MBJudgeable
K-th DigitGiven X = A + sqrt(B) with |A - sqrt(B)| < 1, find the K-th least significant digit of floor(X^N) for N up to 1e9 and K up to 4.Medium7MathNumber theory+2No attempts yet1s1024 MBJudgeable
Buggy ICPCCount the strings W of the same length as T that produce T on a machine that reverses the line every time a vowel is typed.Medium7CombinatoricsString+1No attempts yet1s1024 MBJudgeable
Fundraising DinnerChoose a subset of people with beauty, fortune, and donation so that no two conflict, and the total donation is maximized.Medium7Dynamic programmingSorting+2No attempts yet1s1024 MBJudgeable
Gates of uncertaintyGiven a binary tree of two-input NAND gates where some gates may be stuck, count input assignments that make the faulty circuit differ from the fault-free one.Medium7TreeDynamic programming+1No attempts yet1s1024 MBJudgeable
Removal GameGiven a circle of numbers, remove them one by one paying the gcd of the two neighbors, and minimize the total cost.Medium7Dynamic programmingNumber theory+1No attempts yet2s512 MBJudgeable
Is-A? Has-A? Who Knows-A?Given is-a and has-a facts between at most 500 classes, apply the four transitivity rules and answer whether each queried relation holds.Medium7GraphDFS+2No attempts yet2s512 MBJudgeable
HopscotchCount lattice paths from (0,0) to (N,N) where each hop increases x by at least X and y by at least Y, modulo 1e9+7.Medium7Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Grid ColoringCount completions of an m by n red/blue grid where every blue cell forces the whole prefix rectangle from the top left corner to be blue.Medium7Dynamic programmingCombinatorics+1No attempts yet1s512 MBJudgeable
Drone PackingChoose items to load onto two drones with separate weight capacities so total value is maximized, with no item split or shared.Medium7Dynamic programmingGreedy+1No attempts yet2s512 MBJudgeable
Deathmatch ScoreboardGiven a partial n-player kill/death table sorted by score, count the completed tables that a finished deathmatch game could produce.Medium7CombinatoricsBrute force+2No attempts yet10s512 MBJudgeable
Round the world ticketCount distinct city sequences, starting and ending at ZAG, that can be flown using a subsequence of the ordered coupons, modulo 1e9+7.Medium7Dynamic programmingHash map+1No attempts yet5s512 MBJudgeable
Robot RaceFor each of up to a million queries on an n by m grid of obstacles, decide whether a monotone path moving only right or down connects the two given empty cells.Medium7Dynamic programmingPrefix sum+2No attempts yet2s1024 MBJudgeable
Single EliminationGiven the fixed win/loss outcome for every pair among 16 players, decide which players can be made champion by choosing all four rounds of pairings.Medium7BacktrackingDivide and conquer+2No attempts yet2s512 MBJudgeable
Friend Palindrome 2Given friends split by parity into girls and boys and a friendship graph, choose the largest group that can be arranged so every non-middle person pairs with an opposite-sex friend.Medium7GraphDynamic programming+2No attempts yet2s512 MBJudgeable
InitialsEach student's directory starts as last-initial plus first-initial; append letters from the full names so names strictly increase in class order, minimizing total letters added.Medium7Dynamic programmingString+2No attempts yet3s512 MBJudgeable
ArtistChoose exactly K blocks from N to minimize (sum of chosen widths) times (sum of chosen heights), where each block keeps its orientation.Medium7Dynamic programmingSorting+2No attempts yet1s512 MBJudgeable
SanCount subsets of skyscrapers forming a non-decreasing-height left-to-right jump sequence whose gold sum reaches at least K.Medium7Dynamic programmingCombinatorics+1No attempts yet1s64 MBJudgeable
Black or WhiteGiven a start row s and target row t of B/W bricks, find the minimum number of strokes, each painting at most k consecutive bricks one color, to reach t.Medium7Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
Column AdditionGiven three n-digit strings, erase the fewest digit columns so the first number plus the second equals the third.Medium7Dynamic programmingString+2No attempts yet2s512 MBJudgeable
HikingOn a bipartite graph of peaks and valleys, two players alternate choosing an unvisited neighbor and the player who cannot move loses; report the winner for every starting peak.Medium7Game theoryGraph+2No attempts yet1s256 MBJudgeable
BricksCount the distinct sets of occupied boxes reachable after M bricks fall, where a brick at an occupied position expands its run left or right.Medium7Dynamic programmingIntervalsNo attempts yet0.2s512 MBJudgeable
Menu TourChoose a sequence of restaurants serving courses 1..C in order within budget B, minimizing total Manhattan travel distance; report -1 if impossible.Medium7Dynamic programmingShortest path+2No attempts yet2s512 MBJudgeable
MacaronsCount the ways to tile an N by M rectangle with 1x1 and 1x2 dominoes, with N at most 8 and M up to 10^18, modulo 10^9.Medium7Dynamic programmingBit manipulation+2No attempts yet5s512 MBJudgeable
IngredientsEach dish has a minimum cost and the prestige that goes with that cheapest way; pick a subset of dishes with total cost at most B maximizing prestige, then report the smallest cost achieving it.Medium7Dynamic programmingGraph+2No attempts yet4s512 MBJudgeable
Candy Wall BurglaryA bandit descends and reascends through shelves connected by sparse ladders, collecting jars at most once; find the maximum candy total.Medium7Dynamic programmingGraph+2No attempts yet2s512 MBJudgeable
Bumped!Given an undirected weighted road graph and up to 1000 directed free flights, find the cheapest s-to-t trip using at most one flight.Medium7GraphShortest path+2No attempts yet2s512 MBJudgeable
Company PicnicIn a tree of employees with speeds, pair each node with at most one neighbor on the parent-child edge, maximizing team count then average team speed.Medium7TreeDynamic programming+1No attempts yet2s512 MBJudgeable
RhombinoesGiven live equilateral triangles on a W by H board, find the maximum number of non-overlapping rhombinoes, each covering two live triangles that share a side.Medium7GraphDynamic programming+2No attempts yet2s512 MBJudgeable
Vera and LCSGiven string A and target K, find the smallest i where A's prefix of length i plus N-i copies of A's least frequent letter has LCS exactly K with A.Medium7StringDynamic programming+1No attempts yet2s256 MBJudgeable
Vera and SortingCount permutations of size N for which a recursive quicksort-like routine performs exactly K comparison steps, modulo 1e9+7.Medium7Dynamic programmingCombinatorics+2No attempts yet2s256 MBJudgeable
MizuyokanGiven a bar divided by N-1 score lines into segments of given lengths, cut along some lines so the longest and shortest resulting pieces differ as little as possible.Medium7Dynamic programmingBinary search+2No attempts yet2s512 MBJudgeable
Minimum Edit 2Compute the minimum number of insertions, deletions, replacements, and adjacent swaps needed to turn string A into string B, with both strings up to length 1000.Medium7Dynamic programmingString+2No attempts yet2s512 MBJudgeable
A fun gameTwo players alternately take one or two numbers from either end of a sequence; decide if the first player can force an even total.Medium7Game theoryDynamic programming+1No attempts yet1s512 MBJudgeable
MateFor each query, count subsequences of S of length D whose last two characters are the given pair XY, modulo 1e9+7.Medium7CombinatoricsDynamic programming+2No attempts yet2s128 MBJudgeable
Rectangle CoverChoose axis-aligned rectangles centered at the origin whose union covers all N points, minimizing the total area.Medium7Dynamic programmingSorting+1No attempts yet1s64 MBJudgeable
Tap Titanz at Moloco (Hard)Given an n by n two-color board, one tap flips a whole connected same-color region; find the minimum taps to make the whole board one color.Medium7GraphBFS+2No attempts yet2s512 MBJudgeable
Separate StringCount the ways to split string t into a sequence of pieces, each of which is one of N given dictionary strings, modulo 1e9+7.Medium7Dynamic programmingTrie+2No attempts yet2s512 MBJudgeable
Snake EscapingGiven a toxicity value for each of 2^L bitmasks, answer Q queries: each query fixes some bits and leaves others free, and asks the sum of values over all matching masks.Medium7Bit manipulationPrefix sum+2No attempts yet2s64 MBJudgeable
Filling a rectangle with blocksCount the ways to tile an N by M rectangle with rectangles of size k by N for any k, each rotatable, modulo 1999.Medium7Dynamic programmingCombinatorics+1No attempts yet1s256 MBJudgeable
Blocks 3Count the tilings of an N by M rectangle using blocks of size k by N for any k, allowing 90-degree rotation, modulo 1999.Medium7Dynamic programmingCombinatorics+2No attempts yet1s256 MBJudgeable
Signals 2Choose a subset of points with distinct x coordinates, sort them by x, and maximize the total Euclidean distance between consecutive chosen points.Medium7Dynamic programmingGeometry+2No attempts yet1.5s256 MBJudgeable
Pokemon HuntPokemon sit on houses along a line, each with a candy value and a deadline; starting at house K, maximize candy collected while walking one house per second.Medium7Dynamic programmingIntervalsNo attempts yet1s512 MBJudgeable
Delivery GuyOn a tree of N restaurants with demand A_i, maximize total delivered peppers in M time units, where each visit costs 1 to deliver and each edge costs 1 to traverse.Medium7TreeDynamic programming+2No attempts yet2s64 MBJudgeable
English RestaurantGiven n tables and random hourly group sizes from 1 to g, find the expected number of seated people after t hours, where each group takes the smallest table that fits.Medium7Dynamic programmingProbability+1No attempts yet2s512 MBJudgeable
Installing AppsChoose a largest subset of apps installable within c free space and order them so each install fits, preferring the lexicographically smallest index set.Medium7Dynamic programmingGreedy+1No attempts yet2s512 MBJudgeable
Knockout TournamentArrange the starting line-up of a knockout tournament so that Dale's probability of winning, given pairwise win odds a/(a+b), is maximized.Medium7Dynamic programmingProbability+1No attempts yet2s512 MBJudgeable
Paul the barista picks coffee beansPick the longest subsequence of the given row so that consecutive picked values are congruent mod k or differ by at most d in absolute value.Medium7Dynamic programmingSegment tree+2No attempts yet1.5s64 MBJudgeable
Heaven's Kitchen 2Given an array of integers, choose two non-overlapping nonempty contiguous subarrays and maximize the product of their sums.Medium7ArrayDynamic programming+2No attempts yet1s128 MBJudgeable
Yonsei Water ParkGiven N stones in a line with values K_i, pick a starting stone and a sequence of distinct stones where each jump moves at most D positions, maximizing the sum of visited values.Medium7Dynamic programmingSegment tree+1No attempts yet1s128 MBJudgeable
TrianglesCount all triangles formed by drawn horizontal and diagonal edges in an ASCII picture of a triangular grid up to 3000 by 6000 vertices.Medium7GeometryBrute force+1No attempts yet6s1024 MBJudgeable
Block GameRemove every block so the heights leave in non-decreasing order, minimizing moves of a machine that walks left and right along the shrinking row.Medium7Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
Regular checkupIn a graph split by a river with B bridges, answer Q queries for the shortest travel time from a given house to a given hospital, or -1 if unreachable.Medium7GraphShortest path+2No attempts yet1.5s256 MBJudgeable
Arrays and gcdCount arrays arr with elements in [1, num] whose running gcd array equals the given array C, modulo 1e9+7.Medium7Number theoryDynamic programming+2No attempts yet0.5s128 MBJudgeable
The Return of the TteokfireCount sequences of M daily bowl counts summing to N, where the first M-1 counts are positive and the M-th is zero.Medium7CombinatoricsMath+1No attempts yet1s128 MBJudgeable
Snow BootsFind the minimum number of boot pairs Farmer John must discard, given a stack-ordered backpack and snow-depth and step-size limits, to walk from tile 1 to tile N.Medium7Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
GiftCount sequences of length N that split into blocks where each block is 0,1,...,L-1 with L at most K, modulo 1e9+7.Medium7Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Cheap DeliveriesGiven a weighted undirected graph and k up to 18 delivery pairs, find the order of deliveries that minimizes total travel distance, or report -1 if some delivery is unreachable.Medium7GraphShortest path+2No attempts yet2s512 MBJudgeable
Apples and BananasDecide the winner of an alternating game where each move removes one apple, one banana, three apples and one banana, or one apple and three bananas from piles of a apples and b bananas.Medium7Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Line of BenthamReplace some people in a line with agents so the total happiness, where each person sums likes over the three ahead, is maximized.Medium7Dynamic programmingGreedyNo attempts yet1s256 MBJudgeable
File RecoveryDelete elements from a sequence so the remainder parses as length-prefixed blocks that end exactly at the last position, minimizing the largest likelihood among deleted elements.Medium7Dynamic programmingBinary search+2No attempts yet2s512 MBJudgeable
CoinsMaintain the probability that the number of heads among N coins is odd, under M point updates to individual coin probabilities, and report which outcome is more likely after each update.Medium7MathProbability+2No attempts yet2s512 MBJudgeable
HypercubeOn the N-hypercube whose arcs join labels differing in one bit, find the largest predecessor and smallest successor of M, then count all paths of length K.Medium7CombinatoricsBit manipulation+2No attempts yet0.2s1024 MBJudgeable