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 results457 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
PokegeneCount, for each query, how many string prefixes occur in exactly L of the K listed genomes.Medium5StringString matching+1No attempts yet2s512 MBJudgeable
String DistanceGiven strings O and N, find the minimum number of substring-insertion operations to turn O into N, or output -1 if impossible.Medium6Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Periodic PrefixesFor each prefix of a string, find the largest count n such that the prefix is some substring repeated n times, using prefix-function techniques.Medium6String matchingString+1No attempts yet2s128 MBJudgeable
Longest Repeated SubstringFind the length of the longest substring that occurs at least twice in a given string of up to 200,000 lowercase letters.Medium6Binary searchString matching+2No attempts yet2s128 MBJudgeable
CubeditorGiven a lowercase string of length up to 5000, find the maximum length of a substring that occurs at least twice, allowing overlapping occurrences.Medium6StringDynamic programming+1No attempts yet0.5s128 MBJudgeable
Word GameGiven a string and a dictionary of words, find the minimum number of characters to delete from the string so the rest is a concatenation of dictionary words in order.Medium6Dynamic programmingString matching+2No attempts yet2s128 MBJudgeable
Roman Numeral SentencesFind the largest number whose canonical Roman numeral form can be picked out as an in-order subsequence of letters from a given sentence.Medium6GreedyString matching+2No attempts yet2s128 MBJudgeable
Shortest Non-subsequenceGiven a sequence of values from 1 to k, find the minimum length of a sequence over that alphabet that cannot be found as a subsequence of it.Medium6GreedyString matching+1No attempts yet2s128 MBJudgeable
Caesar CipherGiven a custom alphabet order, plaintext word, and cipher text, find all shift values for which decrypting yields the word exactly once, using string matching over a large alphabet.Medium6String matchingString+1No attempts yet2s256 MBJudgeable
Necklace SequenceDecompose a binary string into a strictly decreasing sequence of Lyndon-like necklace factors where adjacent concatenations fail the necklace property.Medium6StringGreedy+1No attempts yet2s128 MBJudgeable
Phone Number MnemonicsFind the minimum number of dictionary words whose digit encodings concatenate to exactly match a given phone number, using the letter to digit telephone mapping.Medium6Dynamic programmingString matching+1No attempts yet2s128 MBJudgeable
Cipher Decoder Choi JunminFind the earliest starting word position in an encoded word sequence that matches a pattern sentence under a bijective word-to-word substitution mapping.Medium6String matchingHash map+1No attempts yet1s128 MBJudgeable
Card SolitaireGiven several queues of cards, repeatedly pop the front of some queue to append to an answer sequence so that the final sequence is lexicographically smallest.Medium6GreedyString matching+1No attempts yet5s128 MBJudgeable
String CensorshipRepeatedly delete the first then last occurrence of a pattern string from a text until it's absent, and output the final text.Medium6String matchingStack+1No attempts yet1.5s128 MBJudgeable
Word DivisionCount the number of ways to split a long word (up to length 300,000) into consecutive substrings all belonging to a dictionary of up to 4000 short words, modulo 1337377.Medium6Dynamic programmingString matching+2No attempts yet1s128 MBJudgeable
SimilaritySum, over every alignment of a pattern against a text without gaps, the count of matching letter positions, for texts up to 2,000,000 characters.Medium6String matchingString+1No attempts yet1s128 MBJudgeable
Glass BeadsFind the starting index that produces the lexicographically smallest rotation of a circular string of beads, using an efficient least-rotation algorithm.Medium6StringString matching+1No attempts yet1s128 MBJudgeable
Hidden PasswordFind the starting index of the lexicographically smallest rotation of a string, choosing the smallest index in case of ties (Booth's algorithm).Medium6StringString matching+1No attempts yet2s128 MBJudgeable
Where's WallyDecode base64-like bit matrices for an image and a square pattern, then count all image squares matching the pattern under any rotation or mirror flip.Medium6MatrixString matching+2No attempts yet4s128 MBJudgeable
Confusing Login NamesCompute an extended edit distance (insert, delete, replace, adjacent swap) between all pairs of given login names and output pairs within a given threshold, sorted alphabetically.Medium6Dynamic programmingString+1No attempts yet3s128 MBJudgeable
Compound WordsGiven a dictionary of up to 120,000 sorted lowercase words, list every word that can be split into two shorter dictionary words.Medium6TrieString+2No attempts yet1s128 MBJudgeable
DividingFor each case with t, a, b, decide whether (t^a-1)/(t^b-1) is an integer below 100 digits, and print it or a fixed message.Medium6Number theoryMath+2No attempts yet1s128 MBJudgeable
StringerGiven fixed counts of each of N letters, find the K-th string in alphabetical order among all arrangements, without listing them.Medium6CombinatoricsMath+2No attempts yet1s128 MBJudgeable
Hide That NumberGiven the disguised value (11 times the original, truncated to the original's digit count), recover the original number or report IMPOSSIBLE.Medium6MathNumber theory+2No attempts yet1s128 MBJudgeable
Finding a MultipleFor each n up to 200, print the smallest multiple of n whose decimal digits are only 0 and 1, with up to 100 digits.Medium6BFSNumber theory+2No attempts yet1s128 MBJudgeable
Card Game is FunAnna may delete arbitrary cards from her sequence and Bruno may trim cards from the top and bottom of his; find the longest common subarray obtainable.Medium6Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Villain RobotsChoose a string of K characters over {A,B,C} maximizing the total number of substring occurrences of the given pattern strings.Medium6Dynamic programmingString matching+2No attempts yet1s128 MBJudgeable
Network WarsSimulate two programs moving through a labeled graph, one searching alphabetically forward and one backward, until one is trapped or destroyed.Medium6GraphSimulation+2No attempts yet1s128 MBJudgeable
StrategyParse a small strategy language, then simulate every pair of up to 10 programs for 10 rounds and print each program's total score.Medium6ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Pascal Program LengthsCount the scored tokens (reserved words, identifiers, constants, parentheses, brackets, and listed operators) in each Turbo Pascal program, skipping comments and strings, and print the member's name with the total.Medium6StringImplementation+2No attempts yet1s128 MBJudgeable
Truck HistoryConnect all truck codes so the total Hamming distance is minimized, then print 1/Q. This is a minimum spanning tree on a complete graph.Medium6Minimum spanning treeGraph+2No attempts yet1s128 MBJudgeable
Comment removalStrip Pascal comments and collapse whitespace, honoring single-quote strings where doubled quotes are literals and comments can span lines.Medium6StringSimulation+2No attempts yet1s128 MBJudgeable
Number PairsFor a given N, list all pairs (X, Y) with X + Y = N where deleting one digit from X yields Y, and count them.Medium6MathBrute force+2No attempts yet1s128 MBJudgeable
VirusDecide whether every one of N integer sequences shares some contiguous fragment of length at least K, counting reversals as the same fragment.Medium6StringString matching+2No attempts yet1s128 MBJudgeable
Cell phone tunesDecide whether a given tune is good (no adjacent equal-multiset blocks), contains all n sounds, and cannot be extended by a single sound on either end.Medium6String matchingImplementation+1No attempts yet1s32 MBJudgeable
SignalGiven sequence s and a pattern f, find the smallest starting position where f occurs as a contiguous block that can be one of exactly k fragments of lengths in [a,b].Medium6String matchingGreedy+1No attempts yet1s128 MBJudgeable
Fibonacci WordsCount the occurrences of a given a/b pattern as a contiguous substring of the n-th Fibonacci word, overlaps included.Medium6StringDynamic programming+1No attempts yet1s128 MBJudgeable
JanSplit a given lowercase word into the fewest pieces, each of which is lexicographically smaller than all of its nontrivial rotations, and print one valid minimum split.Medium6StringGreedy+2No attempts yet1s128 MBJudgeable
SignalsCompare the signal sets generated by two series-parallel circuit expressions and print whether they are equal, nested, disjoint or overlapping.Medium6String matchingRecursion+1No attempts yet1s128 MBJudgeable
Practice SeasonBoth teams insert rest days into their fixed city orders to minimize combined stadium and hotel costs.Medium6Dynamic programmingString matchingNo attempts yet2s128 MBJudgeable
Substring Set MembershipYou receive a set of patterns and query strings and print YES for each query containing a pattern as a contiguous substring, NO otherwise.Medium6String matchingTrieNo attempts yet1s256 MBJudgeable
Swyper KeyboardExpand a swipe path over a four-row letter grid into every key each segment crosses, then print the first dictionary word that is a subsequence of it.Medium6GeometryString matching+1No attempts yet1s128 MBJudgeable
Genetically Modified AppleInsert priced letters into a DNA string so a given gene appears as a contiguous block at minimum total cost.Medium6Dynamic programmingString matchingNo attempts yet1s128 MBJudgeable
(ℓ, d) patternFind the unique length-l lowercase string within Hamming distance d of some substring in every given string.Medium6Brute forceString matchingNo attempts yet2s512 MBJudgeable
Secret CodeCount the sequences of operations that build the given string from a source of length at least 2 by gluing each string to a copy missing one end character.Medium6Dynamic programmingString matching+1No attempts yet1s128 MBJudgeable
MutationCount overlapping occurrences in a DNA string of a marker and all strings formed by reversing one substring of the marker.Medium6String matchingHash mapNo attempts yet2s256 MBJudgeable
RLE ReplacementReplace the first occurrence of RLE string B inside RLE string A with RLE string C and print the result in RLE form.Medium6String matchingTwo pointers+1No attempts yet2s128 MBJudgeable
HamzawyFind the longest string that is a non-overlapping prefix, suffix, and middle substring of each given string.Medium6String matchingNo attempts yet1s256 MBJudgeable
ConcatenationCount distinct strings formed by joining a nonempty prefix of the first word with a nonempty suffix of the second word.Medium6String matchingCombinatoricsNo 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
Password-free alphabet arrangementArrange A to Z in one row so none of the given passwords appears as a contiguous block, choosing the smallest such order or reporting impossibility.Medium6BacktrackingString matching+1No attempts yet5s512 MBJudgeable
Finding 123456789Count subsets of occurrences of P in S whose starting positions multiply to a common multiple of 1 through 9, modulo 1000000007.Medium6Dynamic programmingString matching+1No attempts yet1s512 MBJudgeable
Number of Strings Containing a SubstringCount length-L lowercase strings that contain the given word S as a contiguous substring, modulo 1,000,000,009.Medium6Dynamic programmingString matchingNo attempts yet2s512 MBJudgeable
Wildcard (Small)Given two lowercase names, output the shortest wildcard pattern of letters and stars that matches the first name but not the second.Medium6String matchingBrute force+1No attempts yet5s512 MBJudgeable
PermRLE (Small)Split the string into fixed blocks of length k, permute each block the same way, and minimize the number of runs in the result over all k! permutations.Medium6Brute forceSorting+2No attempts yet5s512 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
Programming TutorsGiven N students and N tutors in a Manhattan-metric city, find the smallest K such that every student can be matched with a distinct tutor at distance at most K.Medium6Binary searchGraph+2No attempts yet2s512 MBJudgeable
Musical PlagiarismGiven a song as a sequence of notes and a suspect excerpt, decide whether the excerpt appears in the song under some transposition (key change).Medium6String matchingArray+2No attempts yet2s512 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
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
An Unfair PuzzleGiven two permutations of 1..n, decide whether cyclic rotations and reversals can turn the first into the second, printing good puzzle or bad puzzle.Medium6StringString matching+2No attempts yet2s256 MBJudgeable
Anagram Pyramids (Hard)Given a dictionary and query word pairs, decide whether an anagram pyramid can be built from the top word down to the bottom word.Medium6GraphDFS+1No attempts yet10s512 MBJudgeable
Digit RearrangementGiven A and B, rearrange the digits of A (no leading zero) to build the largest permutation that is still strictly less than B, or print -1.Medium6BacktrackingGreedy+2No attempts yet2s512 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
Gluing PicturesGiven a city string C, find for each friend name the fewest substrings of C that concatenate to form it, or -1 if impossible.Medium6Dynamic programmingString matching+2No attempts yet0.3s512 MBJudgeable
Assessing GenomesCompute each DNA string's smallest repeating unit length, then pair the two sets of scores to minimize the sum of squared differences.Medium6StringSorting+2No attempts yet2s512 MBJudgeable
Ponk WarshallGiven two equal-length strings over {A,C,G,T} with matching letter counts, find the minimum number of arbitrary swaps that turn the first string into the second.Medium6GreedyImplementation+2No attempts yet1s512 MBJudgeable
DISHFor each pair of strings, output a shortest string that contains both input strings as substrings.Medium6StringDynamic programming+2No attempts yet2s512 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
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
DNA Deletions and Protein CountCount, modulo 1e9+7, the distinct proteins obtainable by deleting some nucleotides from a DNA string and translating the remaining codons via a given table.Medium7Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Magic StringCount permutations of up to 8 given words whose concatenation is a string that has exactly K circular shifts equal to itself.Medium7String matchingBrute force+2No attempts yet2s512 MBJudgeable
Palindrome Word SequencesCount ordered sequences of given words, reused any number of times, whose concatenation has exact length L and forms a palindrome.Medium7Dynamic programmingString matching+2No attempts yet2s128 MBJudgeable
Four SubstringsGiven a string and four of its substrings, pick one occurrence of each so that the union of the covered positions has the fewest and the most distinct characters.Medium7String matchingIntervals+2No attempts yet2s512 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
Largest Square KillerGiven an R x C binary grid, find the side length of the largest square submatrix that remains unchanged after a 180 degree rotation.Medium7String matchingBinary search+2No attempts yet5s128 MBJudgeable
String Period PredictionUsing KMP-style prefix functions, find for every prefix the largest period-like split point and sum these values across the whole string.Medium7String matchingString+1No attempts yet2s128 MBJudgeable
Maximum String PastingGiven a long string and up to 500 short patterns, find all their occurrences and select non-overlapping intervals to maximize total covered length via DP.Medium7String matchingDynamic programming+1No attempts yet1s128 MBJudgeable
GeneReconstruct a unique circular-free DNA sequence from overlapping fragments (usable forward or reversed) split across k identical copies, then print the lexicographically smaller of it and its reverse.Medium7String matchingGraph+1No attempts yet1s128 MBJudgeable
Reading UPC BarcodesGiven a 95-bit UPC-A barcode string with unknown bits and possible reversal, enumerate all valid 12-digit UPC codes matching the pattern and checksum.Medium7String matchingBrute force+2No attempts yet1s128 MBJudgeable
ASCII StreetGiven a street string and multiple pattern tiles, count how many street positions are never covered by any occurrence of any pattern, requiring efficient multi-pattern matching like Aho-Corasick.Medium7String matchingTrie+1No attempts yet4s512 MBJudgeable
Longest Repeated SubstringGiven a lowercase string of up to 200000 characters, compute the length of the longest substring that occurs at least twice, allowing overlaps.Medium7StringBinary search+1No attempts yet1s256 MBJudgeable
Formula SubstitutionGiven two formula strings with variables 0 and 1, find basic-formula substitutions for both variables that make the two formulas syntactically identical, similar to unification.Medium7RecursionString matching+2No attempts yet1s128 MBJudgeable
Character EquationGiven a recursive definition of a huge string T through variable concatenation equations, determine whether a pattern P is a subsequence of T without expanding T explicitly.Medium7Dynamic programmingString+2No attempts yet1s256 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
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
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
PolylopsGiven the vertices of a simple polygon, count how many distinct lines reflect it exactly onto itself.Medium7GeometryString matching+1No attempts yet1s128 MBJudgeable
Stems SellApply ordered pattern-to-replacement rewrite rules, which support *, V, C, and back-references, to every word in each paragraph.Medium7StringString matching+2No attempts yet1s128 MBJudgeable
Shape NumberGiven a chain code, take its first difference mod 8 and print the lexicographically smallest cyclic rotation of that sequence.Medium7StringString matching+1No attempts yet2s128 MBJudgeable
Comparing CodeFind the longest run of HAL's lines that matches a run of RBN's lines up to injective variable renaming and swapping the two right-hand operands.Medium7String matchingHash map+1No attempts yet1s128 MBJudgeable
String FarmGiven up to 10^4 strings, find the longest chain where each string is a contiguous substring of the next, all photos distinct.Medium7StringDynamic programming+2No attempts yet5s128 MBJudgeable
Emoticons :-)Given a set of emoticon strings, replace the fewest characters with spaces across several text lines so that no emoticon appears consecutively in any line.Medium7String matchingDynamic programming+2No attempts yet1s128 MBJudgeable
NecklaceGiven a string and a pattern, delete the fewest characters so the pattern no longer appears as a contiguous substring.Medium7Dynamic programmingString matching+2No attempts yet1s128 MBJudgeable
Threatening LetterGiven a newspaper string and a message, split the message into the fewest contiguous pieces, each of which appears somewhere in the newspaper. Output that minimum count.Medium7StringDynamic programming+2No attempts yet1s128 MBJudgeable
EnigmaGiven a partial Enigma key and plaintext with a few unknowns, complete the decryption of the ciphertext.Medium7Brute forceSimulation+2No attempts yet1s128 MBJudgeable
Roman NumeralsEach line gives a Roman sum A+B=C. Decide whether it holds as a Roman numeral equation, then classify its cryptarithm as impossible, ambiguous, or valid.Medium7Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Corporate IdentityGiven up to 4000 short lowercase strings, find the longest string that occurs as a contiguous substring of every one, breaking ties by lexicographic order.Medium7StringString matching+2No attempts yet1s128 MBJudgeable
SubstringsCount the distinct substrings of a string, including the empty string and the whole string, for up to 5000 characters per test case.Medium7StringTrie+2No attempts yet1s128 MBJudgeable