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 results907 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Seat SwappingGiven N students each with a team label (K up to 8), find the minimum adjacent swaps to group each team into one contiguous block in some chosen team order.Medium7Dynamic programmingBit manipulation+1No attempts yet2s128 MBJudgeable
Sitting and StandingSimulate a cyclic cellular automaton of standing or sitting students for up to a billion steps efficiently using the XOR-with-neighbor structure.Medium7Bit manipulationMath+1No attempts yet10s128 MBJudgeable
Line UpGiven N students and M precedence constraints, compute the minimum and maximum possible position each student can occupy in any valid linear order, or report impossibility if a cycle exists.Medium7Topological sortGraph+1No attempts yet2s128 MBJudgeable
Covering Holes in a BoardGiven a grid of holes, find the minimum number of horizontal or vertical tape strips (which may overlap on hole cells but never cover a non-hole cell) needed to cover every hole.Medium7GraphBit manipulation+2No attempts yet2s128 MBJudgeable
I²CParse raw I2C SCL/SDA bit-sample sequences to decode start/stop bits, address, direction, ACKs, and data bytes, reporting the transaction or the first protocol error.Medium7SimulationString+2No attempts yet1s128 MBJudgeable
Romantic KingGiven a grid with a start, an end, and up to 16 gift trees where movement speed decreases with carried gifts, find the maximum number of gifts deliverable within a time limit.Medium7BFSDynamic programming+1No attempts yet10s128 MBJudgeable
Donghyuk, King of the Board GameGiven a board colored by AND of bit patterns of row and column indices, count gray cells visited in the first K steps of a zigzag diagonal traversal of an R x C grid.Medium7MathBit manipulation+2No attempts yet1s128 MBJudgeable
TV SwitchesFind the minimum number of switch presses, where pressing a switch releases only a fixed subset of others, to reach a state where only switch 3 is pressed.Medium7BFSBit manipulation+1No attempts yet1s128 MBJudgeable
Bitwise ExpressionsGiven ranges for variables combined by OR within groups and AND across groups, find the maximum achievable value of the resulting bitwise expression.Medium7Bit manipulationGreedy+1No attempts yet1s128 MBJudgeable
Strange BillboardFind the minimum number of tile taps (a Lights Out style toggle puzzle) needed to make an R x C grid all white, or report impossibility.Medium7Bit manipulationBrute force+2No attempts yet1s128 MBJudgeable
Binary Stirling NumbersGiven n and m up to 1e9, determine the parity of the Stirling number of the second kind S(n, m) for many test cases efficiently.Medium7Bit manipulationMath+2No attempts yet1s128 MBJudgeable
High SecurityGiven up to 50000 length-5 passwords over 62 characters, count pairs of passwords for each Hamming distance from 0 to 5.Medium7StringCombinatorics+2No attempts yet3s256 MBJudgeable
Orthogonal ClosureGiven two binary strings, decide whether T equals the XOR of some pair of circular shifts of S, requiring an efficient algorithm beyond brute force for n up to 5000.Medium7String matchingBit manipulation+1No attempts yet2s64 MBJudgeable
Digital ClockDetermine every plausible starting real time for a broken seven-segment clock, given a sequence of minute-by-minute observed displays where some segments are permanently dead.Medium7Bit manipulationSimulation+2No attempts yet1s128 MBJudgeable
Let There Be LightGiven up to 2000 balloons blocking up to 15 point lights from a target point, choose at most R balloons to remove to maximize total illumination, computed via geometric occlusion and a min-cut/greedy set-cover style optimization over light-blocking sets, printed as an exact fraction.Medium7GeometryBit manipulation+2No attempts yet5s128 MBJudgeable
Awkward LightsGiven a grid where toggling a switch flips lights at a fixed Manhattan distance, decide over GF(2) whether all lights can be turned off simultaneously.Medium7MathBit manipulation+2No attempts yet1s128 MBJudgeable
Exact MeasurementEach box offers up to q_i masses of weight 10^k_i; find the fewest boxes to open so the chosen masses sum to exactly x.Medium7Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
HyperdromeCount substrings of S whose characters can be rearranged into a palindrome, where only the parity of each letter's count matters.Medium7Bit manipulationPrefix sum+2No attempts yet2s128 MBJudgeable
Sofa, So GoodGiven framing and upholstering time matrices, find the minimum-cost framing assignment, then the minimum-cost upholstering assignment, and report each worker's schedule and total idle time.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Moving PointsFind the least time for one chaser to intercept N moving targets in order when the chaser is faster than every target.Medium7Dynamic programmingGeometry+2No attempts yet1s128 MBJudgeable
Counting BitsCount integers in [LO, HI] whose number of halving steps under the popcount map reaches 1 in exactly X steps.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
ShoppingGiven weighted roads and up to 10 stores, find the shortest round trip from house 0 visiting every store.Medium7GraphShortest path+2No attempts yet3s128 MBJudgeable
RooksGiven a 15x15 board of marked squares, find the minimum number of rooks needed so every marked square lies in a chosen row or column.Medium7GreedyBrute force+2No attempts yet1s128 MBJudgeable
YahtzeeGiven 13 rounds of five dice, assign each round to a distinct Yahtzee category to maximize total score including the upper-section bonus.Medium7Dynamic programmingBit manipulation+1No attempts yet1s128 MBJudgeable
Rings and RunesValidate the runes for several gates, report the highest-priority error, then decide if the resulting 3-CNF formula is satisfiable.Medium7SimulationImplementation+2No attempts yet1s128 MBJudgeable
Save the Python Programmers!Six labeled teams on a graph must swap houses, moving one team per night into an adjacent empty house while strictly alternating team type; find the minimum number of nights or report impossibility.Medium7BFSGraph+2No attempts yet1s128 MBJudgeable
PegsGiven a 5x5 peg solitaire board with empty, peg, and blocked cells, find the minimum number of pegs reachable by any sequence of horizontal or vertical jumps.Medium7DFSBacktracking+2No attempts yet1s128 MBJudgeable
Shut the BoxGiven N pieces labeled 1 to N and up to T turn values, mark disjoint sets of unmarked pieces summing exactly to each turn value in order, and find the largest total number of pieces markable.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
PlanksGiven a 10x10 grid of stumps and several sets of plank lengths, find the minimum number of planks needed to walk from the top-left stump to the bottom-right stump using each plank at most once.Medium7GraphBFS+2No attempts yet1s128 MBJudgeable
Knight StoryAssign N knights to N distinct target cells on an infinite chessboard to minimize the total number of knight moves.Medium7Dynamic programmingShortest path+2No attempts yet1s128 MBJudgeable
Walsh MatrixSum entries in one row of a Walsh matrix over columns S through E, where the matrix size 2^N can reach 2^60.Medium7Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
And Then, How Many Are There?Given stacked discs of four colors, repeatedly remove two same-colored discs that are both uncovered; find the maximum number of discs removable.Medium7Dynamic programmingBit manipulation+2No attempts yet5s128 MBJudgeable
Traveling by StagecoachWith up to 8 one-use tickets, each giving a speed, find the fastest route from city a to city b, or report Impossible.Medium7GraphShortest path+2No attempts yet3s128 MBJudgeable
Robot VacuumFind the minimum number of moves for a robot to visit and clean all dirty cells in a grid with furniture, or report -1 if some are unreachable.Medium7BFSShortest path+2No attempts yet1s256 MBJudgeable
Power BloggerFind the cheapest closed walk from city 1 that traverses every required edge at least once, using optional extra edges.Medium7GraphDynamic programming+2No attempts yet1s128 MBJudgeable
Allergy TestFind the shortest non-adaptive schedule for applying allergens on a single morning each day so that every reaction pattern identifies exactly the allergy set.Medium7CombinatoricsBit manipulation+2No attempts yet1s128 MBJudgeable
Whac-a-MoleGiven each mole's position and time, find the maximum number of moles whacked while the hammer moves at most distance d between time steps.Medium7Dynamic programmingGeometry+1No attempts yet1s128 MBJudgeable
BarteringGiven starting items, wanted items, and up to 20 barter trades usable at most M times, find the fewest trades to hold all wanted items while never exceeding 5 held items.Medium7BFSGraph+2No attempts yet1s128 MBJudgeable
Protect Our Treasure!Given each pirate's set of keys, list every minimal group whose union covers all locks, ordered by size then lexicographically.Medium7CombinatoricsBrute force+2No attempts yet1s128 MBJudgeable
Polly Wants a CrackerMatch each spoken word to a distinct original word minimizing total Levenshtein edit distance, and report that minimum sum.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
EvolutionGiven N DNA strings linked in an unknown parent-child order, compute each creature's probability of being the original ancestor.Medium7ProbabilityBit manipulation+1No attempts yet1s128 MBJudgeable
Queen GameGiven N queens on an R by C board that move up, left, or up-left, decide if the first player wins with optimal play.Medium7Game theoryMath+1No attempts yet1s128 MBJudgeable
Uncle Tom's Inherited LandGiven a grid where at most 50 squares are usable land and the rest are ponds, find the maximum number of 1x2 dominoes that tile the usable squares.Medium7GraphDynamic programming+2No attempts yet1s128 MBJudgeable
BlinkEach bulb toggles when its left neighbor was on the previous step; given N up to 16 bulbs and a step count B up to 10^15, report the final states.Medium7MatrixBit manipulation+2No attempts yet1s128 MBJudgeable
RelocationGiven an undirected weighted graph with up to 5 market towns, pick a non-market town as home and an order to visit all markets and return, minimizing total distance.Medium7Shortest pathGraph+2No attempts yet1s128 MBJudgeable
Binary SudokuGiven a 9x9 grid of 0s and 1s, find the fewest toggles so that every row, column, and 3x3 block has an even number of 1s.Medium7MathBit manipulation+1No attempts yet1s128 MBJudgeable
Corn FieldsCount subsets of fertile cells in an M by N grid, M,N at most 12, with no two chosen cells sharing an edge, modulo 100000000.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Cow YahtzeeCount ordered rolls of N dice with S sides that satisfy at least one OR-ed expression, where each expression ANDs forms like WxR meaning at least W copies of face R.Medium7CombinatoricsMath+2No attempts yet1s128 MBJudgeable
Gold Balanced LineupGiven N cows each with a K-bit feature ID, find the longest contiguous range where every one of the K features appears the same number of times.Medium7Hash mapPrefix sum+2No attempts yet1s128 MBJudgeable
DiningEach cow likes certain foods and drinks, each item can go to one cow; maximize the number of cows that get a liked food and a liked drink.Medium7GraphDynamic programming+2No attempts yet1s128 MBJudgeable
Islands and BridgesFind the maximum score of a Hamilton path on a graph where the score adds vertex values, edge products, and triangle products, and count how many paths achieve it.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
It's not a Bug, it's a Feature!Each bug state is a bitmask; find the shortest total patch time from all bugs present to no bugs, where patches have presence and absence preconditions.Medium7GraphShortest path+2No attempts yet1s128 MBJudgeable
Help BobGiven up to 15 pizzas with prices, areas, and stacked discount coupons unlocked by buying other pizzas, find the minimum total price over total area of any nonempty purchase order.Medium7Dynamic programmingBit manipulation+1No attempts yet1s128 MBJudgeable
Bus Clock DisplayGiven up to 100 partial 7-segment clock readings with min and max elapsed minutes between consecutive readings, determine the time at each reading or report how many possibilities remain.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Measuring Problem DifficultyGiven three permutations of the numbers 1 to N, count pairs whose relative order is identical in all three orderings.Medium7SortingDivide and conquer+2No attempts yet3s128 MBJudgeable
Wooden FenceGiven up to 16 trees with coordinates, values, and wood lengths, choose trees to cut so their total wood covers the convex hull perimeter of the rest, minimizing lost value.Medium7GeometryBrute force+2No attempts yet1s128 MBJudgeable
Mysterious VillaGiven up to 10 rooms with doors and switches that may control other rooms' lights, find the minimum number of moves and toggles to reach the bedroom with only its light on.Medium7BFSGraph+2No attempts yet1s128 MBJudgeable
S-NimGiven a move set S, decide for each position whether the S-Nim game is a win or a loss by computing Grundy numbers and XORing them over the heaps.Medium7Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
Sylvester constructionGiven a Hadamard matrix built by the Sylvester doubling rule, print a small rectangular sub-matrix specified by its top-left corner.Medium7Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
Odd Loving BakersSimulate monthly celebrations where bakers with an odd chalk count win and add marks to their favorite bakers; find the number of winners at celebration t up to 1e9.Medium7Bit manipulationMath+2No attempts yet1s128 MBJudgeable
Letter ArithmeticAssign distinct digits to letters so that each given letter word plus a second equals a third, then print the three numeric values.Medium7BacktrackingMath+2No attempts yet1s128 MBJudgeable
Shift RegisterGiven the first 2N output bits of a linear feedback shift register, recover the N switch values, choosing the lexicographically smallest valid setting or reporting -1.Medium7MathBit manipulation+2No attempts yet1s128 MBJudgeable
A New BeginningFind the fastest route through airport flight graph, refuelling at up to 20 airports within tank capacity, using great-circle distances.Medium7GraphShortest path+1No attempts yet2s128 MBJudgeable
Cycle DetectionGiven a graph on at most 20 vertices, for each edge that lies on a cycle, count how many distinct simple cycles contain it.Medium7GraphBrute force+2No attempts yet1s128 MBJudgeable
Color PaletteMaintain a set of K-bit colors under insertions and, for each query color, return the stored color with the maximum number of matching bit positions, breaking ties by smallest value.Medium7TrieBit manipulation+2No attempts yet3s1024 MBJudgeable
IOI PhotosEach order lists photo ranges on named rolls; choose for every roll to print individually, print the whole roll, or buy all rolls, minimizing total cost.Medium7Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Destroying SquaresGiven an n x n matchstick grid (n <= 5) with some sticks already removed, find the minimum number of additional sticks to remove so that no square remains complete.Medium7BacktrackingBit manipulation+2No attempts yet5s128 MBJudgeable
PipesGiven a grid of modules with costs on interior walls, find the minimum-cost cycle that visits every module exactly once, starting and ending at the service module.Medium7Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Queen KingdomOn an n by n board with pillars blocking queens' attacks, find the maximum number of non-attacking queens and the number of placements attaining it.Medium7BacktrackingBrute force+2No attempts yet2s128 MBJudgeable
ParityGiven n binary strings and target bits, find the smallest column subset of size at most k whose XOR over each string matches its bit.Medium7Bit manipulationGreedy+2No attempts yet10s512 MBJudgeable
RobotFind the shortest travel time for a robot that moves at speed 1 and turns 1 degree per second, hopping between points within distance R.Medium7GraphShortest path+2No attempts yet1s128 MBJudgeable
Better and Faster!Compute a CRC-style bit checksum of a string after each of up to 1e5 character substitutions, fast enough that recomputing from scratch times out.Medium7Bit manipulationMath+1No attempts yet2s512 MBJudgeable
(False) facesGiven a 0/1 matrix of proposed left-right pairs, decide whether the number of perfect matchings is divisible by 4.Medium7CombinatoricsMath+2No attempts yet5s512 MBJudgeable
Vase CollectionGiven up to 100 shape-decoration pairs drawn from a 36 by 36 grid, find the largest k for which some k shapes and k decorations form a complete k by k block of owned pairs.Medium7Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Violet Jigsaw PuzzleCount how many ways to place and rotate the given pieces into an n by m rectangle so that all touching sides match tab-to-blank and border sides are flat.Medium7BacktrackingImplementation+1No attempts yet5s128 MBJudgeable
ChainGiven which rings of a bytish chain are on a bar, find the minimum number of legal put-on/take-off moves to remove all rings.Medium7Dynamic programmingRecursion+2No attempts yet3s512 MBJudgeable
PrimitivusGiven a set of ordered pairs, find the shortest sequence in which every pair appears consecutively at least once.Medium7GraphShortest path+2No attempts yet3s128 MBJudgeable
Multiset Permutation RankGiven one permutation of a multiset, compute its lexicographic rank among all distinct permutations, modulo m.Medium7CombinatoricsMath+2No attempts yet2s128 MBJudgeable
HexerFind the shortest walk from town 1 to town n where each road can be used only after collecting swords for all monster kinds on it.Medium7Shortest pathGraph+2No attempts yet1s128 MBJudgeable
WalkGiven up to one million missing strings among n-bit names, decide whether two present names are connected through single-bit flips avoiding blocked names.Medium7BFSGraph+2No attempts yet5s256 MBJudgeable
SweetsPartition n boxes (n up to 24) of sweets into three groups with sums A <= D <= B, minimizing B - A.Medium7Brute forceGreedy+2No attempts yet2s512 MBJudgeable
MosaicismFor each phage, count ordered pairs of genes and pairs of other phages where one gene has a homolog in one phage and the other gene has a homolog in the other.Medium7CombinatoricsBit manipulation+1No attempts yet1s128 MBJudgeable
RooksGiven an n x n 0/1 board, decide whether the number of ways to place n non-attacking rooks on the 1-cells is odd or even.Medium7CombinatoricsMath+2No attempts yet1s128 MBJudgeable
Interplanetary VacationFor each of n planets, compute the Manhattan distance to the farthest planet.Medium7MathBit manipulation+2No attempts yet1s128 MBJudgeable
Three-bit Computers Strike BackGiven up to five functions on n states, decide whether some composition maps every state to 0.Medium7GraphBFS+2No attempts yet1s128 MBJudgeable
RoundupCount the axis-aligned squares of side at least 2 whose border cells are all 1 in an n by n binary grid.Medium7Prefix sumMatrix+1No attempts yet1s128 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
EquipmentChoose exactly K of N pieces, each with five scores, to maximize the sum of the five category maxima.Medium7Brute forceBit manipulation+1No attempts yet5s128 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
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
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
Card GameTwo players alternately pick cards and OR the value into a shared number, losing by completing 511 or moving with no cards left.Medium7Game theoryBit manipulationNo attempts yet1s128 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
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
Hack ProtectionCount the subarrays of the given array whose bitwise XOR equals their bitwise AND.Medium7Bit manipulationPrefix sum+2No attempts yet1s128 MBJudgeable
JanosikCount how many money bags Janosik pockets when n caskets holding 1 to n bags are emptied by the smallest-first split, pocket, or hand-out rule.Medium7MathBit manipulationNo attempts yet1s128 MBJudgeable
XOR Set ExpansionGiven an initial integer set, count the expansion rounds that add XORs of current and original elements until the set stops growing.Medium7Bit manipulationBFS+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
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
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