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,786 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| 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. | Hard8 | StringGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| First!Given up to 30000 strings, find every string that can become lexicographically smallest under some permutation of the 26-letter alphabet. | Hard8 | StringTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Scrambled LettersGiven N scrambled names, find for each the lowest and highest rank its original anagram could occupy in an alphabetical ordering of all cows. | Hard8 | StringSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AppendGiven an LZ-style encoding as a list of (back-reference, length) pairs, count how many prefix positions split it into two valid non-empty encodings whose concatenation reproduces the original string. | Hard8 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| L-system SubstringGiven a D0L system over {a,b} and a query z, decide whether z appears as a contiguous substring of some word derivable from the start word. | Hard8 | StringSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| XenosemanticsFind words over lowercase letters delimited by varying spacer letters in a bit stream, then report the distinct true words that repeat and overlap another true word. | Hard8 | StringHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FoldGiven the sequence of A/V fold directions along an unfolded paper strip, find the minimum number of all-layer folding steps that produce it. | Hard8 | Dynamic programmingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Careful DeclarationMerge two word sequences into the shortest common supersequence, breaking ties by choosing the lexicographically smallest result. | Hard8 | Dynamic programmingString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| God of the Vile BaskersFind the longest prefix of a string that contains no two substrings with the same multiset of k alphabetic characters, ignoring case. | Hard8 | StringSliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Transforming CometsGiven two cyclic sequences of integer points, decide whether one is a rotation, uniform positive scaling, and translation of the other, and report the matching cyclic offset. | Hard8 | String matchingGeometry+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Post's Correspondence ProblemFind the shortest, lexicographically smallest index sequence whose A-concatenation equals its B-concatenation, under k < m. | Hard8 | BFSString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ransom NoteGiven a target note and a newspaper text, find the minimum number of contiguous clips (letters and spaces only, case-insensitive, reusable) needed to paste the note. | Hard8 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Automatic TradingGiven a string and pairs of positions, for each query find the length of the longest common prefix of the two suffixes starting at those positions. | Hard8 | StringString matching+2 | No attempts yet | 5s | 128 MB | Judgeable |
| The Palindromes Strike BackFor every position i, count the subsets of positions that include i and form a palindrome, then XOR all i times that count mod 1e9+7. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| ASMFind the fewest add/multiply/print commands in a one-variable program whose printed concatenation matches every test's required output. | Hard8 | Brute forceDynamic programming+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Changing Phone NumbersGiven area codes and a sequence of rules (digit duplication, digit swap, area-code change) applied over time, answer queries transforming a phone number from one year to another. | Hard8 | StringSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Puzzle OutGiven a dictionary and an encrypted uppercase text, recover the substitution cipher table or report no solution or multiple solutions. | Hard8 | BacktrackingHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DNA LaboratoryGiven up to 15 DNA strings, find the shortest string that contains all of them as substrings, breaking ties by lexicographic order. | Hard8 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Missing LettersReconstruct a space-free corrupted string into words from a known vocabulary, choosing the highest-scoring word segmentation and breaking ties alphabetically. | Hard8 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Identity CheckerEach test case gives a reverse Polish expression in x with sin, cos, and tan; decide whether it equals zero wherever defined. | Hard8 | MathString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CensorshipGiven a text and a filter word set, remove occurrences repeatedly to make the shortest possible result and report its length. | Hard8 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Vigenère CipherGiven a ciphertext and pair frequencies, find the key length-K shift maximizing the total frequency of adjacent plaintext letter pairs. | Hard8 | Dynamic programmingString+1 | No attempts yet | 5s | 64 MB | Judgeable |
| Cyclic Rotation CipherReconstruct the original lowercase string from its Burrows-Wheeler transform index i and last column R. | Hard8 | StringSorting+1 | No attempts yet | 1s | 32 MB | Judgeable |
| ByephoneFind the longest common subsequence of two strings up to length 10000 within 3MB of memory, breaking ties by the lexicographically smallest result. | Hard8 | Dynamic programmingString+2 | No attempts yet | 2s | 3 MB | Judgeable |
| EncodingFind the shortest encoding length for a target string under dynamic coding, where a changing marker toggles between verbatim and interpreted modes. | Hard8 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| Beer NumbersDecide whether a positive integer is the only one that can produce its row of binary mugs under any choice of which mug position means 1 and which reading direction. | Hard8 | StringCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| NecklacesDecide whether two run-length compressed string descriptions encode the same circular necklace up to rotation. | Hard8 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Word EquationsCount the binary word assignments to variables of fixed lengths that make the two sides of a word equation equal. | Hard8 | StringUnion-find+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Words 2Given exponents k1..kn, find the smallest m such that the concatenation of h_k(0) is a substring of h_m(0), or report NIE. | Hard8 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| WordsGiven indices k_i, decide whether the concatenation of the words h^{k_i}(0) appears as a substring of some h^m(0). | Hard8 | StringDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BeadsSplit the bead string into blocks of size k (leftover dropped) and find the k that maximizes the count of distinct blocks, where a block and its reversal are the same. | Hard8 | StringHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AntisymmetryCount how many contiguous substrings of a binary string are antisymmetric, meaning each character differs from its mirror-position partner. | Hard8 | StringHash map+2 | No attempts yet | 3s | 512 MB | Judgeable |
| A Horrible PoemGiven a string and substring queries, find the length of the shortest full period of each substring, where a full period divides the substring into equal repeats. | Hard8 | StringNumber theory+2 | No attempts yet | 8s | 128 MB | Judgeable |
| PrefixuffixGiven a string t, find the maximum length L, at most n/2, such that the length-L prefix and the length-L suffix of t are cyclic rotations of each other. | Hard8 | StringString matching+2 | No attempts yet | 3s | 512 MB | Judgeable |
| TransformationsGiven two binary strings of length n, decide whether disjoint ab and ba fragments can be swapped repeatedly to turn the first string into the second. | Hard8 | StringMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Shortest PeriodDelete exactly one letter from a string to minimize the length of the shortest period of the resulting word. | Hard8 | StringString matching+2 | No attempts yet | 5s | 128 MB | Judgeable |
| TurnsFor each starting position, find how many turns must be observed before the position on the map becomes uniquely determined. | Hard8 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Almost ConjugatesDecide whether two length-n words are almost conjugates and, if so, list every rotation of the first that differs from the second in exactly one position. | Hard8 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Gordian DancesGiven a sequence of S (string swap) and R (quarter-turn) moves, find the minimum number of further moves that returns the dance to a horizontal, parallel, untangled state. | Hard8 | MathString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CiągBajtek needs the shortest string over the given alphabet that is not a subsequence of the word, and the lexicographically smallest among shortest such strings. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Three-Bit ComputersThe task is to decide whether a target string over a, b and c can be built from uninitialized cells with the two pair operations. | Hard8 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| General BytorGiven two permutations of n unit types and m cyclic position-shift orders, find the shortest (then lexicographically smallest) sequence of at most 10 orders that transforms the start into the target. | Hard8 | Brute forceString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RitualCount the subsequences of a long digit string that form a palindrome divisible by 666, then report ((count - 1) mod 666) + 1. | Hard8 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Fibonacci GameDetermine whether the first player wins a game that erases Fibonacci words only from the right end of a given a/b string. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PandoraGiven the left/right turn sequence of a rectilinear polygon, count the coordinate axes it is monotone with respect to. | Hard8 | GeometryString | No attempts yet | 1s | 128 MB | Judgeable |
| Digital OnionGiven a balanced parentheses string, output the string that comes next in the defined price order. | Hard8 | CombinatoricsRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Correcting CuriosityGiven two strings, find the length of the shortest substitution command that rewrites the first into the second. | Hard8 | String matchingString+1 | No attempts yet | 2s | 256 MB | Judgeable |
| PasswordsFind the longest prefix length and suffix length from two distinct set strings whose repetitions coincide. | Hard8 | String matchingString | No attempts yet | 7s | 128 MB | Judgeable |
| Moves on an Infinite Binary TreeStarting from the node reached by S, count the distinct nodes reachable by following any subsequence of T on an infinite binary tree. | Hard8 | Dynamic programmingTree+1 | No attempts yet | 2s | 128 MB | Judgeable |
| RNAReport the longest contiguous block shared by both RNA strings whose parenthesis marks balance. | Hard8 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Eunki's DNA MoleculesFor every pair of N DNA strings, decide whether four two-way substring swaps can rewrite one into the other. | Hard8 | MathString+1 | No attempts yet | 5s | 256 MB | Judgeable |
| Ancient ScrollsRecover the lexicographically smallest string within Hamming distance d of three given strings, or print -1 when no such string exists. | Hard8 | GreedyString+1 | No attempts yet | 8s | 256 MB | Judgeable |
| Make a superpalindromeGiven a lowercase string, find the smallest superpalindrome of the same length that comes after it in lexicographic order. | Hard8 | StringRecursion+1 | No attempts yet | 1s | 16 MB | Judgeable |
| Selling NumbersCount how many D-digit strings, with leading zeros allowed, have exactly the memorability score S defined by palindromic and repeated substrings. | Hard8 | BacktrackingCombinatorics+1 | No attempts yet | 2s | 256 MB | Judgeable |
| SubstringsOrder all given strings as the consecutive length-L windows of one string of length L+N-1 and print the lexicographically smallest such string. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Round wordsGiven two words of length up to 2000, pick a rotation or reversal of each to maximize the LCS length and print that maximum. | Hard8 | Dynamic programmingString | No attempts yet | 2s | 128 MB | Judgeable |
| Birthday Numbers IIAdd up the products of every neighboring pair among the integers between x and y that use only the digits 3, 5 and 8, and report the total modulo 19980305. | Hard8 | MathRecursion+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Fair and Square (Large2)Count numbers in each interval [A, B] that read the same forwards and backwards and equal the square of such a number. | Hard8 | MathString+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Hongjun Likes StringsFor each of up to 100000 queries, find the shortest substring of a fixed string S that contains both given short patterns A and B, allowing overlap. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Maximum substring costGiven a string T, find the maximum of length times number of occurrences over all substrings S of T. | Hard8 | StringSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Flipping a Bit StringGiven a binary string and a divisor M of its length, find the minimum number of operations (single flip, prefix flip of a multiple of M, or suffix flip of a multiple of M) to make all characters 1. | Hard8 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Counting strings with LCS n-1Count length-n strings over the first m letters whose longest common subsequence with a given string S has length exactly n-1. | Hard8 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Fewest letters for a suffix arrayGiven a permutation that is a suffix array, find the minimum number of distinct letters needed for a string that realizes exactly this suffix array. | Hard8 | StringGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Calculation mistakeMaintain a string of digits and plus or minus signs under range replacements, and evaluate the arithmetic value of any substring with the calculator's operator rules. | Hard8 | Segment treeString+1 | No attempts yet | 3s | 256 MB | Judgeable |
| PasswordGiven a length-N string, collect all distinct substrings meeting four counts (length, digits, specials, uppercase), sort them lexicographically, and print the middle one. | Hard8 | StringSorting+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Big Number MultiplicationMultiply two non-negative integers of up to 300,000 digits each and print the exact product without leading zeros. | Hard8 | MathString+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Good SubstringsCount how many distinct substrings of a binary string appear twice at non-overlapping positions. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| New Store NameSplit each of two short strings into two non-overlapping contiguous pieces so that A+C equals B+D, and output the lexicographically smallest longest result. | Hard8 | StringBrute force+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Substitution Cipher KeyGiven N distinct words and a target permutation, find the lexicographically smallest substitution cipher key that sorts the encrypted words into that order, or report none. | Hard8 | GreedySorting+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Palindromes and QueriesSupport range character assignments and count palindromic substrings of length at most K inside a queried range. | Hard8 | Segment treeString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| What NextGiven a prefix of an NZPC Speak program cut at an arbitrary point, list the symbols that can legally come next, respecting declarations, masking, and partial names. | Hard8 | ImplementationSimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Revenge of the Champernowne ConstantGiven a digit string S of length up to 100, find the 1-indexed position of its first occurrence in the Champernowne constant 0.123456789101112... | Hard8 | StringMath+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Palindrome cipher decryptionFor each string, find its longest palindromic subsequence and output the lexicographically smallest one among those of maximal length. | Hard8 | Dynamic programmingString+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Favorite musicGiven n note strings and q pairs, find the shortest string containing both given fragments as contiguous substrings, allowing overlap. | Hard8 | String matchingTrie+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Game of MatchingsCount substrings of S that match pattern P under a bijective letter-to-number mapping, where distinct numbers must get distinct letters. | Hard8 | String matchingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Arranging HatEach of n m-digit strings may have individual digits rewritten; find the minimum number of digit changes so the sequence becomes nondecreasing. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Binary CodeEach of n binary words has at most one unreadable bit; decide whether the ?s can be filled so no word is a prefix of another. | Hard8 | TrieGreedy+2 | No attempts yet | 2s | 2048 MB | Judgeable |
| K-th good stringGiven a bracket string S, list the distinct good strings that appear as subsequences in lexicographic order and print the K-th one. | Hard8 | Dynamic programmingString+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Substring appearing twiceGiven a string and at most K letter replacements, maximize the length of the longest substring that occurs at two different starting positions, allowing overlap. | Hard8 | StringBinary search+2 | No attempts yet | 6s | 128 MB | Judgeable |
| ZvonimirFind the minimum number of operations (type one letter, or copy a contiguous block of already typed text and append it) to produce string X. | Hard8 | Dynamic programmingString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| ExpressionParse a two-dimensional rendering of nested fractions, additions, multiplications, and divisions, then print the reduced value as a fraction. | Hard8 | ImplementationRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |
| RhymeGiven N distinct words, find the longest sequence using each word at most once where consecutive words rhyme: their longest common suffix has length at least the longer word's length minus one. | Hard8 | StringTrie+2 | No attempts yet | 1s | 256 MB | Judgeable |
| f(X) = A + X + B + X + CCount occurrences of pattern F in the K-fold string expansion f(X)=A+X+B+X+C applied to S, modulo 1e9+7. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Integeregex (Large)Count integers in [A, B] whose decimal form (no leading zeros) matches a small regular expression over digits. | Hard8 | Dynamic programmingString+2 | No attempts yet | 5s | 512 MB | Judgeable |
| String TableBuild a table whose cells are huge concatenated strings defined by comparing neighbors, then print 50 characters from a given position of the final cell. | Hard8 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Palindromes and Queries 2Given a string and queries, each query asks how many palindromic substrings start at a given index with length at least a given value. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Period of a Slot MachineGiven a sequence of n outcomes, find k and p minimizing k+p (ties by smaller p) such that T[i+p]=T[i] for all i>k with i+p<=n. | Hard8 | String matchingImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Jumping FrogGiven a circular string of rocks and ponds, count the step sizes K (1 to N-1) for which some rock's K-step cycle stays entirely on rocks. | Hard8 | Number theoryMath+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Long Long StringsDecide whether two sequences of insertions and deletions, applied to any sufficiently long string, produce identical results. | Hard8 | StringMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Flipping OutCount the strings that, added to the given patterns, make the flip rule reproduce the given flip sequence, or -1 if infinitely many work. | Hard8 | StringDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| String PuzzleGiven equality hints between substrings of a huge implicit string plus some fixed letters, decide the letters at the queried positions. The hint structure is a partition of the string into sections, and a hint joins one section to an earlier same-length section, so the constraints are interval equalities on an unknown string of length n; the task is to propagate equality and fixed letters across positions, answering ? where a position's letter is not forced. The input size is small (at most 1000 hints and 1000 queries) but n can be 10^9, so positions cannot be enumerated directly and the hint/ | Hard8 | StringUnion-find+1 | No attempts yet | 2s | 512 MB | Judgeable |
| MarsFor each query substring, find the minimum number of bit flips that make it match no substring of the DNA, or report Impossible. | Hard8 | String matchingDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| RetroGiven a grid where the player moves horizontally while objects fall one row per turn, collect brackets to form the longest valid expression and output the lexicographically smallest one of that length. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Concert Attendance SchedulesCount the ways to pick increasing day positions matching a target band sequence, where each pick must wait h_b+1 days after that band's previous pick. | Hard8 | Dynamic programmingString | No attempts yet | 0.3s | 128 MB | Judgeable |
| Vera and the BanquetGiven a circular string S, count the number of distinct substrings appearing in any contiguous block read in either direction around the circle. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Standing Out from the HerdFor each name in the herd, count its substrings that occur in no other name. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Operation OptimizationFind the shortest sequence of append-0, append-1, and self-doubling operations whose two-fold application to the empty string yields a given binary string S. | Hard8 | StringGreedy+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Big Number Multiplication (2)Multiply two integers of up to 300,000 digits each, too large for quadratic multiplication, and print the exact product. | Hard8 | MathDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hit of the SeasonFind the shortest print matrix over R, G, B that can reproduce a wallpaper string, where specified stripes must never be overprinted and at most 19 stripes are unspecified. | Hard8 | StringBrute force+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Go with the FlowChoose a line width for justified monospaced text, then find the longest run of spaces that drifts by at most one column per line, and report the best width and length. | Hard8 | Brute forceString+2 | No attempts yet | 12s | 1024 MB | Judgeable |