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 results1,020 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Jumping YoshiStarting from the first pebble, follow jumps allowed when two spot counts sum to their distance and report the farthest reachable pebble.Medium6GraphBFS+1No attempts yet2s256 MBJudgeable
Loda TeleportationsGiven N strings in order, find the longest subsequence where each earlier string is both a prefix and a suffix of the later one.Medium6Dynamic programmingString matching+1No attempts yet1s64 MBJudgeable
Performance Assessment 1Find the shortest sequence over 1 to M missing as a contiguous block of A and count such sequences modulo 1e9+7.Medium6String matchingHash map+1No attempts yet1s256 MBJudgeable
Equivalent PasswordsGiven an ordered list of short numeric passwords, find the worst-case number typed when passwords equivalent to an earlier typed one are skipped.Medium6Brute forceHash map+1No attempts yet3s256 MBJudgeable
Multi-pianoChoose a nonnegative step K so the walk that starts at the first pitch and moves by K on each rise or fall matches the true pitches in the most positions.Medium6Hash mapPrefix sum+1No attempts yet1s64 MBJudgeable
Crime House (Large)Decide if an enter and leave log with masked identities fits a single door and find the smallest possible number of people left inside.Medium6GreedySimulation+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
Professor Normal's Marble GameChildren on a grid repeatedly drop out when short on marbles, then survivors pass 12 marbles to neighbors; count the exchanges or the children who play forever.Medium6SimulationQueue+1No attempts yet5s512 MBJudgeable
Multi-base happy numbersFor each set of bases, find the smallest integer above 1 whose repeated digit-square iteration reaches 1 in every listed base.Medium6MathSimulation+1No attempts yet5s512 MBJudgeable
Crop Triangles (Large)Generate n points with a given recurrence and count triples whose coordinate sums are divisible by 3 on both axes.Medium6MathCombinatorics+1No attempts yet5s512 MBJudgeable
Stone GroupsStarting from stone counts A, B, C, repeatedly double the smaller of two unequal groups and subtract it from the larger; decide whether all three can become equal.Medium6BFSMath+2No attempts yet2s512 MBJudgeable
RATS SequenceSimulate a RATS sequence term by term for up to M steps, detecting the first term that repeats an earlier value or first takes the chain form 1233*4444 or 5566*7777.Medium6SimulationImplementation+2No attempts yet2s512 MBJudgeable
Prefix and SuffixCount the distinct substrings of S that both start with string A and end with string B, where A and B may overlap within a substring.Medium6StringHash map+1No attempts yet2s512 MBJudgeable
Array SumReorder two arrays to make some sum value repeat as often as possible; report the maximum repeat count and the largest such sum.Medium6SortingHash map+1No attempts yet5s512 MBJudgeable
Robert FloydStitches walks up to 2048 unit steps on a huge grid, leaving bile on each edge crossed, and you must count the regions the bile walls split the map into.Medium6GeometrySimulation+1No attempts yet1.2s256 MBJudgeable
Number of good substringsCount how many distinct substrings of s contain at most k bad letters, counting equal substrings once.Medium6StringHash map+1No attempts yet2s512 MBJudgeable
Martian VolleyballGiven an axis-parallel polygon, find the minimum number of points outside the court such that every side has a point on its supporting line.Medium6GeometryGraph+2No attempts yet1s512 MBJudgeable
SetGiven multiset of cards, each with a count of figures (1 to 3) and a shape (circle, square, triangle), find the maximum number of disjoint triples where each characteristic is all-same or all-different.Medium6CombinatoricsGreedy+1No attempts yet2s512 MBJudgeable
BarbellsGiven up to 14 bars and 14 plates, find every total weight obtainable by putting plates on both sides of one bar so that the two sides balance.Medium6Brute forceHash map+2No attempts yet2s512 MBJudgeable
Headstrong StudentFor each fraction x/y, report how many decimal digits come before the repeating part starts and how long that repeating part is (0 if the decimal terminates).Medium6MathNumber theory+2No attempts yet8s512 MBJudgeable
Where To Go?A note string uses upper case letters and each station name uses lower case letters, so a match between them is an equality-pattern match between two windows of different alphabets.Medium6StringString matching+2No attempts yet2s512 MBJudgeable
Stupendous BowtiesGiven N distinct integer points, count unordered pairs of axis-aligned right triangles that share only the right-angle vertex.Medium6GeometryCombinatorics+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
HackerFind the first string t such that the strings from S to t contain exactly K strings sharing t's rolling-hash value, then print those K strings.Medium6Hash mapMath+1No attempts yet0.5s128 MBJudgeable
AliensGiven N points, choose an integer axis value s minimizing new points needed so the set is symmetric about x = s/2, then output those points. Ties go to the smallest s, output sorted by x then y.Medium6Hash mapSorting+2No attempts yet1s128 MBJudgeable
Plane GameGiven N points, rotate and translate them arbitrarily so that as many points as possible lie on the two coordinate axes; output that maximum count.Medium6GeometryBrute force+2No attempts yet2s512 MBJudgeable
Why Did the Cow Cross the Road 9Given a circular sequence where each cow label appears exactly twice, count pairs of cows whose chords necessarily cross.Medium6ArrayHash map+2No attempts yet2s512 MBJudgeable
Bovine Genomics (Gold)Given N spotted and N plain DNA strings of length M, find the shortest window of consecutive positions whose substrings separate every spotted string from every plain one.Medium6StringHash map+2No attempts yet2s512 MBJudgeable
Bot or notScore pairs of secondary accounts by shared posts they follow, then count accounts similar to a known human.Medium6ImplementationHash map+1No attempts yet2s512 MBJudgeable
Nothing But The TruthGiven facts about which person was at which place and when, count how many claims in a text (who met whom, who was where) are definitely false.Medium6StringIntervals+1No attempts yet2s512 MBJudgeable
Googlements (Small)Given a googlement G that may have already decayed, count all length-L digit strings that reach G after zero or more decay steps.Medium6GraphSimulation+2No attempts yet5s512 MBJudgeable
Dice Straight (Small)Given N dice with six distinct faces each, find the longest run of consecutive integers you can place on top using each die at most once.Medium6GreedyHash map+1No attempts yet5s512 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
Abandoned AnimalGiven each store's stock and the ordered list of purchases, count how many store assignments make store numbers nondecreasing: zero, one, or many.Medium6GreedyArray+1No attempts yet2s512 MBJudgeable
Lemonade TradeGiven a sequence of one-way lemonade exchanges walked in order, find the maximum litres of blue obtainable starting from one litre of pink, capped at 10.Medium6Dynamic programmingHash map+1No attempts yet2s512 MBJudgeable
Domino KillingGiven up to 100000 dominoes on a grid with orientations, count how many topple after a push using the 90-degree blocking rule.Medium6SimulationHash map+2No attempts yet2s512 MBJudgeable
School PairingFor each query range, count pairs of positions whose skill grades sum to K.Medium6Hash mapPrefix sum+1No attempts yet2s512 MBJudgeable
Jumbled passwordGiven a string, find the smallest index past the midpoint where the suffix differs from the prefix of equal length in exactly one character.Medium6StringString matching+2No attempts yet0.5s1024 MBJudgeable
Hidden HierarchyBuild a directory tree from file paths, and print the smallest set of directories (expanding or collapsing as needed) that covers every directory whose total size is at least t.Medium6TreeHash map+2No attempts yet1s512 MBJudgeable
Card block reversalGiven a permutation of 1..N, choose one contiguous block to reverse so that the final number of positions i with card i is maximized, breaking ties by leftmost start then leftmost end.Medium6ArrayHash map+1No attempts yet1s128 MBJudgeable
TataramonGiven a sequence, pick each value at most twice to maximize the sum, and among all maximum-sum picks output the lexicographically smallest subsequence.Medium6GreedySorting+2No attempts yet3s512 MBJudgeable
Greeting CardCount how many pairs of given lattice points lie exactly 2018 units apart.Medium6Hash mapMath+2No attempts yet2s512 MBJudgeable
Milk MeasurementSort the measurements by day, then count the days where the set of cows with the maximum current milk output changes after applying each update.Medium6SortingHash map+2No attempts yet2s512 MBJudgeable
Thinking StationFor each K from 1 to N, split the first N cars into blocks of K (dropping the remainder) and count distinct blocks up to reversal; report the K values with the maximum count.Medium6StringHash map+2No attempts yet1s256 MBJudgeable
Adventurer on a QuestMaintain a set of completed quest numbers under insertions and range queries asking how many integers in [L, R] are not yet completed.Medium6Hash mapSorting+2No attempts yet3s256 MBJudgeable
GeneticsGiven N DNA strings of length M, find the one string that differs from every other string in exactly K positions.Medium6StringBrute force+2No attempts yet2s1024 MBJudgeable
Array and GahuiProcess point updates on an array and after each one count index pairs whose two values have GCD greater than one.Medium6Hash mapNumber theory+2No attempts yet2s512 MBJudgeable
Subway in SeoulGiven up to 10 subway lines, each listing stations (0 is the start), find the minimum number of transfers to reach a destination station.Medium6GraphBFS+2No attempts yet2s128 MBJudgeable
The Mirror Cat Leaves a Mirror Behind When It DiesGiven N cats in fire order, each living cat emits beams in four directions blocked by any mirror; a cat dies if hit, leaving a mirror below its cell; count survivors.Medium6SimulationHash map+2No attempts yet1s1024 MBJudgeable
ParallelepipedGiven n rectangular sheets, pick 6 to form the faces of a rectangular box (opposite faces must match in size), maximizing the volume. Output -1 if impossible.Medium6Hash mapSorting+2No attempts yet2s512 MBJudgeable
Memory AllocationSimulate first-fit malloc and free over 100,000 memory cells and print requested variable values in command order.Medium6IntervalsSimulation+2No attempts yet1s512 MBJudgeable
Random Index VectorsMerge two sparse signed index lists to output their element-wise sum, product, and each list rotated left by k with wraparound.Medium6Two pointersHash map+2No attempts yet2s512 MBJudgeable
Subprime Fibonacci SequenceGenerate terms with the divide-out recurrence and find the shortest repeating pair of consecutive terms within the first n terms, then print the cycle.Medium6SimulationHash map+2No attempts yet2s512 MBJudgeable
Substring PermutationGiven strings S and P, decide whether some permutation of P is a substring of some permutation of S.Medium6Hash mapTwo pointers+1No attempts yet1s512 MBJudgeable
LiarsGiven each person's claimed range for the truth-teller count, find the maximum possible number of truth-tellers within any consistent assignment.Medium6Hash mapPrefix sum+1No attempts yet1s512 MBJudgeable
Arithmetic ProgressionsGiven up to 5000 distinct numbers, find the length of the longest subset that forms an arithmetic progression.Medium6ArrayHash map+1No attempts yet5s512 MBJudgeable
Watch Where You StepFind the maximum number of new one-way sidewalks you can add to a zoo graph without creating any new reachability between attractions.Medium6GraphBFS+2No attempts yet2s512 MBJudgeable
Making a ShapeIn a grid of 0s and 1s, find the largest connected group of 1s obtainable by flipping exactly one 0 cell to 1.Medium6GraphDFS+2No attempts yet2s512 MBJudgeable
Guess the AnimalGiven N animals and their traits, find the maximum number of yes answers Elsie can hear before her questions pin down exactly one animal.Medium6ImplementationGreedy+2No attempts yet2s512 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
Coloring PracticeCount how many 3x3 subgrids contain exactly i black cells for each i from 0 to 9, given up to 1e5 black cells on a huge grid.Medium6Prefix sumHash map+2No attempts yet1s512 MBJudgeable
Life in WartimeGiven N distinct cities (all below 250) in an infinite binary heap tree, count cities that either host a unit or lie on the unique path between two units.Medium6TreeHash map+2No attempts yet2s512 MBJudgeable
Christmalo.winGiven N short strings, pick two and a shared letter to splice their prefix and suffix, minimizing the total deleted characters.Medium6StringHash map+2No attempts yet1s1024 MBJudgeable
Count SquaresGiven coordinates of h horizontal and v vertical lines, count how many axis-aligned squares have all four sides drawn by those lines.Medium6ArrayHash map+2No attempts yet2s512 MBJudgeable
TriangleGiven N plane points and Q query points, count epsilon-isosceles triangles having the query point as vertex and two distinct given points as the others, where two side lengths differ by less than 0.0001.Medium6GeometryHash map+1No attempts yet2s512 MBJudgeable
JOIOJIGiven a string of J, O, and I, find the longest contiguous substring with equal counts of all three letters.Medium6Prefix sumHash map+2No attempts yet1s512 MBJudgeable
Beer VisionCount the nonzero shift vectors (X, Y) for which some set of stars, shifted by that vector, equals the given set of points.Medium6Hash mapGeometry+2No attempts yet2s512 MBJudgeable
Problematic Public KeysGiven M flawed RSA-style public keys, find the prime factors of each and print all distinct primes in ascending order, five per line.Medium6Number theoryMath+2No attempts yet1s512 MBJudgeable
Typo SquattingFor each domain name, count how many other given domains differ from it in exactly one character position.Medium6Hash mapString+2No attempts yet4s512 MBJudgeable
HaikuGiven a set of syllables, decide whether the three input phrases can each be split into syllables so their syllable counts are 5, 7, and 5.Medium6Dynamic programmingString+2No attempts yet1s512 MBJudgeable
One of EachGiven a sequence containing every value 1 to k at least once, find the lexicographically smallest subsequence that includes each value exactly once.Medium6GreedyStack+2No attempts yet2s512 MBJudgeable
Firetrucks Are RedGiven sets of numbers describing each of n people, output n-1 edges (p, q, r) where r appears in both sets, so that all people end up connected, or report that this is impossible.Medium6Union-findGraph+2No attempts yet5s512 MBJudgeable
Robot AssemblyMaintain a growing set of unions between robot parts and answer, for each query part, how many parts currently belong to its robot.Medium6Union-findImplementation+1No attempts yet4s1024 MBJudgeable
CatCount how many distinct strings you can form by joining a non-empty suffix of a with a non-empty prefix of b.Medium6StringString matching+2No attempts yet2s512 MBJudgeable
Triangles (Silver)Given N points, sum twice the areas of all right triangles whose legs are parallel to the axes, modulo 1e9+7.Medium6MathGeometry+2No attempts yet1s512 MBJudgeable
Arithmetic SequencesGiven a set of distinct integers, find the size of the largest subset that can be ordered as an arithmetic sequence.Medium6Dynamic programmingSorting+2No attempts yet1.5s512 MBJudgeable
Subarray Average of a SequenceCount the contiguous subarrays of a given sequence whose elements have an average exactly equal to K.Medium6Prefix sumHash map+2No attempts yet1s256 MBJudgeable
Two PrefixesGiven strings s and t, count distinct strings formed by concatenating a non-empty prefix of s with a non-empty prefix of t.Medium6StringString matching+2No attempts yet1s512 MBJudgeable
Sequence RestorationReconstruct any original length-N sequence given all its overlapping length-M contiguous subsequences in arbitrary order.Medium7Hash mapGraph+2No attempts yet2s128 MBJudgeable
Triangles in a Planar GraphCount the triangles (3-cycles) in a planar graph with up to 100,000 vertices and 300,000 edges, exploiting the sparse edge bound for efficiency.Medium7GraphHash map+2No attempts yet2s128 MBJudgeable
Stepping-Stone Race 2Find the minimum total Euclidean jump length from the origin to any stone whose y-coordinate equals a target line, moving only between stones within dx,dy of 2.Medium7Shortest pathGraph+2No attempts yet2s128 MBJudgeable
Counting Submatrices with Divisible SumsCount contiguous submatrices of an N by M matrix (N,M up to 256) whose sum is divisible by K, requiring an efficient prefix-sum plus hashing technique.Medium7Prefix sumHash map+1No attempts yet1s128 MBJudgeable
RectangleGiven up to 1500 points, find the maximum area rectangle (not necessarily axis-aligned) whose four vertices are among the points.Medium7GeometryHash map+1No attempts yet2s1024 MBJudgeable
Median of a Contiguous SubsequenceCount odd-length contiguous subarrays of a permutation of 1..N whose median equals a given value B.Medium7Prefix sumHash map+1No attempts yet1s128 MBJudgeable
The Dragon and the KnightsGiven n lines forming an arrangement with m marked points, determine whether every region of the arrangement contains at least one marked point.Medium7GeometryHash map+1No attempts yet3s128 MBJudgeable
Size of the DictionaryCount distinct words formed as base words themselves, plus prefix-of-one-base-word concatenated with suffix-of-another-base-word combinations.Medium7TrieString matching+1No attempts yet2s128 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
KINA Is Not AbbreviationGiven a text, find the abbreviation (initials of a consecutive word window) that is unambiguous per the stated rules and maximizes letter-count reduction, breaking ties lexicographically.Medium7String matchingHash map+2No attempts yet2s512 MBJudgeable
AmbiguousSplit a scrambled, space-free string into a unique sequence of dictionary words matching letter multisets, first and last letters, reporting ambiguity or impossibility.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Find the MultiplesCount index pairs (i,j) with a_i nonzero such that the decimal number formed by a_i...a_j is divisible by a given prime Q, for a pseudo-randomly generated digit sequence of length up to 1e5.Medium7MathHash map+2No attempts yet2s128 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
Cut It Out!Given n triangular holes and 2n smaller triangles produced by splitting each hole along a cevian, match the two pieces to each hole using side lengths and angles.Medium7GeometryHash map+2No attempts yet1s128 MBJudgeable
We've Got Chemistry, BabeParse chemical formulas into atom counts, then find positive integer coefficients with gcd 1 that balance the reaction, or report that none or many exist.Medium7MathNumber theory+2No attempts yet1s128 MBJudgeable
Mastermind: The Best Next GuessGiven prior Mastermind guesses and their black/white peg counts, find the guess that minimizes the largest group of codes still consistent with each possible response.Medium7Brute forceSimulation+2No attempts yet3s128 MBJudgeable
Life FormsGiven up to 100 DNA strings, find every longest contiguous substring that appears in strictly more than half of them, printed in alphabetical order.Medium7StringBinary search+2No attempts yet2s128 MBJudgeable
Eventually Periodic SequenceGiven N, a start n, and a function f written in postfix, follow the iteration x -> f(x) mod N and report the length of its eventual cycle.Medium7MathSimulation+2No attempts yet1s128 MBJudgeable
Help!Given two patterns of literal words and named placeholders, find the lexicographically smallest word phrase matching both, or output a minus sign if none exists.Medium7StringHash map+2No attempts yet1s128 MBJudgeable
Edit Step LaddersGiven a lexicographically sorted dictionary, find the longest sequence of words where each consecutive pair differs by one insertion, deletion, or substitution, and the sequence follows dictionary order.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Blenjeel Sand Worms and Color WrigglesA snake of n cells starts filling the left column of an n by m colored grid and must reach the right column, moving one end per wriggle, always keeping n distinct-colored cells; find the minimum number of wriggles.Medium7BFSSimulation+2No attempts yet1s128 MBJudgeable
BeadsGiven two 13-bead rings, each with 13 gray and 13 yellow beads, find the fewest swaps of a 3-bead block between the rings to put all gray on top.Medium7BFSString+2No attempts yet1s128 MBJudgeable