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,785 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| XEN 3166Assign each country a length-K subsequence starting with its first letter so that code order matches name lexicographic order, or report impossible. | Hard8 | GreedyString+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Longest Common Palindromic SubstringGiven up to 50 strings with total length 1,000,000, find the length of the longest palindrome that occurs as a substring in every one of them. | Hard8 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Hiding MerlinDecompose a digit string into concatenated perfect squares, each at most 10 digits and starting with 1 to 9, and report the smallest possible total sum. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Injecting DNAFor every suffix of a string, compute its toxicity from the number of out-of-order suffix pairs, then output the length of the suffix with the largest effectiveness. | Hard8 | StringSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Intergalactic BiddingGiven up to 1000 bidders with huge distinct bids and a huge target s, find every bidder contained in a subset whose sum is exactly s. | Hard8 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Locker RoomPick length-K substrings from a cyclic string covering every position and minimize their lexicographic maximum. | Hard8 | StringGreedy+2 | No attempts yet | 6s | 512 MB | Judgeable |
| Repeated SubstringsFind the longest substring with at least two overlapping occurrences in a string of up to 10^5 letters, breaking ties by the smallest in lexicographic order. | Hard8 | String matchingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| A/B - 3Given A and B with up to 10000 digits (possibly negative), compute the quotient and nonnegative remainder of A divided by B. | Hard8 | MathImplementation+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Bad KemingFill every gap in the spaced copy of S with chosen letters to make the longest prefix of S a contiguous substring, and find that prefix length. | Hard8 | String matchingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Fraction ChallengeMultiply many huge fractions given as digit strings and output the reduced product as a/b. | Hard8 | StringHash map+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Distinct SubstringsGiven a period string p and length n, count distinct substrings of the string formed by repeating p and cutting to n. n may be 1e9. | Hard8 | String matchingMath+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Shortest Common Non-SubsequenceGiven two binary strings of length up to 4000, find the shortest binary string that is a subsequence of neither, breaking ties by lexicographic order. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Naming the ComputerGiven a string S and integer K, find the shortest string that contains S as a substring at least K times, and output its length. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct Substring Queries 2Process a stream of append-character and count-distinct-substrings queries on a growing string, answering each count query online. | Hard8 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Substring ReplacementReplace each question mark in S with a lowercase letter so that T appears as a substring as many times as possible, and report that maximum count. | Hard8 | Dynamic programmingString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| K-th SubstringGiven a string S, answer queries that ask for the K-th distinct substring of S in lexicographic order, or -1 if it does not exist. | Hard8 | StringTrie+2 | No attempts yet | 2s | 512 MB | Judgeable |
| String FoldingFold the string at a sequence of positions into vertical columns, then find the longest column-run of one repeated character that starts at the bottom with no gaps. | Hard8 | StringBrute force+2 | No attempts yet | 2s | 512 MB | Judgeable |
| String DecorationGiven a string S and N pattern strings, find the length of the shortest substring of S that contains every pattern as a substring. | Hard8 | StringSliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ZooGiven a string, count for each prefix the non-overlapping prefix-suffix matches and output the product of (count+1) modulo 1e9+7. | Hard8 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Ali's TypewriterGiven a keypress sequence that builds strings in a buffer and prints them, answer queries counting how often printed string x occurs inside printed string y. | Hard8 | StringTrie+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Pipe MarblesGiven two binary strings as stacks, count the sum of squares of the number of interleavings producing each distinct output string, modulo 1024523. | Hard8 | Dynamic programmingString+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Third Baseman UnknownOn an N by N grid of uppercase letters, walk right or down from the top-left to the bottom-right and maximize how many times "MOLA" appears in the collected string. | Hard8 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 512 MB | Judgeable |
| AbbreviationCount the ways to split a query string into pieces, where each piece is a prefix of some dictionary word, with duplicates counted as distinct. | Hard8 | Dynamic programmingString matching+2 | No attempts yet | 2.5s | 1024 MB | Judgeable |
| Dishonest DriverGiven a string of N characters, find the size of the shortest compressed form built from single characters, concatenation, and repetition (C repeated k times). | Hard8 | Dynamic programmingString+2 | No attempts yet | 6s | 512 MB | Judgeable |
| JOI Logo DesignGiven a circular string of length 4^K over {J,O,I}, find the rotation that minimizes mismatches with a level-K JOI sequence built by recursive quarter block replacement. | Hard8 | Dynamic programmingDivide and conquer+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Copy and PasteGiven a string of up to 200,000 lowercase letters, find the length of the longest substring that appears at least twice at disjoint positions, or -1 if none exists. | Hard8 | StringBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Interleaved Periodic StringGiven a binary string S, find the minimum total length of two binary strings whose repeated copies can be interleaved to produce S. | Hard8 | Brute forceDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| LCS 6Given two uppercase strings of up to 50000 characters, print the length of their longest common subsequence. | Hard8 | StringDynamic programming+1 | No attempts yet | 1s | 8 MB | Judgeable |
| LCS 7Given two strings of length up to 50000, find the length of their longest common subsequence and print one such subsequence. | Hard8 | StringDynamic programming+2 | No attempts yet | 2s | 8 MB | Judgeable |
| Crazy LCPGiven N strings and Q range queries, for each range [L, R] report the maximum longest common prefix over all pairs of distinct strings in that range. | Hard8 | StringTrie+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Exciting MenusGiven N strings with a joy value per position, maximize over all substrings the product of its length, the joy at its end, and the number of strings having it as a prefix. | Hard8 | TrieString+2 | No attempts yet | 4s | 512 MB | Judgeable |
| PasswordsGiven n rows of m letters, permute the columns so the rows become lexicographically nondecreasing, choosing the smallest such permutation or reporting NIE. | Hard8 | GreedySorting+2 | No attempts yet | 1.5s | 64 MB | Judgeable |
| Balanced SequenceReorder n bracket strings to maximize the length of the longest balanced subsequence of their concatenation. | Hard8 | GreedySorting+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Escape SequencesFor a morphism f that replaces a with aa and b with ab, find the smallest k such that t is a substring of the k-fold iterate f^k(s). | Hard8 | StringDivide and conquer+2 | No attempts yet | 1s | 512 MB | Judgeable |
| TrenerCount ways to pick one surname from each length bucket so every shorter surname is a substring of every longer one, modulo 1e9+7. | Hard8 | StringDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Related LanguagesGiven strings A and B and an integer k, find the longest pair of equal-length substrings, one from each string, that differ in at most k positions. | Hard8 | Binary searchDynamic programming+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Dynamic Input ToolFind the minimum number of append-character and append-subsequence-of-current-string operations needed to build a given string from empty. | Hard8 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Searching for StringsCount how many distinct permutations of the needle string N occur as a contiguous substring of the haystack string H. | Hard8 | Sliding windowString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Swapping SeatsGiven a circular string of A, B, C, find the minimum number of seat swaps needed so each letter forms one contiguous block. | Hard8 | GreedySliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| String ProcessingDecide whether a recursive split-and-swap program can turn string S into T, and if so output the 2^k - 1 bit program. | Hard8 | Divide and conquerString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Shom LanguageGiven a sentence with alternating uppercase and lowercase letters, find the minimum number of distinct two-letter words needed to rebuild it via overlapping placements. | Hard9 | GraphCombinatorics+2 | No attempts yet | 2s | 128 MB | Judgeable |
| All Closed-Walk LengthsGiven a directed graph, decide for every length x whether a closed walk of that length exists, then print the eventually periodic 0/1 sequence in its shortest prefix-plus-period notation. | Hard9 | GraphMatrix+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Hangul-Missing NumbersGiven which Hangul letters are forbidden, find the N-th positive integer up to 10^52-1 whose Korean numeral representation avoids all forbidden jamo, using digit DP over decomposed syllables. | Hard9 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Casting SpellsGiven a string, find the maximum length of a substring of the form ww^R w w^R (a palindrome ww^R followed immediately by itself) across up to 40 large test cases. | Hard9 | String matchingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| K’ak’-u-pakal and the Maya ScriptParse a recursive grammar for Maya glyph compositions and render a minimal-size ASCII-art box layout respecting horizontal/vertical grouping and bracket-doubling size rules. | Hard9 | RecursionString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Most Powerful SpellGiven a labeled directed graph, find the lexicographically smallest string that labels a walk from the star node to the gold node, or print NO if none exists or the minimum is unbounded. | Hard9 | GraphShortest path+2 | No attempts yet | 5s | 128 MB | Judgeable |
| ContactGiven a binary string and a length range [A,B], report the N largest occurrence counts and all patterns achieving each count, with output ordering rules. | Hard9 | StringSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Version-Controlled IDEMaintain a versioned text buffer under insert and delete operations, answering substring queries against any past version, with all commands encoded by a running counter. | Hard9 | TreeImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Synnerg LifeformGiven rewriting rules that merge adjacent synnergs with multiplicative lifetimes, find all maximum-lifetime synnergs obtainable by fully unifying some contiguous block of each input sequence. | Hard9 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 128 MB | Judgeable |
| JukeboxEach song has a title and artist; decide which artist fields to drop so the total length of shortest unique substrings over all title and remaining artist strings is minimized. | Hard9 | StringBrute force+2 | No attempts yet | 3s | 128 MB | Judgeable |
| PurifyRepeatedly delete forbidden substrings from P, always choosing the earliest-ending occurrence and removing the shortest such forbidden word, then print what remains. | Hard9 | StringTrie+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Accountant NotesFor each note, find every starting row in the summary file where a renamed transcription of the note appears as consecutive rows. | Hard9 | String matchingHash map+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Suffix Array ReconstructionGiven a permutation p, decide whether it is the suffix array of some lowercase string and, if so, output the lexicographically smallest such string. | Hard9 | StringGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| The CodeGiven a prefix code entered via button presses, find the code words that resynchronize decoding after any loss of leading bits. | Hard9 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PeriodicityFor each name, find the lexicographically smallest bit string of the same length whose set of periods equals the name's set of periods, or XXX if none exists. | Hard9 | StringPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Computational BiologyFor each query length m, find a length-m word whose every cyclic rotation appears in s, maximizing the total count of those rotations in s. | Hard9 | StringSorting+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Quasi-templateCount the distinct words that, as substrings of v with possibly overhanging copies, can tile across the whole input; report the count and the shortest, lexicographically smallest such word. | Hard9 | String matchingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fibonacci WordCount occurrences of a given binary pattern in the Fibonacci word F_m and count distinct subwords occurring at least that many times, mod 20062006, with m up to 1e9. | Hard9 | StringDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Prefix-SuffixesCount proper borders summed over all substrings of a given lowercase word of length up to 10^5. | Hard9 | String matchingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Minimum bracketsGiven an arithmetic template with holes, delete as many brackets as possible while keeping the same value for every valid assignment of real numbers to the holes. | Hard9 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Palindromic EquivalenceCount words of the same length that have palindromic substrings at exactly the same positions as the given word. | Hard9 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Same Suffix ArrayCount the strings that differ from the given length N string in exactly one position and keep the same suffix array. | Hard9 | StringString matching+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Dictionary SurveyFind how many leading pages of the integers from A to B in lexicographic order pin down both A and B. | Hard9 | TrieMath+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Counting Distinct Suffix ArraysCount how many distinct suffix arrays length-N strings with at most M distinct letters produce, modulo 1e9+7. | Hard9 | CombinatoricsString+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Binary cryptarithm decryptionGiven a short cipher string where letters replace some characters of an unknown binary equation, count how many valid equations from the given grammar match it. | Hard9 | BacktrackingDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Bracket SubstringsCount how many distinct balanced bracket sequences appear as non-empty substrings of a given bracket string of length up to 500,000. | Hard9 | StringHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct Substring QueriesMaintain a string under push-back and pop-front operations, reporting the number of distinct substrings after each of up to a million queries. | Hard9 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PseudoknotFind the largest t such that the string splits into u v z^R u^R y z with |u|>=t and |z|>=t, or report -1 if no such split exists. | Hard9 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| IntuidiffFind the minimum number of blocks, each a substring of the first string or a single new character, whose concatenation equals the second string. | Hard9 | String matchingGreedy+2 | No attempts yet | 7s | 512 MB | Judgeable |
| KabobsCount length-K strings over the given alphabet that satisfy all substring-implication rules of the form b>e, modulo 10^7. | Hard9 | Dynamic programmingString+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Parameterized Pattern MatchingFind every substring of text T that p-matches pattern P, where parameter names must correspond under a bijection and tokens match exactly. | Hard9 | StringString matching+2 | No attempts yet | Not set | 16 MB | Judgeable |
| Mischievous JunseokGiven a short English word and a multiset of letters, count the distinct strings obtainable from any contiguous substring with that letter multiset under the recursive half-split-and-reverse rule. | Hard9 | Brute forceRecursion+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Sequence and Queries 34Maintain two integer sequences under updates and range queries: for a suffix of a compute the longest match against b and how many suffixes achieve it, compare suffixes of b, and test whether a concatenation of two b-substrings is itself a substring of b. | Hard9 | String matchingSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| GnalcatsDecide whether two genes, each a sequence of seven possible base transformations on proteins, produce identical results or both fail on every sufficiently long input protein. | Hard9 | StringStack+2 | No attempts yet | 0.3s | 512 MB | Judgeable |
| KnowledgeCount strings of length x reachable from s by inserting or deleting the blocks aa, bbb, and ababab, modulo 998244353. | Hard9 | StringCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| String AlgorithmFor every k, cut s into blocks of length k, discard the tail, and count block pairs whose Hamming distance is at most one. | Hard9 | StringHash map+2 | No attempts yet | 20s | 512 MB | Judgeable |
| Counting Edit DistancesCount the number of distinct strings over 'A' to 'Z' whose Levenshtein distance from a given string s is exactly d, modulo 998244353. | Hard9 | Dynamic programmingString+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Integer Equation CheckerClassify an equation string as correct, format error, math error, or a typo fixable by replacing at most two characters with a valid correct equation. | Hard9 | Brute forceImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| DoublindromesCount distinct substrings of s that are palindromes and split into two non-empty palindromes, with length at least k. | Hard9 | StringString matching+2 | No attempts yet | 3s | 512 MB | Judgeable |
| K-th StringCount permutations t of n distinct letters whose k-th smallest non-empty substring equals s, modulo 1e9+7. | Hard9 | StringCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Jong Hyok and StringGiven n pattern strings, for each query string Q count the substrings T of the patterns with the same set of (pattern, end position) occurrence pairs as Q. | Hard9 | StringTrie+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Right Expansion Of The MindGroup n infinite strings, each formed by a finite prefix s followed by repeats of t, so that within each group every pair is mutually a subsequence of the other; minimize the number of groups. | Hard9 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| GeneratorRead an index 0 to 10 and output the exact contents of the matching recovered file gen_i.out from the archive. | Hard10 | ImplementationString+2 | No attempts yet | 2s | 256 MB | Judgeable |
| String Palindrome QueriesMaintain a lowercase string under block moves, reversals, and single-character insertions, answering after each change whether a given substring reads the same forwards and backwards. | Hard10 | StringString matching+1 | No attempts yet | 2s | 256 MB | Judgeable |
| RobotsDesign two robots' instruction tables so they classify a binary string as fine or coarse from its middle third's A and B counts, using four-bit memories, exact-then-wildcard dispatch, and 1000n steps. | Hard10 | ImplementationBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |