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
RIPEMD-160Compute the RIPEMD-160 hash of an alphanumeric string of length at most 50 and print it as 40 lowercase hexadecimal digits.Medium4ImplementationBit manipulationNo attempts yet1s256 MBJudgeable
SHA-1 HashPrint the SHA-1 hash of the given alphanumeric string as lowercase hexadecimal.Medium4ImplementationBit manipulationNo attempts yet1s256 MBJudgeable
CivilizationPick the smallest subset of at most 18 regions whose total workforce, tax income, and farm count all reach the required thresholds, or print game over.Medium4Brute forceBit manipulationNo attempts yet1s256 MBJudgeable
2-SAT AssignmentDetermine whether a 2-CNF formula with up to 20 variables is satisfiable and output the lexicographically smallest satisfying assignment.Medium4Brute forceBit manipulationNo attempts yet1s256 MBJudgeable
Longest Prefix MatchGiven X bit prefixes with ids and Y destination addresses, print the id of the longest matching prefix for each address or -1.Medium4TrieBit manipulationNo attempts yet1s256 MBJudgeable
Geppetto's PizzaCount the subsets of up to 20 ingredients that contain none of the given incompatible pairs, including the empty pizza.Medium4Brute forceBit manipulationNo attempts yet1s64 MBJudgeable
Death StarRecover the lexicographically smallest sequence whose pairwise bitwise AND values match the given off-diagonal matrix.Medium4Bit manipulationNo attempts yet1s256 MBJudgeable
Nim Game 2Two players alternately remove stones from one of N piles and the player taking the last stone wins, so decide the winner under optimal play.Medium4Game theoryBit manipulationNo attempts yet2s512 MBJudgeable
English and French (Small)Assign each unknown sentence to English or French so the number of words appearing in both languages is as small as possible.Medium4Brute forceBit manipulation+1No attempts yet5s512 MBJudgeable
Noisy NeighborsPlace N tenants on an R by C grid to minimize the number of shared walls between occupied neighbors.Medium4Brute forceBit manipulationNo attempts yet5s512 MBJudgeable
EnclosurePlace the fewest stones on an N by M grid of at most 20 cells so at least K points are cut off from the border.Medium4Brute forceBFS+1No attempts yet5s512 MBJudgeable
Charging Chaos (Small)Find the fewest bit positions to flip so the outlet strings match the device strings after reordering.Medium4Brute forceBit manipulation+1No attempts yet5s512 MBJudgeable
Snapper Chain (Large)You daisy-chain N snappers that toggle when powered and report whether the bulb at the end is lit after K snaps.Medium4Bit manipulationMathNo attempts yet5s512 MBJudgeable
Snapper ChainGiven N chained snappers acting as a binary counter and K snaps, decide whether the lamp on the last snapper receives power.Medium4Bit manipulationMathNo attempts yet5s512 MBJudgeable
Odd Man OutGiven an odd-length list where every number appears twice except one, find the number that appears once.Medium4Bit manipulationHash mapNo attempts yet5s512 MBJudgeable
Idempotent FilterGiven a 128-bit lookup table describing a hexagonal cellular automaton filter, decide whether applying the filter twice always equals applying it once.Medium4SimulationBrute force+2No attempts yet8s512 MBJudgeable
Fast ExponentiationCompute A raised to the power X modulo 1,000,000,007, where A and X can be up to 10^18.Medium4MathBit manipulation+1No attempts yet1s512 MBJudgeable
Harps and TailsFlip any subset of columns of an H/T grid; find the maximum number of rows that can be made all-H.Medium4Hash mapGreedy+2No attempts yet2s512 MBJudgeable
Remove DuplicatesRead a space-separated list whose length is not given, keep each value only at its first occurrence, and print the surviving values in order.Medium4Hash mapArray+2No attempts yet5s8 MBJudgeable
Boolean Product of Boolean MatricesCompute the Boolean product of two N by N 0/1 matrices and count how many entries in the result are 1.Medium4MatrixBrute force+1No attempts yet2s512 MBJudgeable
Byte Me!Given N data bytes and a parity byte, find the parity type, the one data byte with wrong popcount parity, and the flipped bit position.Medium4Bit manipulationImplementation+1No attempts yet2s512 MBJudgeable
Wizard of OddsGiven N possible secret numbers and K yes/no questions, decide whether K adaptive questions always identify the number, where K questions distinguish at most 2^K outcomes.Medium4MathBinary search+2No attempts yet2s512 MBJudgeable
Trains crossing the Milky WaySimulate four seat operations across N trains, then count how many trains have a seating state that appears for the first time.Medium4SimulationHash map+2No attempts yet1s512 MBJudgeable
Zebras and OcelotsGiven a stack of zebras and ocelots, each bell ring flips the lowest ocelot and all zebras beneath it; count rings until no ocelots remain.Medium4Bit manipulationMath+2No attempts yet2s512 MBJudgeable
Generic QueriesGiven an array and range queries, compute each interval XOR and output the XOR of all answers mixed with the given k values.Medium4Prefix sumBit manipulation+2No attempts yet2.5s512 MBJudgeable
Wonyoung Wants to Stay with ZOAC ForeverFor each t from 1 to N, the number of participants is the largest power of two dividing 2t; find the sum over all t.Medium4MathNumber theory+2No attempts yet1s256 MBJudgeable
Bit OverflowGiven an N-digit binary number K, count how many times the operation K = K - (K & ((~K)+1)) can be applied before K becomes 0.Medium4Bit manipulationMath+2No attempts yet1s512 MBJudgeable
Bus LogicGiven a starting stop and bus routes as bit strings of length s, find the maximum number of other stops reachable by choosing exactly one bus that serves the starting stop.Medium4Bit manipulationImplementation+2No attempts yet1s512 MBJudgeable
Umm CodeConcatenate u and m characters from words made only of u, m, and punctuation, then decode each 7-bit chunk as ASCII.Medium4StringImplementation+2No attempts yet2s512 MBJudgeable
Water BottlesGiven N one-liter bottles and capacity K, find the minimum number of extra one-liter bottles so that merging equal amounts leaves at most K non-empty bottles.Medium5MathGreedy+1No attempts yet1s512 MBJudgeable
X and KGiven X and K, find the K-th smallest positive integer Y such that X+Y equals X OR Y, which requires placing K's bits into the zero-bit positions of X.Medium5Bit manipulationMath+1No attempts yet2s128 MBJudgeable
Traveling Salesperson TourFind the minimum cost Hamiltonian cycle in a directed graph with up to 16 cities using bitmask dynamic programming.Medium5Dynamic programmingBit manipulation+1No attempts yet1s128 MBJudgeable
Final Team MatchGiven up to 1000 students each mastering a subset of at most 15 problem types, find the largest group whose combined skill set covers at most K types.Medium5Bit manipulationBrute force+1No attempts yet2s128 MBJudgeable
Height OrderGiven pairwise shorter-than relations between students, count how many students have their exact height rank fully determined by transitivity.Medium5GraphDFS+1No attempts yet1s128 MBJudgeable
Building EDSAC InstructionsConvert a decimal fraction into two's-complement binary and print it as an EDSAC assembly instruction, rounding toward zero and detecting out-of-range values.Medium5Bit manipulationString+2No attempts yet1s128 MBJudgeable
Remove ParenthesesGiven an expression with up to 10 matching parenthesis pairs, output every distinct string formed by removing one or more full pairs, sorted lexicographically.Medium5StringBit manipulation+1No attempts yet1s128 MBJudgeable
Counting Sanggeun's Digit FriendsGiven up to a million large integers, count pairs that share at least one decimal digit, requiring bitmask digit sets and efficient counting over 1024 subsets.Medium5Bit manipulationCombinatorics+1No attempts yet1s128 MBJudgeable
Truth-Tellers and LiarsCount all ways to label N people as truth-tellers or liars so that every statement matches the truth-and-lies rule.Medium5Brute forceBit manipulation+1No attempts yet1s128 MBJudgeable
Friends Calling PlanGiven call minutes between up to 16 employees, pair them all up to minimize total billing cost using bitmask DP over perfect matchings.Medium5Dynamic programmingBit manipulation+1No attempts yet1s128 MBJudgeable
MisLEDGiven two observed 7-segment displays with the same unknown burnt-out segments, find the second observed time in 12-hour format.Medium5Brute forceBit manipulation+1No attempts yet1s128 MBJudgeable
The Turn of the ShrewEach child's code must differ from the bitwise OR of some male and female adult code; find the minimum Hamming distance over all pairs.Medium5Bit manipulationBrute force+2No attempts yet1s128 MBJudgeable
Going to the MoviesGiven M movies each covering a subset of P preferences, find the smallest number of movies whose coverage includes all P preferences.Medium5Bit manipulationBrute force+2No attempts yet2s128 MBJudgeable
Problem-Free Problem SetGiven N problems, each covering some of M required algorithms, find the smallest subset of problems covering all M algorithms, breaking ties by lexicographic order of problem names.Medium5Bit manipulationBrute force+2No attempts yet1s128 MBJudgeable
Bad WiringEach switch toggles a window of 2D+1 lights; find the fewest flips that turn every light off, or report impossibility.Medium5GreedyBit manipulationNo attempts yet3s128 MBJudgeable
Cow IDsFind the N-th smallest binary number that has exactly K one-bits and no leading zeros, then print it in binary.Medium5CombinatoricsMath+2No attempts yet1s128 MBJudgeable
Escaping the FarmAmong up to 20 cow weights, find the largest subset whose base-10 sum produces no carry in any digit position.Medium5Bit manipulationBrute force+1No attempts yet1s128 MBJudgeable
Hexadecimal to Octal ConversionConvert a hexadecimal number of up to 100,000 digits into its octal form with no leading zeros, using binary as the intermediate step.Medium5StringMath+2No attempts yet1s128 MBJudgeable
Extended Lights OutGiven a 5 by 6 Lights Out board, find the unique set of button presses that turns every light off, then print the press grid.Medium5Brute forceBit manipulation+2No attempts yet1s128 MBJudgeable
In DangerGiven n people in a circle where every second person is eliminated starting from person 1, report the final surviving position; n arrives encoded as xyez.Medium5MathRecursion+2No attempts yet1s128 MBJudgeable
Quad TreeDecode a quad tree string into an n by n black and white image, then print each row as XBM hexadecimal bytes.Medium5RecursionDivide and conquer+2No attempts yet1s128 MBJudgeable
FriendsEvaluate set expressions over uppercase letters using union, intersection, and difference, where * binds tighter than + and - and equal operators left-associate.Medium5StringStack+2No attempts yet1s128 MBJudgeable
Pattern GeneratorFor each (n, k) pair, print all n-bit strings with exactly k ones in decreasing numeric order, separated by blank lines.Medium5BacktrackingRecursion+2No attempts yet1s128 MBJudgeable
Betting SetsPartition an N by M table of probabilities into groups of one cell per column to maximize the expected number of all-heads groups.Medium5Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
NimGiven a Nim position, count how many single-pile moves lead to a losing position (XOR of the remaining piles equals zero).Medium5Game theoryBit manipulation+1No attempts yet1s128 MBJudgeable
PassageSplit n people into groups whose total weight is at most W, minimizing the sum of each group's slowest crossing time.Medium5Dynamic programmingBit manipulation+1No attempts yet3s128 MBJudgeable
ATMsFor each amount under 10^30, find a subset of the 100 ATMs whose signed sum equals the amount and another equal to its negation.Medium5Bit manipulationGreedy+1No attempts yet1s128 MBJudgeable
MatchesGiven m match lineups that each split n boys into two teams, decide whether every pair of boys is separated at least once.Medium5Bit manipulationCombinatorics+1No attempts yet1s128 MBJudgeable
Logarithmic PaprikaGiven counts of paprika weighing 1, 2, 4, ..., 2^k grams, find the smallest positive weight that cannot be formed from whole pieces.Medium5GreedyMath+2No attempts yet1s128 MBJudgeable
Balls in a Binary TreeFollow the n-th ball down h levels of toggling switches, going left on odd visits and right on even visits, to find its leaf number.Medium5Bit manipulationSimulation+1No attempts yet1s128 MBJudgeable
Binary SumGiven k, print in binary the sum of all integers from 1 to the largest k-digit binary number.Medium5MathBit manipulationNo attempts yet1s128 MBJudgeable
BoardsFrom the smallest power of two at least K, find the fewest board halvings so some pieces sum to exactly K.Medium5Bit manipulationGreedyNo attempts yet1s128 MBJudgeable
Social AdvertisingPick the fewest users so that every user is picked or is a friend of someone picked.Medium5Brute forceBit manipulation+1No attempts yet2s128 MBJudgeable
Counting Ones in a RangeAdd up the number of 1 bits in the binary form of every integer from A to B.Medium5Bit manipulationMathNo attempts yet1s128 MBJudgeable
N-QueenCount the ways to place N non-attacking queens on an N by N board for N under 15.Medium5BacktrackingBit manipulationNo attempts yet10s128 MBJudgeable
One Move from Towers of HanoiGiven n disks and an index k, report the disk and the source and destination posts of the kth move in the classic recursive Hanoi solution.Medium5RecursionBit manipulation+1No attempts yet3s128 MBJudgeable
Removing pieces so none attackRemove the fewest chess pieces from each board of up to 15 pieces so no two remaining pieces attack each other.Medium5Brute forceGraph+1No attempts yet1s128 MBJudgeable
ShopsPick cells with no shared side in an N by 5 profit grid to maximize the summed profit.Medium5Dynamic programmingBit manipulationNo attempts yet2s256 MBJudgeable
Floating-Point Format ConversionConvert each 8-digit hex Gould floating-point value to its IEEE 754 single-precision hex form with truncation and overflow rules.Medium5Bit manipulationMath+1No attempts yet1s256 MBJudgeable
NicolePick at least two locations with no hearing pair among them to maximize total satisfaction.Medium5Brute forceBit manipulation+1No attempts yet1s256 MBJudgeable
XOR TriplesChoose the largest subset of 1 to N with no three distinct values xoring to zero, breaking ties by smallest lexicographic order.Medium5Brute forceBit manipulationNo attempts yet5s256 MBJudgeable
Traveling Salesman Tour 2Find the cheapest tour that starts at one city, visits each of N cities exactly once, and returns to the start using the given directed costs.Medium5Dynamic programmingBit manipulation+1No attempts yet2s256 MBJudgeable
The Sorting HatFind the department of student n by counting the set bits in n-1 and taking the remainder modulo p.Medium5Bit manipulationMathNo attempts yet1s256 MBJudgeable
Base-2 PalindromesFind the M-th positive integer whose binary representation reads the same forward and backward and print it in decimal.Medium5Bit manipulationMathNo attempts yet1s256 MBJudgeable
Atomic ComputerCount the length-y signed-binary strings over -1, 0 and 1 whose digits weighted by powers of two sum to x.Medium5Dynamic programmingBit manipulationNo attempts yet1s256 MBJudgeable
A Rational SequenceGiven a reduced fraction p/q from the Calkin-Wilf tree, compute its position n in breadth-first order.Medium5MathTree+1No attempts yet1s256 MBJudgeable
Pyro TubesFor each value in a sorted list, count larger list values whose 18-bit patterns differ in at most two bits.Medium5Bit manipulationHash mapNo attempts yet13s256 MBJudgeable
Sheldon NumbersCount numbers between X and Y whose binary form starts with ones and alternates blocks of N ones and M zeros.Medium5Brute forceBit manipulation+1No attempts yet1s256 MBJudgeable
DeceptionYou divide the numbers into two nonempty groups with equal XOR to make the first group's sum as large as possible.Medium5Bit manipulationGreedyNo attempts yet1s256 MBJudgeable
Robot Rock Band (Large)Count quadruples with one element from each of four lists whose bitwise XOR equals K.Medium5Hash mapBit manipulationNo attempts yet7s512 MBJudgeable
Not So RandomFeed X through N stages that each apply bitwise AND, OR, or XOR with K at given probabilities and report the expected final value.Medium5ProbabilityBit manipulation+1No attempts yet5s512 MBJudgeable
Not So Random (Large)N machines each apply AND, OR, or XOR with K at given probabilities, and the expected output after chaining them must be computed.Medium5Bit manipulationProbability+1No attempts yet10s512 MBJudgeable
Googol String (Large)Answer the Kth character of a recursively defined binary string for each query with K up to 10^18.Medium5RecursionBit manipulationNo attempts yet5s512 MBJudgeable
Broken Seven-segment DisplayFrom N consecutive seven-segment readings with unknown start digit and dead segments, infer the next reading, or print ERROR when consistent readings disagree.Medium5Brute forceBit manipulationNo attempts yet5s512 MBJudgeable
Broken Seven-segment DisplayFrom N recorded seven-segment states of a countdown with unknown start digit and stuck-off segments, find the single possible next state or report ERROR!.Medium5Brute forceBit manipulation+1No attempts yet5s512 MBJudgeable
Part Elf (Large)Given a claimed elf fraction P/Q, decide whether 40 generations of averaging can produce it and report the closest possible generation of a full elf ancestor.Medium5Number theoryMath+1No attempts yet5s512 MBJudgeable
Bit Count (Small)Given N, split it into nonnegative a and b with a plus b equal to N to maximize the total count of 1 bits in a and b.Medium5Bit manipulationDynamic programmingNo attempts yet5s512 MBJudgeable
Bit Count (Large)For each N, choose nonnegative a and b with a plus b equal to N to maximize the total number of 1 bits in a and b.Medium5Bit manipulationGreedyNo attempts yet5s512 MBJudgeable
Candy SplittingDivide the candies into two nonempty piles that look equal under addition without carries and keep the largest possible true sum for yourself.Medium5Bit manipulationGreedyNo attempts yet5s512 MBJudgeable
Candy Splitting (Large)Split the candies into two nonempty piles with equal xor totals and keep the pile with the largest ordinary sum.Medium5Bit manipulationGreedyNo attempts yet5s512 MBJudgeable
Snapper Chain (Large)After K snaps on a chain of N toggling snappers, decide whether power reaches the light plugged into the last one.Medium5Bit manipulationMathNo attempts yet5s512 MBJudgeable
Double and AddStarting from an all-zero array, find the minimum number of single-element increments and whole-array doublings that produce the target array B.Medium5GreedyBit manipulation+2No attempts yet2s512 MBJudgeable
Palindromic substringsCount length-N uppercase strings whose length-M substrings include at least K palindromes.Medium5Brute forceString+2No attempts yet2s512 MBJudgeable
Movement 3Decide whether (x, y) is reachable by moving 3^k right or up on each step k, starting at the origin.Medium5MathBit manipulation+1No attempts yet2s512 MBJudgeable
Powers of Three WalkGiven a target point, decide whether it is reachable if stage k moves exactly 3^k in one of the four axis directions.Medium5MathNumber theory+1No attempts yet2s512 MBJudgeable
LoteriaDecide whether K target parities can be chosen so that no non-empty subset of the given rows has column sums matching all of them.Medium5MathBit manipulation+2No attempts yet1s512 MBJudgeable
Block GameFor each letter, find the minimum number of blocks needed so any choice of one word per board can be spelled at once.Medium5Brute forceBit manipulationNo attempts yet2s512 MBJudgeable
Paper PiecesCut an N x M digit grid into horizontal or vertical strips and maximize the sum of the numbers those strips form.Medium5Brute forceBit manipulation+2No attempts yet2s512 MBJudgeable
Integer SequenceGiven x, y, the last two digits of A0 and A1, and a large index n, print the last two digits of An where An = x*An-1 + y*An-2.Medium5MathDynamic programming+2No attempts yet0.25s512 MBJudgeable
Hamming distance queriesGiven binary strings a and b, answer queries asking for the Hamming distance between a substring of a and a substring of b.Medium5Prefix sumString+2No attempts yet6s512 MBJudgeable
Birthday CakeGiven up to 50 candle points and up to 15 cuts, decide whether the cuts carve the cake so that every resulting piece holds exactly one candle.Medium5GeometryBit manipulation+2No attempts yet2s512 MBJudgeable