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
Hidden CodesGiven code words and a long text, choose non-overlapping covering sequences, each at most 1000 long, maximizing the total length of the code words used.Medium7Dynamic programmingString matching+2No attempts yet1s128 MBJudgeable
Walk the TalkCount the number of distinct monotone paths (only right and/or up hops) through an H by W letter grid whose visited letters spell one of N given words.Medium7Dynamic programmingTrie+2No attempts yet1s128 MBJudgeable
Cow PatternsFind every length-K window of a spot-count sequence whose relative order matches a given rank pattern.Medium7String matchingSliding window+1No attempts yet1s128 MBJudgeable
Wiping WordsRepeatedly blank out any word whose column has no support in the next line, or that appears in the last line, until no more words can be wiped.Medium7SimulationImplementation+1No attempts yet1s128 MBJudgeable
Serial NumbersGiven up to 10 forbidden digit substrings, find the b-th smallest positive integer whose decimal form contains none of them as a substring.Medium7Dynamic programmingString matching+2No attempts yet1s128 MBJudgeable
TemplateFind a template whose overlapping occurrences cover every position of S, minimizing the template length.Medium7StringString matching+1No attempts yet3s128 MBJudgeable
VirusesGiven a set of forbidden binary words, decide whether an infinite binary sequence exists that avoids all of them as contiguous substrings.Medium7String matchingTrie+2No attempts yet3s512 MBJudgeable
Word EqualizingAppend the given words to x and y any number of times to make them equal, and output the minimum total number of appends, or NIE if impossible.Medium7StringGraph+2No attempts yet1s128 MBJudgeable
Even Palindrome DecompositionDecide whether a string can be split entirely into even-length palindromes, and if so report the minimum and maximum number of parts.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
PalindromesGiven n distinct palindromes, count ordered pairs whose concatenation is also a palindrome, with total length up to 2,000,000.Medium7StringHash map+2No attempts yet5s256 MBJudgeable
Algorithm SpeedupDecide whether a recursively defined Boolean function F on two sequences returns 1 or 0, where F strips the longest prefix and suffix that drop some value.Medium7RecursionHash map+2No attempts yet8s128 MBJudgeable
Error CorrectionGiven letter-to-bits codebook and binary strings, decide if exactly one letter sequence encodes to within one bit flip.Medium7Dynamic programmingString matching+1No attempts yet1s128 MBJudgeable
EraserPick the alphabetically last name that appears as a subsequence in every scrap and keep bitek when nothing later exists.Medium7GreedyString matchingNo attempts yet1s512 MBJudgeable
Substring DrawTwo slips are drawn without replacement from all position-counted substrings of a word, and the tie probability is printed as a reduced fraction.Medium7String matchingCombinatorics+1No attempts yet1s128 MBJudgeable
PatternCount the positions in the text where the pattern matches when every letter is repeated the same number of times.Medium7String matchingTwo pointers+1No attempts yet1s128 MBJudgeable
Lottery TicketsCount numbers from 0 to M-1 whose zero-padded decimal form matches Z in some length-r block at the same positions.Medium7Dynamic programmingString matchingNo attempts yet1s128 MBJudgeable
Suffix ArrayRead a lowercase string of length up to 500000 and print its suffix array and LCP array, writing x for the first LCP entry.Medium7String matchingSortingNo attempts yet3s256 MBJudgeable
Longest Common SubstringFind the length of the longest substring shared by two lowercase strings and print the lexicographically smallest one of that length.Medium7String matchingBinary search+2No attempts yet1s256 MBJudgeable
Goguryeo and the Crown PrinceGiven two different binary strings of equal length, compute the probability that the first appears before the second in fair coin flips.Medium7String matchingProbabilityNo attempts yet1s128 MBJudgeable
Probability ParadoxTwo players each pick a coin-flip pattern and the program computes the chance the first pattern appears before the second.Medium7ProbabilityString matching+1No attempts yet1s128 MBJudgeable
Decoding the HallwayFor each query, decide whether the given string appears as a contiguous substring of the turn record built after n hallway walks.Medium7StringRecursion+2No attempts yet1s128 MBJudgeable
Secret MessageCount the operation sequences that build the given string by repeatedly prepending or appending a proper prefix or suffix.Medium7Dynamic programmingString+1No attempts yet1s128 MBJudgeable
PalindromeFind the palindromic substring that maximizes its length times its number of occurrences in the given string.Medium7String matchingStringNo attempts yet2s128 MBJudgeable
PasswordCount length-N strings over the first K uppercase letters that avoid ABCBC and ABABC as substrings, modulo 1,000,000,009.Medium7Dynamic programmingString matchingNo attempts yet1s256 MBJudgeable
Circle of digitsSplit the circular digit string into K contiguous parts so the largest part value is as small as possible, and output that value.Medium7Binary searchDynamic programming+1No attempts yet5s256 MBJudgeable
Best PositionFor each binary blueprint, find the placement with the most matching cells, tie-broken by row then column, and report the grain and livestock counts.Medium7String matchingMatrix+1No attempts yet10s256 MBJudgeable
Repeated Substring CountCount the distinct substrings that occur at least twice in each string of up to 100000 letters.Medium7String matchingStringNo attempts yet5s256 MBJudgeable
Playing with GeometryDecide whether two rectilinear polygons reduce to the same permutomino after deleting empty grid lines and rotating by multiples of 90 degrees.Medium7GeometryString matching+1No attempts yet1s256 MBJudgeable
The Big PictureCount the top-left positions where the given black-and-white painting matches the masterpiece exactly without rotation.Medium7String matchingNo attempts yet2s512 MBJudgeable
Barbarian TabletsEach query asks how many words shown so far contain the tablet word of barbarian S as a contiguous substring.Medium7String matchingTrieNo attempts yet4s768 MBJudgeable
CensoringRepeatedly delete the leftmost occurrence of any of N forbidden words from string S until none remains and print the result.Medium7String matchingStack+1No attempts yet1s256 MBJudgeable
Typing monkeyGiven per-letter probabilities and two words P and Q, compute the probability that P appears as a substring before Q does.Medium7ProbabilityString matching+1No attempts yet1s256 MBJudgeable
String GameFor each game, decide if Alice wins when both players alternately delete the first or last letter until the string matches the target length.Medium7Game theoryString matching+1No attempts yet1s256 MBJudgeable
Number of distinct substrings 2Count how many different contiguous substrings appear in the given lowercase string of length up to 1,000,000.Medium7String matchingSorting+1No attempts yet5s256 MBJudgeable
CLARKSONSplit the lyrics into consecutive parts that each appear in the script and maximize the shortest part length.Medium7String matchingBinary search+1No attempts yet1s256 MBJudgeable
OOPCount for each pattern with one asterisk how many given words equal it after replacing the asterisk with any string, possibly empty.Medium7String matchingHash map+1No attempts yet2s512 MBJudgeable
Lights Out in the BarnFor each polygon vertex, walk clockwise until angles and edge lengths reveal the start, then report the worst extra distance versus the shortest exit path.Medium7String matchingSimulation+1No attempts yet2s512 MBJudgeable
Garbled EmailSplit the garbled string into dictionary words with changed letters spaced at least 5 apart while changing as few letters as possible.Medium7Dynamic programmingTrie+1No attempts yet60s512 MBJudgeable
Box Factory (Large)Match boxes and toys of equal type in order on run-length encoded lines to maximize the number of pairs.Medium7Dynamic programmingString matchingNo attempts yet5s512 MBJudgeable
Selling RNA StrandsFor each query pair P, Q, count how many dictionary strings start with P and end with Q, where the prefix and suffix may overlap.Medium7TrieString matchingNo attempts yet2s1536 MBJudgeable
PasswordGiven finishes over N years, find the lexicographically largest password substring allowed by rules and count its occurrences.Medium7ArrayString matching+1No attempts yet4s256 MBJudgeable
Suffix array 2Sort all suffixes of a string lexicographically and output the starting index of each suffix in sorted order.Medium7StringSorting+1No attempts yet2s512 MBJudgeable
Stair Climbing WorkoutCount length-N balanced U/D walk strings (never going below 0, ending at 0) that contain a given piece as a contiguous substring.Medium7Dynamic programmingCombinatorics+1No attempts yet2s512 MBJudgeable
Easy ReadingGiven a book text and a picture of painted cells, find the shortest prefix-contiguous text segment whose pen strokes draw exactly that picture up to translation.Medium7String matchingHash map+1No attempts yet2s256 MBJudgeable
Chameleon SubstringGiven a string S, find the longest substring that is both a prefix and a suffix of S and also appears somewhere strictly inside S.Medium7String matchingString+1No attempts yet2s512 MBJudgeable
Prefix and SuffixFor each prefix of S that is also a suffix, output its length and how many times it occurs as a substring.Medium7String matchingPrefix sum+1No attempts yet2s512 MBJudgeable
Strings and QueriesFor a string S, F(i) is the length of the longest common suffix of S and the prefix of S ending at position i; answer M queries for F(i).Medium7StringString matching+2No attempts yet2s512 MBJudgeable
Forest University (Small)Count the fraction of topological orderings of a tiny rooted forest whose label string contains each given cool word as a substring, printed as an irreducible fraction.Medium7Dynamic programmingTopological sort+2No attempts yet100s512 MBJudgeable
Longest Palindromic SubstringGiven a lowercase string of up to 100,000 characters, report the length of its longest palindromic substring.Medium7StringString matching+2No attempts yet2s512 MBJudgeable
Looping PlaylistGiven a circular sequence of N notes, each song is a maximal run whose notes fit one major scale and has at least two notes; find the minimum number of songs covering the loop.Medium7GreedyString matching+2No attempts yet1.5s512 MBJudgeable
Reverse and RejoinSplit a fixed sequence into two non-empty parts, reverse each part, and print the lexicographically smallest result among all split positions.Medium7ArrayString matching+2No attempts yet3s512 MBJudgeable
Separate StringCount the ways to split string t into a sequence of pieces, each of which is one of N given dictionary strings, modulo 1e9+7.Medium7Dynamic programmingTrie+2No attempts yet2s512 MBJudgeable
Prefix Free CodeGiven n prefix-free strings, rank a given concatenation of k of them among all ordered k-selections sorted alphabetically, modulo 1e9+7.Medium7TrieCombinatorics+2No attempts yet2s512 MBJudgeable
A Very Nasty Graph ProblemBuild the lexicographically smallest de Bruijn sequence of order N over two symbols, a shortest binary string containing every N-bit number.Medium7GraphDFS+2No attempts yet2s512 MBJudgeable
Repeated PatternAppend at most K letters to S so it becomes repetitions of one word, and output the longest possible word length (at most N), or 0.Medium7String matchingString+2No attempts yet1s1024 MBJudgeable
Selling RNA StrandsGiven N RNA strings, answer M queries that count strings matching a prefix P and suffix Q.Medium7String matchingHash map+2No attempts yet1.5s1536 MBJudgeable
Longest Common SubstringGiven up to 10 lowercase strings, each up to 100,000 characters, find the length of the longest substring shared by all of them.Medium7StringBinary search+2No attempts yet2s512 MBJudgeable
Contiguous Repeated StringGiven string S and k, choose k appended characters so that the resulting string has the longest substring of the form TT (a block repeated twice back to back), and report that length.Medium7StringBrute force+2No attempts yet2s512 MBJudgeable
Beer MugsGiven a string of N characters over 20 brands, find the longest substring that is a palindrome after permuting it freely.Medium7Bit manipulationHash map+2No attempts yet2s512 MBJudgeable
Palindrome SentencesGiven up to 13 distinct words, count ordered arrangements of a subset of them whose concatenation without spaces forms a palindrome.Hard8Dynamic programmingBit manipulation+2No attempts yet2s128 MBJudgeable
Count Palindromic Word SequencesCount ordered sequences of given words, space-joined, whose concatenation (ignoring spaces) is a palindrome of length at most K, modulo a prime.Hard8Dynamic programmingString matching+2No attempts yet2s128 MBJudgeable
Merge WordsGiven up to 12 uppercase words, find the shortest string containing all of them as substrings, breaking ties by lexicographic order.Hard8Dynamic programmingBit manipulation+2No attempts yet5s128 MBJudgeable
Number ConcatenationGiven a subsequence left after deleting digits from the concatenation of 1,2,...,N, find the smallest N that could produce it.Hard8String matchingBinary search+2No attempts yet2s128 MBJudgeable
LaserCount primitive direction vectors (a,b) with max(a,b) <= K whose periodic grid-wraparound character string contains each given word as a substring.Hard8Number theoryMath+2No attempts yet5s128 MBJudgeable
Palindrome EncodingGiven a binary string, repeatedly delete the second half of any even-length palindromic substring and find the minimum length achievable.Hard8Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Partial DNA SubstringsGiven a DNA string, count distinct substrings occurring at least m times and find the K-th one under length-then-lex order.Hard8String matchingBinary search+1No attempts yet2s16 MBJudgeable
Compressing a StringFind the minimum length of a string obtained by optimally applying nested k(S) run-length style compression to a given lowercase string of length up to 200.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Binary Sequence RotationGiven the last column of a sorted matrix of all circular rotations of an unknown binary string, reconstruct the lexicographically smallest rotation (first row) or report impossibility.Hard8String matchingSorting+2No attempts yet2s128 MBJudgeable
Square-Substring-Free NumberGiven N up to 10^18, find the smallest number at least N whose decimal representation contains no perfect square as a substring.Hard8Dynamic programmingString matching+1No attempts yet1s1024 MBJudgeable
Easy Group MatchingGiven a text sequence and two patterns, count group-matching positions for each pattern, then find the smallest integer n that maximizes group matches for the concatenated pattern P1·n·P2 and report that count.Hard8Dynamic programmingPrefix sum+1No attempts yet30s1536 MBJudgeable
Balanced Bracket SegmentMaintain a dynamic string under prefix/suffix bracket insertions and after each insertion report the shortest valid contiguous bracket substring covering the new character.Hard8StackString matching+1No attempts yet1s128 MBJudgeable
Martian DNA FormulaCompress a DNA string into the shortest possible run-length style notation using nested parentheses with repeat counts.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Logo MatchingGiven a permutation pattern of length n and a sequence of m distinct heights, find all starting positions where a length-n window matches the relative order pattern.Hard8String matchingArray+1No attempts yet2s128 MBJudgeable
Vigenère Cipher AnalysisDetermine, for each candidate Vigenère key length up to K, whether the unique decrypted plaintext contains two given cribs at non-overlapping positions, and report the plaintext, ambiguous, or impossible.Hard8String matchingString+2No attempts yet1s128 MBJudgeable
Unchanged PictureDetermine whether two plotter-drawn vector pictures are geometrically similar under translation, rotation, and uniform scaling but no mirroring.Hard8GeometryString matching+1No attempts yet5s128 MBJudgeable
BundlingGiven permitted bundle templates and a dependency chain among instructions, compute the minimum number of bundles to pack the sequence and, among those, the minimum number of stops needed.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Secret Code: Largest NumberGiven a noisy string, find the largest decimal number it could decode to, either fixing one language for all digits or allowing a different language per digit, using digit-word subsequence matching.Hard8Dynamic programmingString matching+2No attempts yet3s128 MBJudgeable
Term GeneratorParse a formula, convert it to a normal form by expanding nested sums and products according to given rewriting rules, then implement a cyclic generator that outputs requested numbers of terms, some possibly skipped without printing, based on huge signed counters.Hard8String matchingRecursion+2No attempts yet1s128 MBJudgeable
Proof GeneratorConvert a logical formula to a canonical disjunctive normal form using given rewrite rules, then cyclically output the k-th next satisfying terms under given axioms for a sequence of queries.Hard8String matchingRecursion+2No attempts yet1s128 MBJudgeable
Software Industry RevolutionGiven a wildcard pattern (with ? and *) and a text, find the minimum-complexity substring of the text that matches the whole pattern, or report impossible.Hard8String matchingDynamic programming+1No attempts yet1s128 MBJudgeable
Stammering AliensGiven a string and a minimum repeat count m, find the longest substring occurring at least m times (overlaps allowed), breaking ties by rightmost starting position, using suffix array or suffix automaton techniques.Hard8String matchingBinary search+1No attempts yet1s128 MBJudgeable
Using sedFind the minimum number of sed-style leftmost non-overlapping replacement operations needed to turn one small string into another, given up to 10 rewrite rules.Hard8BFSString matching+1No attempts yet1s128 MBJudgeable
Keyword SearchGiven up to 12 base strings, count positions in a text where some permutation-concatenation of all base strings occurs as a substring, treating duplicate resulting strings once.Hard8String matchingBit manipulation+2No attempts yet10s128 MBJudgeable
Fibonacci WordGiven a bit pattern p and an index n up to 100, count the possibly overlapping occurrences of p inside the Fibonacci word F(n), whose length grows exponentially.Hard8String matchingDynamic programming+2No attempts yet1s128 MBJudgeable
Intellectual PropertyGiven two code bases as raw strings, find the k longest maximal substrings of the JCN base that also occur in the TDP base, with exact positions and lengths.Hard8String matchingSorting+2No attempts yet1s128 MBJudgeable
Tail PalindromeGiven two lowercase strings a and b, find the shortest string x such that exactly one of ax, bx is a palindrome, and among ties the lexicographically smallest x.Hard8StringString matching+2No attempts yet1s128 MBJudgeable
SpaghettiDecide whether two labeled Fortran IV programs run the same sequence of statements for every input, ignoring unconditional gotos and labels.Hard8GraphImplementation+2No attempts yet1s128 MBJudgeable
Fill the CrosswordFill a crossword grid with a given word list so every slot holds a listed word exactly once and crossings match; also decide if no solution exists.Hard8BacktrackingTrie+2No attempts yet1s128 MBJudgeable
Crosswords InsiderGiven a list of words and a crossword grid template, decide whether each word can fill one run of empty cells and output the lexicographically smallest filled grid.Hard8BacktrackingSimulation+2No attempts yet1s128 MBJudgeable
Pattern MatchingDecide whether digit sequences match patterns where digits match exactly and * and # stand for even and odd counts of arbitrary digits.Hard8Dynamic programmingString matchingNo attempts yet1s128 MBJudgeable
Alpha of Degree kGiven a dictionary, answer queries asking for the shortest chain from word s to word t where each step shares a suffix-prefix overlap of length at least k, with a cap on chain length.Hard8GraphBFS+2No attempts yet1s128 MBJudgeable
City MergerGiven up to 14 uppercase city names, find the length of the shortest string that contains every name as a consecutive substring, allowing overlaps.Hard8Dynamic programmingBit manipulation+2No attempts yet2s128 MBJudgeable
Name the CrossingGiven named crossings of orthogonal streets, infer an equal-strength and stronger-than relation between streets, then answer whether each queried crossing name is valid.Hard8GraphUnion-find+2No attempts yet1s128 MBJudgeable
InsecurityGiven a hexadecimal bitstring and lists of usernames and passwords, find which username concatenated with which password encrypts to that string under a growing left-shift XOR scheme.Hard8Bit manipulationBrute force+2No attempts yet1s128 MBJudgeable
Balanced Garden in a RowCount balanced binary strings of length N whose every substring has at most two more L than P, and find the lexicographic rank of a given string modulo M.Hard8Dynamic programmingCombinatorics+2No attempts yet2s128 MBJudgeable
Zigzag NumbersCount numbers in [A, B], up to 500 digits, that are divisible by M and whose adjacent digit comparisons alternate up then down.Hard8Dynamic programmingMath+2No attempts yet2s128 MBJudgeable
File SearchCount how many non-empty subsets of the files can be exactly the result set of some substring query.Hard8StringTrie+2No attempts yet5s128 MBJudgeable
File RecoverCount the distinct contiguous substrings that occur at least twice in a given string, for several test cases up to 100000 characters each.Hard8StringString matching+1No attempts yet5s128 MBJudgeable
Ambiguous CodesDecide whether a set of hexadecimal code words is ambiguous, and if so report the length of the shortest message with two distinct decodings.Hard8StringGraph+2No attempts yet1s128 MBJudgeable
Milk PatternsGiven N integers, find the length of the longest contiguous subsequence that repeats at least K times, counting overlapping occurrences.Hard8String matchingBinary search+2No attempts yet1s128 MBJudgeable