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
Radio CoverageChoose a non-overlapping subset of at most 10 candidate disks inside a base disk to maximize the union area of the base and chosen disks.Medium6GeometryBrute force+1No attempts yet3s128 MBJudgeable
ChecksumAppend zeros to a bit message, divide the polynomial over F2 by a generator, output the remainder as decimal, or ERROR if the generator is composite.Medium6MathNumber theory+2No attempts yet1s128 MBJudgeable
XOR NetsGiven a XOR net with n inputs, count how many binary words in the range [a, b] make the net output 1.Medium6Bit manipulationImplementation+2No attempts yet1s128 MBJudgeable
KnightsOn a 3 by n board with one possibly blocked square per column, place the maximum number of non-attacking knights and count the number of maximum placements.Medium6Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Truth Fraction of a FormulaGiven a DNF formula over n variables, count the valuations that satisfy at least one clause and print the fraction over 2^n as an exact decimal.Medium6Bit manipulationCombinatorics+1No attempts yet1s128 MBJudgeable
Signed Binary ExpansionGiven a decimal integer with up to 500 digits, find the smallest possible count of nonzero digits in a signed binary expansion.Medium6Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Moving PegsJump pegs over lines of pegs on a 15-hole triangle to leave one peg in the starting hole in the fewest moves.Medium6BFSBrute force+1No attempts yet1s128 MBJudgeable
Contest Problem AssignmentSplit up to ten contest problems among three members with individual time limits to solve the largest possible count.Medium6Dynamic programmingBit manipulationNo attempts yet1s128 MBJudgeable
Who needs 8 queens when you can have N?Find the lexicographically smallest placement of N non-attacking queens on an N by N board for each test case.Medium6BacktrackingRecursion+1No attempts yet1s128 MBJudgeable
Suspicious OrdersCount the cliques in a network of up to 20 people whose combined ordered items cover at least one of the given attack combinations.Medium6BacktrackingBit manipulation+1No attempts yet1s128 MBJudgeable
InfluenceFrom the candidate set X, pick the person who reaches the most people through transitive influence, breaking ties by smallest id.Medium6Topological sortGraph+1No attempts yet3s128 MBJudgeable
Friendship GraphDecide up to 200000 reachability queries on a directed graph with 2000 vertices, printing 1 when Y is reachable from X.Medium6GraphDFS+2No attempts yet2s128 MBJudgeable
LazycatFind the shortest walk on a grid with walls that starts at S, visits every food cell, then ends at the bed.Medium6Dynamic programmingBFS+1No attempts yet2s512 MBJudgeable
Unicycle countingFind the smallest number of arithmetic progressions that leave marks exactly at the observed road positions.Medium6Dynamic programmingBit manipulation+2No attempts yet2s256 MBJudgeable
Web Service DependenciesCount the launch orders that place each container after all of its dependencies for each configuration.Medium6Dynamic programmingTopological sort+1No attempts yet1s256 MBJudgeable
SuperbullPick N minus 1 pairings that connect all team IDs into one group so the sum of pairwise XOR values is as large as possible.Medium6Minimum spanning treeGraph+1No attempts yet1s256 MBJudgeable
ImplicationGiven formulas assumed true, decide for each query formula whether it holds under every assignment that satisfies all assumptions.Medium6Brute forceBit manipulation+1No attempts yet2s256 MBJudgeable
4×n TilingCount the ways to tile a 4 by N board with 1 by 3 and 3 by 1 trominoes modulo 1000000007 for each test case.Medium6Dynamic programmingBit manipulationNo attempts yet2s256 MBJudgeable
Coin Turning GameGiven a row of heads and tails, decide if the first player wins the interval-flip game and report the smallest winning first move.Medium6Game theoryDynamic programming+2No attempts yet2s256 MBJudgeable
Dance RecitalReorder the given routines so the total number of dancers shared by consecutive routines is as small as possible.Medium6Dynamic programmingBit manipulationNo attempts yet1s256 MBJudgeable
Frodo and the MonsterSimulate up to 200000 cuts on the head count where odd cuts add the largest smaller prime and even cuts remove every head with the same binary popcount.Medium6SimulationNumber theory+2No attempts yet1s256 MBJudgeable
BankDecide whether M banknotes can be distributed to N people so each person receives exactly the owed salary.Medium6Dynamic programmingBit manipulationNo attempts yet1s256 MBJudgeable
NimbleEach turn slides one coin left along numbered squares, so print which player moves the last coin onto square zero under optimal play.Medium6Game theoryBit manipulationNo attempts yet2s512 MBJudgeable
XorbonacciGiven the first K terms of an XOR recurrence, answer many queries asking for the XOR of terms l through r with indices up to 1e18.Medium6MathPrefix sum+1No attempts yet1s64 MBJudgeable
IP Address SummarizationMerge the given IPv4 subnets and print the shortest ordered list of normalized subnets that covers exactly the same addresses.Medium6IntervalsBit manipulation+2No attempts yet5s512 MBJudgeable
IP Address Summarization (Large)The task merges the given IPv4 subnets into the shortest sorted list of normalized subnets covering exactly the same addresses.Medium6TrieBit manipulation+1No attempts yet5s512 MBJudgeable
River Flow (Small)Find the fewest farmers whose power-of-two toggling cycles explain N days of river flow, or declare the record impossible.Medium6Brute forceBit manipulation+1No attempts yet5s512 MBJudgeable
Cut Tiles (Large)Pack square tiles with power-of-two sides into the fewest MxM tiles using only side-parallel cuts.Medium6GreedySorting+1No attempts yet5s512 MBJudgeable
Charging Chaos (Large)Find a bit mask applied to every outlet string that makes the outlet set match the device set with the fewest flipped bits, or report that it is impossible.Medium6Bit manipulationHash map+1No attempts yet5s512 MBJudgeable
Rational Number TreeGiven the infinite binary tree that lists every positive rational once, find the nth fraction in level order and the level-order position of a given fraction.Medium6MathNumber theory+2No attempts yet5s512 MBJudgeable
King (Small)On a board of at most 16 squares with burned cells, a king moves to unvisited neighbors; decide who wins under optimal play.Medium6Game theoryDFS+1No attempts yet5s512 MBJudgeable
Painting blocksCount colorings of N blocks with 4 colors so that the number of red and yellow blocks are both even, modulo 10007.Medium6CombinatoricsMath+2No attempts yet2s512 MBJudgeable
Colorful VillageMaintain N houses under range repaint operations and answer queries counting how many of the T colors appear in a range.Medium6Segment treeBit manipulation+2No attempts yet2s512 MBJudgeable
TrislePartition N powers into three nonempty groups to maximize the sum of the three XOR values.Medium6Dynamic programmingBit manipulation+1No attempts yet2s512 MBJudgeable
Good SetsCount nonempty subsets of {1,...,N} whose decimal digits, pooled together, use each digit 0-9 at most once.Medium6Bit manipulationCombinatorics+1No attempts yet2s512 MBJudgeable
OR Score of a SequenceSplit the array into K contiguous non-empty groups and maximize the sum of each group's bitwise OR.Medium6Dynamic programmingBit manipulation+1No attempts yet2s512 MBJudgeable
Maximum XOR of two numbersGiven N non-negative integers, find the maximum XOR over all pairs of distinct elements.Medium6Bit manipulationTrieNo attempts yet2s512 MBJudgeable
Flipping Coins 3Flip whole rows or columns of an N by M grid of coins to leave as few tails as possible, with N at most 20.Medium6Bit manipulationBrute force+1No attempts yet5s512 MBJudgeable
Consistent Letter PathFind the shortest path on an N by N letter grid from top-left to bottom-right where no letter appears in both lowercase and uppercase along the path.Medium6BFSBit manipulation+2No attempts yet2s512 MBJudgeable
Linear Feedback Shift RegisterGiven an N-bit linear feedback shift register, its taps, and two states, find the minimum number of clock pulses to reach the final state, or report that it is impossible.Medium6Bit manipulationMath+1No attempts yet2s512 MBJudgeable
XOR Sum 3Compute the XOR of every contiguous subsequence of A and print the sum of all those XOR values.Medium6Bit manipulationPrefix sum+1No attempts yet2s512 MBJudgeable
Hamiltonian HypercubeGiven two binary strings in Gray Code order, count how many code words lie strictly between them on the n-bit Gray Code path.Medium6Bit manipulationRecursion+1No attempts yet2s512 MBJudgeable
Emptying the GlassesGiven N glasses and pairwise pour costs, find the minimum effort to end with water in at most K glasses.Medium6Dynamic programmingGraph+2No attempts yet2s32 MBJudgeable
The Longest Travel RouteGiven a directed weighted graph with at most 18 cities, find the maximum total length of a simple path from city 0 to city n-1.Medium6Dynamic programmingBit manipulation+2No attempts yet2s512 MBJudgeable
O CanadaEach move flips a 2x2 block of an N x N red/white grid. Count pairs of given grids that can reach each other by such moves.Medium6Bit manipulationHash map+2No attempts yet1s512 MBJudgeable
BeesGiven an n by m hexagonal honeycomb's initial honey pattern, apply the rule that each cell fills next day exactly when an odd number of its neighbors were filled, and print the state after k days.Medium6Bit manipulationSimulation+2No attempts yet1s512 MBJudgeable
XORMaintain an array under range XOR updates and point queries, printing each queried element in order.Medium6Binary searchPrefix sum+2No attempts yet2s512 MBJudgeable
XOR EquationCount ordered pairs of positive integers A and B with A+B=S and A xor B=X.Medium6MathBit manipulationNo attempts yet2s512 MBJudgeable
XOR GroupsErase cells from an N by M grid in increasing value order and after each erasure report the maximum sum of XOR values of the connected groups.Medium6Union-findSimulation+1No attempts yet2s512 MBJudgeable
Key Rearrangement 2Given n keys with lists of compatible keyholes and a time limit k, decide whether a perfect matching exists with total |i-j| cost at most k.Medium6Dynamic programmingBit manipulation+2No attempts yet2s512 MBJudgeable
Monster Path (Small)Given a small grid, a start cell, and a fixed step count, choose a walk maximizing the expected number of distinct monsters caught.Medium6Dynamic programmingBit manipulation+1No attempts yet5s512 MBJudgeable
Integer GameGiven N and up to 15 divisors, remove multiples of each in order and count how many numbers from 1 to N survive.Medium6MathNumber theory+2No attempts yet2s512 MBJudgeable
Subarray XOR sumsFor a sequence, count how often each XOR value appears among all contiguous subarrays, then report the most frequent value, breaking ties by choosing the smallest.Medium6Prefix sumBit manipulation+2No attempts yet2s512 MBJudgeable
Elevator PrankEach move toggles a fixed set of buttons and costs N, N/2, N/2, or N/3 seconds; count the distinct button states reachable with total time at most m, including pressing nothing.Medium6Bit manipulationBrute force+2No attempts yet1s512 MBJudgeable
Turning Off the LightsGiven a 10x10 grid of lit and unlit bulbs, find the minimum presses so that every bulb ends up off.Medium6Brute forceBit manipulation+2No attempts yet1s128 MBJudgeable
Asphalt PavingGiven segments on a triangular grid, choose the largest subset so that no two share an endpoint at an acute angle.Medium6GraphDynamic programming+2No attempts yet1s512 MBJudgeable
Friend PalindromeGiven a friendship graph on up to 20 students, find the largest number of students that can form a palindrome-like line where every student except the possible middle one is paired with a friend.Medium6Dynamic programmingBit manipulation+2No attempts yet2s512 MBJudgeable
PaversCount the tilings of a 2 x n board with 1x1 squares, 2x1 rectangles, and L-trominoes, and sum the total number of each paver over all tilings.Medium6Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Birthday Gift SequenceFor each query (x, K), form every non-empty subset sum of {1, x, x^2, ...}, sort uniquely, and sum the K-th values over all queries modulo 1e9+7.Medium6MathCombinatorics+2No attempts yet2s512 MBJudgeable
Football Association ElectionGiven N ranked ballots over M candidates, find the current winner and the fewest candidates to remove so that candidate K wins.Medium6Brute forceBit manipulation+2No attempts yet3s64 MBJudgeable
Tap Titanz at Moloco (Easy)On an n by n black/white board, each tap flips a whole same-color connected region; find the minimum taps to make the board one color.Medium6GraphBFS+2No attempts yet2s512 MBJudgeable
ifConstruct a value x of type int or long such that x != 0 and x == -x, exploring two's complement overflow wrap-around.Medium6MathBit manipulation+2No attempts yet2s512 MBJudgeable
The PricesChoose for each product a wholesaler to buy it from, paying each visited wholesaler's round-trip cost once, to minimize the total.Medium6Dynamic programmingBit manipulation+2No attempts yet2s512 MBJudgeable
Two teams with the smallest ability gapSplit N people into two nonempty teams so the difference between the two teams' pairwise ability sums is minimized, and print that minimum.Medium6Bit manipulationBrute force+2No attempts yet2s512 MBJudgeable
Escape RoomEach press toggles one button and up to two buttons to its right; find the fewest presses to turn an all-off row of N lights into a target 0/1 pattern.Medium6GreedyArray+2No attempts yet1s256 MBJudgeable
Edge ColoringCount subsets of edges of a multigraph, modulo 100000007, such that every vertex has an odd number of chosen incident edges.Medium6MathBit manipulation+2No attempts yet2s256 MBJudgeable
Drawn and QuarteredA fixed permutation is applied to a string K times; find where each index goes and output the rearranged string.Medium6MathBit manipulation+1No attempts yet2s512 MBJudgeable
Is-A? Has-A? Who Knowz-A?Given is-a and has-a edges between classes, answer queries whether one class is-a or has-a another using inheritance and field transitivity.Medium6GraphBFS+2No attempts yet2s512 MBJudgeable
EscapeFind the fewest presses of A (add 1) and B (double then cut the leading digit) turning N into G without passing 99999 in T steps, or report impossible.Medium6BFSGraph+1No attempts yet1s256 MBJudgeable
Monkey SportsAssign each of N monkeys to team A or B on each of 7 days so that every pair of monkeys is split across teams on at least one day.Medium6CombinatoricsMath+2No attempts yet1s128 MBJudgeable
DebloGiven a tree with numbers on its nodes, add up the XOR of every node-value along every path between two nodes, counting single-node paths too.Medium6TreeBit manipulation+2No attempts yet1s512 MBJudgeable
CrazinessGiven a symmetric matrix of pairwise and individual craziness values for n up to 20 relatives, find the non-empty subset whose invited pairs plus individual terms sum to the maximum.Medium6Brute forceBit manipulation+2No attempts yet2s512 MBJudgeable
Hotel ManagementEach room belongs to exactly two switches; find whether pressing some subset of switches turns every room's lock state to open.Medium6GraphDFS+2No attempts yet2s512 MBJudgeable
Traveling Salesman 3Find the minimum-length round trip that visits all N cities exactly once and returns to the start, where N is at most 16.Medium6Dynamic programmingBit manipulation+2No attempts yet1s512 MBJudgeable
ParametriziranCount pairs of equal-length words over lowercase letters and question marks that can be made identical by filling the question marks.Medium6Bit manipulationHash map+2No attempts yet3s512 MBJudgeable
Space ProbeGiven travel times between N planets and a start planet, find the shortest route that visits every planet, with no need to return to the start.Medium6Dynamic programmingBit manipulation+2No attempts yet1s512 MBJudgeable
Team SelectionPick five of n candidates and assign each a distinct role among A to E so the total skill summed over roles is as large as possible.Medium6Dynamic programmingBit manipulation+1No attempts yet1s256 MBJudgeable
Oh Right, the UmbrellaOn a grid with walls, find the shortest walk from S that picks up every X item (at most 5) and ends at E.Medium6BFSBit manipulation+2No attempts yet1s256 MBJudgeable
Getting-Up SyndromeChoose an initial integer x in [0, m] so that applying n bitwise OR/XOR/AND gates with given parameters maximizes the final value.Medium6Bit manipulationGreedy+2No attempts yet1s512 MBJudgeable
Feeding the CatsStarting at (0,0), visit all N cats on a grid, moving in Manhattan steps, and return to (0,0) in the shortest time.Medium6Dynamic programmingBit manipulation+2No attempts yet1s256 MBJudgeable
Getting ConfidenceGiven an N by N matrix of confidence values, assign each of N ornaments to a distinct position so that the product of the chosen values is maximized, and output the assignment.Medium6Dynamic programmingBit manipulation+2No attempts yet0.5s512 MBJudgeable
Two-Pan BalanceGiven up to 13 distinct weights, count how many integers from 1 to their sum cannot be formed when each weight goes on the bowl side, the other pan, or unused.Medium6Brute forceBacktracking+2No attempts yet1s512 MBJudgeable
Bus PlanningSplit n kids (n up to 17) into the fewest groups so no two enemies share a group and each group has at most c kids, then output one valid grouping.Medium6Bit manipulationDynamic programming+2No attempts yet2s512 MBJudgeable
Domino PredictionGiven XORs of consecutive domino numbers, answer queries for the XOR of positions x and y, or for the value at y when x holds d.Medium6Prefix sumBit manipulation+2No attempts yet1s256 MBJudgeable
Binary Number GameGiven two binary strings, find the minimum number of single-bit flips (never the leading bit), increments, and decrements to turn the start number into the target.Medium6BFSDynamic programming+2No attempts yet1s1024 MBJudgeable
Automatic Control MachineGiven up to 15 binary strings of length n, pick the fewest strings whose bitwise OR covers every position, or report -1.Medium6Bit manipulationBrute force+2No attempts yet2s1024 MBJudgeable
Game of Nim EverywhereCount N in [L, R] where the Nim position (N, 2N, 3N) is a first-player win, i.e. where N xor 2N xor 3N is nonzero.Medium6Game theoryBit manipulation+2No attempts yet2s512 MBJudgeable
Delivering Problem SheetsGiven N points and Q query points in 11 dimensions, report for each query the maximum Manhattan distance to any of the N points.Medium6MathBit manipulation+2No attempts yet2s1024 MBJudgeable
MafiaGiven guilt scores and a reaction matrix, the mafia Eunjin picks one night victim at a time and must survive as long as possible, returning the maximum number of nights.Medium7Bit manipulationDFS+2No attempts yet2s128 MBJudgeable
Twin VillagesSelect as many village pairs as possible with Manhattan distance at least D and degree at most P per village, then minimize the total distance among maximum selections.Medium7Dynamic programmingBit manipulation+2No attempts yet2s128 MBJudgeable
Paper CuttingDecide whether five fixed-shape pieces can be translated without rotation to exactly tile an L x L grid, then print the lexicographically smallest piece-number layout or gg if impossible.Medium7BacktrackingBit manipulation+2No attempts yet2s128 MBJudgeable
Number of Strings Matching Exactly K PatternsCount lowercase strings that match exactly K out of N given letter/question-mark patterns of equal length, modulo 1,000,003.Medium7CombinatoricsBit manipulation+2No attempts yet2s128 MBJudgeable
MarriageGiven up to 12 men and 12 women with mutual liking pairs, partition everyone into star-shaped marriages (one person of one gender with several of the other) to cover all people with the fewest marriages, or report impossibility.Medium7Dynamic programmingBit manipulation+2No attempts yet5s128 MBJudgeable
Fixing an ArrayFor each array value, find the number within a given range that has the smallest Hamming distance in binary, breaking ties by choosing the smallest value.Medium7Bit manipulationDynamic programming+1No attempts yet2s128 MBJudgeable
Box FillingGiven a length x width x height box and limited counts of power-of-two sized cubes, find the minimum number of cubes to fill it exactly, or -1 if impossible.Medium7MathBit manipulation+2No attempts yet2s128 MBJudgeable
Finding Domino TilingsCount the ways to tile a fixed 8x7 numeric grid with all 28 distinct dominoes so that each domino's pair matches the covered cell values.Medium7BacktrackingBit manipulation+2No attempts yet2s128 MBJudgeable
Stair NumbersCount N-digit numbers whose adjacent digits differ by exactly 1 and that contain every digit 0-9 at least once, modulo 1,000,000,000.Medium7Dynamic programmingBit manipulation+1No attempts yet2s128 MBJudgeable
Lighting FixtureGiven an N×M grid of colored lamps, find a sequence of row-flip and column-swap button presses that turns the initial grid into a target grid, or report impossibility.Medium7Bit manipulationCombinatorics+2No attempts yet2s128 MBJudgeable
Security PanelFind the minimum set of button presses on an R by C panel so a fixed 3x3 toggle pattern turns every button on, breaking ties by a lexicographic rule.Medium7MatrixBit manipulation+2No attempts yet2s128 MBJudgeable
Bungeoppang TycoonGiven an MxN grid where pressing a cell flips it and its four neighbors, find the minimum, lexicographically smallest set of presses to make every cell 0.Medium7Brute forceBit manipulation+2No attempts yet2s128 MBJudgeable