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
WerewolfCount the role assignments with exactly W werewolves that satisfy all accusations and defenses, modulo 1000000007.Medium7GraphDynamic programming+1No attempts yet1s256 MBJudgeable
Early Exam EvacuationEach of M writers seated in an N-row auditorium exits front or back to minimize passing plus crowding cost.Medium7Dynamic programmingSorting+1No attempts yet2s256 MBJudgeable
HotelsCount triplets of distinct towns in a tree whose three pairwise distances are all equal.Medium7TreeDynamic programming+1No attempts yet3s256 MBJudgeable
The Little BirdA bird jumps from tree 1 to tree n in flights of at most k and minimizes landings on trees at least as tall as the takeoff tree.Medium7Dynamic programmingStack+1No attempts yet2s256 MBJudgeable
PackingBuy the fewest backpacks from the shop so all items fit without splitting items or exceeding capacities.Medium7Dynamic programmingBit manipulationNo attempts yet1s256 MBJudgeable
TeamsSplit the row into the most contiguous teams so each student's team size lies within their given range, and count those optimal splits.Medium7Dynamic programmingSegment tree+1No attempts yet5s256 MBJudgeable
PasswordCount length-N strings over the first K uppercase letters that avoid ABCBC and ABABC as substrings, modulo 1,000,000,009.Medium7Dynamic programmingString matchingNo attempts yet1s256 MBJudgeable
Gold MinesPick an axis-aligned rectangle over weighted points to maximize the sum of enclosed weights.Medium7Dynamic programmingPrefix sum+1No attempts yet3s256 MBJudgeable
Relay HorsesMove all petitions sitting on a ring of stations to the capital so the sum of horse days used and days each petition spends traveling is smallest.Medium7Dynamic programmingGreedy+1No attempts yet1s64 MBJudgeable
Bridge RemovalStarting from any island, a crew that spends a bridge length to cross or remove it must delete every bridge of a tree in the shortest total time.Medium7Dynamic programmingTree+1No attempts yet1s256 MBJudgeable
Mattress stain removalCover all stained cells on an m by n grid with the fewest 3 by 3 blocks placed inside the grid.Medium7Dynamic programmingBit manipulationNo attempts yet3s256 MBJudgeable
Switch ArrayFind the fewest restricted toggles that turn each given bit string into all zeros.Medium7RecursionDynamic programming+1No attempts yet1s256 MBJudgeable
The Club TripEach of n classmates rides only if one named classmate also rides; fill up to k bus seats with the largest group that respects every such condition.Medium7GraphDynamic programming+1No attempts yet1s256 MBJudgeable
Road WorkSchedule cars from both ends through one shared lane to minimize how many drivers wait past their patience limit.Medium7Dynamic programmingSimulationNo attempts yet1s512 MBJudgeable
Bounty Hunter Jeong-eunA ship visits every planet sorted by x on an outward and a return monotone leg with minimum total Euclidean length.Medium7Dynamic programmingGeometryNo attempts yet1s256 MBJudgeable
Pontoon BridgeFind the smallest connected set of water squares that touches both banks of a river given as water intervals per row.Medium7Shortest pathDynamic programmingNo attempts yet1s256 MBJudgeable
ShoppingA shopper starts at the entrance, visits each of N shops in a row under the given order constraints, and ends at the exit with the shortest total walk.Medium7Dynamic programmingIntervalsNo attempts yet1s256 MBJudgeable
Circle of digitsSplit the circular digit string into K contiguous parts so the largest part value is as small as possible, and output that value.Medium7Binary searchDynamic programming+1No attempts yet5s256 MBJudgeable
Circle and MarbleEach move shifts one marble along an arrow to the next circle, and you decide if the first or second player wins under best play.Medium7Game theoryTree+1No attempts yet1s256 MBJudgeable
Kebab HouseCount subsets of the work seconds with gaps of at least t+1 such that each kebab misses at most q_i minus x_i ingredients, modulo 1e9+7.Medium7Dynamic programmingCombinatorics+1No attempts yet2s256 MBJudgeable
A Cure for the Common CodeCompute the shortest encoded length of each lowercase string using count-plus-parentheses notation for repeats.Medium7Dynamic programmingStringNo attempts yet5s256 MBJudgeable
Generalized Roman NumeralsGiven a string of Roman letters, list every distinct value it can take under all parenthesizations of the subtract-when-smaller rule.Medium7Dynamic programmingIntervals+1No attempts yet3s256 MBJudgeable
Black and White StonesShagga reorders black and white stones so all black stones stand left of white ones with minimum cost, paying A per swap and A minus B for adjacent swaps.Medium7Dynamic programmingGreedy+1No attempts yet3s256 MBJudgeable
Dividing the namesSplit 2N names into N streets and N avenues so the total length of shortest unique prefixes on all N by N crossing signs is minimal.Medium7TrieDynamic programmingNo attempts yet3s256 MBJudgeable
Two YachtsPick priced time intervals so no day is covered more than twice and the total price is maximal.Medium7Dynamic programmingIntervals+1No attempts yet1s256 MBJudgeable
Power TillerCount distinct positions reachable by steps of lengths 1, 2, 4 and so on moving only right or up inside an A by B rectangle.Medium7Bit manipulationDynamic programming+1No attempts yet3s256 MBJudgeable
Can't stop playingStick each arriving power-of-two block to the left or right end, merge equal neighbours, and report if one block can remain with the smallest direction string.Medium7Dynamic programmingBit manipulation+2No attempts yet10s256 MBJudgeable
VocabularyCount ways to replace every question mark with a lowercase letter so the three words are distinct and in lexicographic order.Medium7Dynamic programmingString+1No attempts yet5s256 MBJudgeable
Alien InvadersDestroy each alien within its time window using bombs, where a bomb of power R kills all aliens present within distance R at cost R, for minimum total fuel.Medium7Dynamic programmingDivide and conquer+2No attempts yet3s256 MBJudgeable
Why-Salesman TourDecide whether a metric graph with up to 14 vertices has a Hamiltonian cycle of total length exactly L.Medium7Dynamic programmingBit manipulation+1No attempts yet9s256 MBJudgeable
The Safe SecretFor each ring rotation, replace each ? with +, - or * and parenthesize to get the min and max values, then join their digits in order.Medium7Dynamic programmingIntervalsNo attempts yet1s256 MBJudgeable
Table Tennis Team LineupReorder the queue with the fewest take-and-reinsert moves so each consecutive block of K holds the next K weakest players.Medium7Dynamic programmingSorting+1No attempts yet1s64 MBJudgeable
KnightsCount non-attacking knight placements on an M by N board with M up to 4 and N up to 1e9, modulo 1000000009.Medium7Dynamic programmingMatrix+1No attempts yet60s256 MBJudgeable
AntennasPlace carrier-specific or shared antennas on a line so each house interval meets a matching coverage interval at minimum cost.Medium7Dynamic programmingSorting+1No attempts yet2s256 MBJudgeable
Apartment floor planCover an N by M floor with integer-sided rectangles that each touch the outer edge so the sum of squared area deviations from K is minimal.Medium7Dynamic programmingDivide and conquer+1No attempts yet2s64 MBJudgeable
LRFill each ? with an allowed character to form a valid L and R expression with the largest possible value, or report invalid.Medium7Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Snake GameGuide a snake that steps forward or climbs one row while reversing direction and eat every apple with the fewest button presses.Medium7Dynamic programmingShortest path+1No attempts yet1s32 MBJudgeable
FrisbeeChoose and order some of up to 20 cows so their total height reaches H while maximizing the worst remaining strength margin.Medium7Dynamic programmingSortingNo attempts yet1s256 MBJudgeable
Cow JogCows start in fixed order with fixed speeds, and you assign the fewest lanes so no two cows in one lane ever meet by time T.Medium7Dynamic programmingBinary search+1No attempts yet1s256 MBJudgeable
Moovie MoovingChoose the fewest movies, each used at most once, whose showings chain together to cover every moment from time 0 to time L.Medium7Dynamic programmingBit manipulation+1No attempts yet1s256 MBJudgeable
Grass CownoisseurStarting from field 1 and returning to it, visit the most distinct fields while traveling at most one directed path backwards.Medium7GraphTopological sort+1No attempts yet1s256 MBJudgeable
SIRO ChallengeJiro starts at station s, visits as many of up to 16 ramen stations as possible, and returns within time t, paying rail travel plus eating time.Medium7Dynamic programmingShortest path+2No attempts yet8s512 MBJudgeable
WTF TransformationChoose the ID array that maximizes the two-phase rotating sum and output that maximum with the lexicographically smallest optimal ID array.Medium7Dynamic programmingPrefix sum+1No attempts yet1s256 MBJudgeable
Cutting the Cake 2JOI chooses the first slice of a round cake, then both sides take exposed ends in turn against an opponent who always takes the larger end.Medium7Game theoryDynamic programming+1No attempts yet2s512 MBJudgeable
Slave to achievements 1Craft as many N-cost daggers as possible and reclaim 0-to-K chips per dagger until fewer than N remain then print each final remainder probability modulo 1e9+7.Medium7Dynamic programmingProbability+2No attempts yet3s256 MBJudgeable
Jan's coloring bookCount proper colorings of one of eight fixed maps using at most three of K colors with adjacent areas different.Medium7GraphCombinatorics+1No attempts yet1s64 MBJudgeable
Library shelf tidyingGiven current and target shelf layouts, find the minimum number of books to lift when sliding a book into an empty spot on the same shelf costs nothing.Medium7Dynamic programmingBinary searchNo attempts yet1s64 MBJudgeable
Cow HopscotchCount paths from the top-left to the bottom-right cell moving down and right where consecutive cells hold different values.Medium7Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Coin type identificationDetermine each coin fixed type from the pairwise weighing results, printing ? when it is not unique.Medium7Union-findTopological sort+2No attempts yet2s512 MBJudgeable
Palindrome Path 3Count the paths from the top-left to the bottom-right corner moving only right or down whose letters form a palindrome, modulo 1000000007.Medium7Dynamic programmingMatrixNo attempts yet1s256 MBJudgeable
Trapped in the HaybalesMeasure the total length of starting positions between sorted bales from which repeated run-up breaks can reach neither the leftmost nor the rightmost bale.Medium7Dynamic programmingSorting+2No attempts yet1s256 MBJudgeable
BowlingCount the distinct bowling games whose frame symbols and running totals match the blurred notes.Medium7Dynamic programmingSimulationNo attempts yet1s256 MBJudgeable
Tug of WarDecide if 2n contestants, each with one left spot, one right spot, and a strength, split into two disjoint teams of n whose strength sums differ by at most k.Medium7GraphDynamic programmingNo attempts yet3s256 MBJudgeable
CateringCover all n event locations with at most k routes starting from the depot so the total equipment moving cost is minimal.Medium7GraphShortest path+1No attempts yet4s256 MBJudgeable
Virtual Keyboard TypingFind the fewest arrow and select presses that type the given text on a sliding-cursor virtual keyboard, including the final Enter.Medium7Dynamic programmingShortest path+1No attempts yet4s256 MBJudgeable
369 Game CountCount numbers from A to B that are multiples of 3 or contain the digit 3, 6, or 9, and output the count modulo 20150523.Medium7Dynamic programmingString+1No attempts yet1s256 MBJudgeable
Cutting an L-shaped paperThe program cuts the given L-shaped sheet with guillotine cuts into integer-sided squares with the fewest pieces.Medium7Dynamic programmingGeometry+1No attempts yet2s256 MBJudgeable
Queen BeeSimulate N days of growth on an M by M grid where each inner cell copies the largest daily growth among its left, upper-left, and upper neighbors.Medium7Dynamic programmingPrefix sumNo attempts yet2s256 MBJudgeable
MatChoose a set of top-anchored and bottom-anchored rectangles with disjoint interiors that maximizes total profit.Medium7Dynamic programmingIntervals+1No attempts yet1s512 MBJudgeable
A Journey to GreecePlan a round trip from Athens that visits every listed site within time G, using at most one fixed-time taxi jump.Medium7Dynamic programmingShortest path+1No attempts yet2s1024 MBJudgeable
SouvenirsBuy souvenirs from merchants in order with gold and silver coins and choose how to pay each price to maximize the number bought.Medium7Dynamic programmingGreedy+1No attempts yet1s256 MBJudgeable
Block StackingCount distinct front-view colorings of supported stacks of width W and height at most H built from unlimited blocks of widths 1 to K, modulo 1e9+7.Medium7Dynamic programmingCombinatorics+1No attempts yet1s32 MBJudgeable
Covering the gridPlace corner-touching rectangles chaining from the top-left cell to the bottom-right cell to maximize the sum of covered cell values.Medium7Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Gift BoxesStarting from sector 0 of a circular hall, a courier with capacity K must hand one gift to each of N teams and return, minimizing total walking time.Medium7Dynamic programmingGreedyNo attempts yet3s512 MBJudgeable
Cutting the Tofu BoardPair up adjacent cells of a graded N by N board to maximize the sum of pair prices, leaving cells unpaired when that pays more.Medium7Dynamic programmingBit manipulation+1No attempts yet1s256 MBJudgeable
Tetris 2Count the ways to tile a 3 by N rectangle with the six tetrominoes except the straight piece, modulo 1,000,000.Medium7Dynamic programmingMatrixNo attempts yet2s256 MBJudgeable
Calvinball championshipGiven a valid team-number sequence, compute its 1-based lexicographic rank among all such records for n players, modulo 1000007.Medium7CombinatoricsDynamic programmingNo attempts yet1s64 MBJudgeable
School CanteenCount length-n menus over k meals with no meal repeated l times in a row, modulo 4000000009.Medium7Dynamic programmingMatrix+1No attempts yet5s256 MBJudgeable
Calvinball team splitSplit up to 16 players into the fewest teams with no disliked pair sharing a team, breaking ties by the smallest assignment sequence.Medium7GraphBacktracking+2No attempts yet1s256 MBJudgeable
KimchiPick bury and take-out days at most D apart to maximize aging days times take-out temperature plus crock value while temperatures fall.Medium7Dynamic programmingSliding window+1No attempts yet1s256 MBJudgeable
500-Yen SavingVisit shops in order, paying with held coins and bills, to collect the most 500-yen coins in change and spend the least for them.Medium7Dynamic programmingSimulation+1No attempts yet8s256 MBJudgeable
Cutting BrowniesGiven a B by D brownie sheet where Harry cuts depth and Vicky cuts breadth, decide if the named starting player has a forced win.Medium7Game theoryDynamic programming+1No attempts yet2s256 MBJudgeable
Shortest Boolean ExpressionGiven a fully parenthesized boolean expression over x, y, and z with &, |, and !, print the length of the shortest equivalent expression, ignoring spaces.Medium7Dynamic programmingBrute force+1No attempts yet1s256 MBJudgeable
Bicycle picture puzzleThe program reads W, H, and S and prints the probability that a random scramble needs fewer optimal swaps than S.Medium7CombinatoricsProbability+2No attempts yet1s256 MBJudgeable
Ambulance AnticsPlan tours from the hospital that carry up to three patients each to bring every patient back in the least total driving time.Medium7Dynamic programmingShortest path+1No attempts yet2s256 MBJudgeable
Counting Soundex StringsCount case-insensitive strings up to length L whose Soundex code equals the given code, modulo 1000000007.Medium7Dynamic programmingString+1No attempts yet1s256 MBJudgeable
Sheep FrenzyMove across a grid with mountains to reach every sheep and spend one second eating each, using the fewest seconds, or report impossible.Medium7Dynamic programmingBFS+1No attempts yet1s256 MBJudgeable
Longest Common PathTwo friends each walk a shortest route from school to their own home, and the goal is to maximize the shared consecutive stretch of both routes.Medium7Shortest pathGraph+1No attempts yet1s256 MBJudgeable
Kings on a ChessboardCount the ways to place k non-attacking kings on an x by y board and print each answer modulo 1,000,000,007.Medium7Dynamic programmingBit manipulation+1No attempts yet5s256 MBJudgeable
String StretchingGiven a lowercase string up to length 200, find the shortest base string that builds it by repeated insertions anywhere, breaking ties alphabetically.Medium7Dynamic programmingString+1No attempts yet1s256 MBJudgeable
SongGiven a 26 by 26 pair score table, pick an L-note song starting from C that maximizes the sum of adjacent pair scores.Medium7Dynamic programmingMatrix+1No attempts yet1s256 MBJudgeable
Design a TreeCount binary tree shapes with exactly N left edges and M right edges modulo 9999991 for up to 10000 queries.Medium7CombinatoricsDynamic programming+1No attempts yet3s256 MBJudgeable
Hero PowerEarn charge during star phrases and spend it on activations that double note points without wiping future phrases to maximize the score.Medium7Dynamic programmingGreedy+1No attempts yet1s256 MBJudgeable
Alicia's Afternoon AmbleVisit all points on a bitonic tour from the leftmost hotel to the rightmost parlour and back, minimizing total Euclidean length.Medium7Dynamic programmingGeometry+1No attempts yet1s256 MBJudgeable
String GameFor each game, decide if Alice wins when both players alternately delete the first or last letter until the string matches the target length.Medium7Game theoryString matching+1No attempts yet1s256 MBJudgeable
Power EggsFind the fewest egg drops in the worst case that pin down the highest safe floor for N floors and K eggs, or report Impossible past 32.Medium7Dynamic programmingCombinatorics+1No attempts yet1s256 MBJudgeable
The Running GamePick disjoint segments of the given sequence so the sum of each segment weighted by its position inside the segment is as large as possible.Medium7Dynamic programmingPrefix sum+1No attempts yet1s512 MBJudgeable
Optimal ability loadoutChoose a subset of abilities with given trigger chances and damage values to maximize the expected damage of one attack under a random trigger order.Medium7Dynamic programmingProbabilityNo attempts yet1s512 MBJudgeable
Choo ChooPassengers request trips between numbered cities with per-person fares, and the train picks whom to board within its capacity to maximize total fare revenue.Medium7GraphShortest path+1No attempts yet1s256 MBJudgeable
Taxi sharingSplit up to 15 employees into taxis of four or fewer and order each drop-off route to minimize total distance fares plus boarding fees.Medium7Dynamic programmingShortest path+1No attempts yet1s256 MBJudgeable
Word by mouthSimulate the recursive WBM(m) vote, where faulty friends always forward cat, and report each loyal friend's majority word.Medium7SimulationDynamic programming+1No attempts yet3s256 MBJudgeable
Chess TournamentCount the equal two-team splits in which every pair across the teams played at least once, and print the lexicographically smallest team containing player 1.Medium7GraphUnion-find+1No attempts yet3s256 MBJudgeable
RiskCompute the attacker win probability in a Risk battle with D-sided dice where the defender picks one or two dice after seeing the attack roll.Medium7Dynamic programmingProbability+2No attempts yet2s256 MBJudgeable
Journey to "The World's Start"Pick the cheapest travel card whose range lets you ride from stop 1 to stop n with transfer delays within t minutes.Medium7Dynamic programmingBinary search+1No attempts yet2s256 MBJudgeable
Aqueduct ConstructionEach town must connect to a distinct spring through downhill hops of limited length so the combined aqueduct length is minimal.Medium7Shortest pathGraph+1No attempts yet3s256 MBJudgeable
Coin ExchangeFind the fewest swaps along graph edges that place every black coin on a black vertex and every white coin on a white vertex.Medium7Shortest pathGraph+1No attempts yet8s256 MBJudgeable
Exposing corruptionBribe members to switch parties within a budget while keeping rivals in different parties, and report the largest achievable DSP and PPP sizes.Medium7Dynamic programmingGraph+1No attempts yet3s256 MBJudgeable
Keep it energizedBuy energy packs at level shops so the stored energy covers each level cost in order for the least total cash.Medium7Dynamic programmingSegment tree+2No attempts yet3s256 MBJudgeable
CLARKSONSplit the lyrics into consecutive parts that each appear in the script and maximize the shortest part length.Medium7String matchingBinary search+1No attempts yet1s256 MBJudgeable
Stepping Stones on Ingyeong LakeChoose stones from 1 to N with jumps of length at most K so the product of the chosen numbers has as few trailing zeros as possible.Medium7Dynamic programmingGraph+1No attempts yet5s256 MBJudgeable