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
TitleLevelTopicsSolvedTime limitMemory limitJudge
XEN 3166Assign each country a length-K subsequence starting with its first letter so that code order matches name lexicographic order, or report impossible.Hard8GreedyString+1No attempts yet2s512 MBJudgeable
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.Hard8StringString matching+2No attempts yet1s512 MBJudgeable
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.Hard8String matchingDynamic programming+2No attempts yet4s512 MBJudgeable
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.Hard8StringSorting+2No attempts yet2s512 MBJudgeable
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.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Locker RoomPick length-K substrings from a cyclic string covering every position and minimize their lexicographic maximum.Hard8StringGreedy+2No attempts yet6s512 MBJudgeable
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.Hard8String matchingString+2No attempts yet2s512 MBJudgeable
A/B - 3Given A and B with up to 10000 digits (possibly negative), compute the quotient and nonnegative remainder of A divided by B.Hard8MathImplementation+2No attempts yet0.5s512 MBJudgeable
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.Hard8String matchingString+2No attempts yet2s512 MBJudgeable
Fraction ChallengeMultiply many huge fractions given as digit strings and output the reduced product as a/b.Hard8StringHash map+2No attempts yet0.5s512 MBJudgeable
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.Hard8String matchingMath+1No attempts yet3s512 MBJudgeable
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.Hard8Dynamic programmingGreedy+2No attempts yet5s512 MBJudgeable
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.Hard8String matchingDynamic programming+2No attempts yet2s512 MBJudgeable
Distinct Substring Queries 2Process a stream of append-character and count-distinct-substrings queries on a growing string, answering each count query online.Hard8StringString matching+2No attempts yet1s512 MBJudgeable
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.Hard8Dynamic programmingString matching+2No attempts yet2s512 MBJudgeable
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.Hard8StringTrie+2No attempts yet2s512 MBJudgeable
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.Hard8StringBrute force+2No attempts yet2s512 MBJudgeable
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.Hard8StringSliding window+2No attempts yet2s512 MBJudgeable
ZooGiven a string, count for each prefix the non-overlapping prefix-suffix matches and output the product of (count+1) modulo 1e9+7.Hard8StringString matching+2No attempts yet1s512 MBJudgeable
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.Hard8StringTrie+2No attempts yet1s512 MBJudgeable
Pipe MarblesGiven two binary strings as stacks, count the sum of squares of the number of interleavings producing each distinct output string, modulo 1024523.Hard8Dynamic programmingString+2No attempts yet1s512 MBJudgeable
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.Hard8Dynamic programmingMatrix+2No attempts yet1s512 MBJudgeable
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.Hard8Dynamic programmingString matching+2No attempts yet2.5s1024 MBJudgeable
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).Hard8Dynamic programmingString+2No attempts yet6s512 MBJudgeable
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.Hard8Dynamic programmingDivide and conquer+2No attempts yet1s512 MBJudgeable
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.Hard8StringBinary search+2No attempts yet2s512 MBJudgeable
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.Hard8Brute forceDynamic programming+2No attempts yet1s512 MBJudgeable
LCS 6Given two uppercase strings of up to 50000 characters, print the length of their longest common subsequence.Hard8StringDynamic programming+1No attempts yet1s8 MBJudgeable
LCS 7Given two strings of length up to 50000, find the length of their longest common subsequence and print one such subsequence.Hard8StringDynamic programming+2No attempts yet2s8 MBJudgeable
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.Hard8StringTrie+2No attempts yet2s512 MBJudgeable
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.Hard8TrieString+2No attempts yet4s512 MBJudgeable
PasswordsGiven n rows of m letters, permute the columns so the rows become lexicographically nondecreasing, choosing the smallest such permutation or reporting NIE.Hard8GreedySorting+2No attempts yet1.5s64 MBJudgeable
Balanced SequenceReorder n bracket strings to maximize the length of the longest balanced subsequence of their concatenation.Hard8GreedySorting+2No attempts yet1s256 MBJudgeable
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).Hard8StringDivide and conquer+2No attempts yet1s512 MBJudgeable
TrenerCount ways to pick one surname from each length bucket so every shorter surname is a substring of every longer one, modulo 1e9+7.Hard8StringDynamic programming+2No attempts yet2s512 MBJudgeable
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.Hard8Binary searchDynamic programming+2No attempts yet10s512 MBJudgeable
Dynamic Input ToolFind the minimum number of append-character and append-subsequence-of-current-string operations needed to build a given string from empty.Hard8Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Searching for StringsCount how many distinct permutations of the needle string N occur as a contiguous substring of the haystack string H.Hard8Sliding windowString matching+2No attempts yet2s512 MBJudgeable
Swapping SeatsGiven a circular string of A, B, C, find the minimum number of seat swaps needed so each letter forms one contiguous block.Hard8GreedySliding window+2No attempts yet2s512 MBJudgeable
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.Hard8Divide and conquerString+2No attempts yet2s512 MBJudgeable
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.Hard9GraphCombinatorics+2No attempts yet2s128 MBJudgeable
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.Hard9GraphMatrix+2No attempts yet2s128 MBJudgeable
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.Hard9Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
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.Hard9String matchingString+2No attempts yet1s128 MBJudgeable
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.Hard9RecursionString+2No attempts yet1s128 MBJudgeable
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.Hard9GraphShortest path+2No attempts yet5s128 MBJudgeable
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.Hard9StringSorting+2No attempts yet1s128 MBJudgeable
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.Hard9TreeImplementation+2No attempts yet1s128 MBJudgeable
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.Hard9Dynamic programmingIntervals+2No attempts yet1s128 MBJudgeable
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.Hard9StringBrute force+2No attempts yet3s128 MBJudgeable
PurifyRepeatedly delete forbidden substrings from P, always choosing the earliest-ending occurrence and removing the shortest such forbidden word, then print what remains.Hard9StringTrie+2No attempts yet1s64 MBJudgeable
Accountant NotesFor each note, find every starting row in the summary file where a renamed transcription of the note appears as consecutive rows.Hard9String matchingHash map+2No attempts yet5s512 MBJudgeable
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.Hard9StringGreedy+2No attempts yet1s512 MBJudgeable
The CodeGiven a prefix code entered via button presses, find the code words that resynchronize decoding after any loss of leading bits.Hard9TrieString+2No attempts yet1s128 MBJudgeable
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.Hard9StringPrefix sum+2No attempts yet1s128 MBJudgeable
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.Hard9StringSorting+2No attempts yet5s128 MBJudgeable
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.Hard9String matchingString+2No attempts yet1s128 MBJudgeable
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.Hard9StringDynamic programming+2No attempts yet1s128 MBJudgeable
Prefix-SuffixesCount proper borders summed over all substrings of a given lowercase word of length up to 10^5.Hard9String matchingString+1No attempts yet1s128 MBJudgeable
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.Hard9StringImplementation+2No attempts yet1s128 MBJudgeable
Palindromic EquivalenceCount words of the same length that have palindromic substrings at exactly the same positions as the given word.Hard9StringString matching+2No attempts yet1s128 MBJudgeable
Same Suffix ArrayCount the strings that differ from the given length N string in exactly one position and keep the same suffix array.Hard9StringString matching+1No attempts yet2s256 MBJudgeable
Dictionary SurveyFind how many leading pages of the integers from A to B in lexicographic order pin down both A and B.Hard9TrieMath+1No attempts yet3s256 MBJudgeable
Counting Distinct Suffix ArraysCount how many distinct suffix arrays length-N strings with at most M distinct letters produce, modulo 1e9+7.Hard9CombinatoricsString+1No attempts yet1s512 MBJudgeable
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.Hard9BacktrackingDynamic programming+2No attempts yet2s512 MBJudgeable
Bracket SubstringsCount how many distinct balanced bracket sequences appear as non-empty substrings of a given bracket string of length up to 500,000.Hard9StringHash map+2No attempts yet2s512 MBJudgeable
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.Hard9StringString matching+2No attempts yet2s512 MBJudgeable
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.Hard9StringString matching+2No attempts yet2s512 MBJudgeable
IntuidiffFind the minimum number of blocks, each a substring of the first string or a single new character, whose concatenation equals the second string.Hard9String matchingGreedy+2No attempts yet7s512 MBJudgeable
KabobsCount length-K strings over the given alphabet that satisfy all substring-implication rules of the form b>e, modulo 10^7.Hard9Dynamic programmingString+2No attempts yet5s512 MBJudgeable
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.Hard9StringString matching+2No attempts yetNot set16 MBJudgeable
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.Hard9Brute forceRecursion+2No attempts yet2s256 MBJudgeable
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.Hard9String matchingSegment tree+2No attempts yet2s512 MBJudgeable
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.Hard9StringStack+2No attempts yet0.3s512 MBJudgeable
KnowledgeCount strings of length x reachable from s by inserting or deleting the blocks aa, bbb, and ababab, modulo 998244353.Hard9StringCombinatorics+2No attempts yet1s512 MBJudgeable
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.Hard9StringHash map+2No attempts yet20s512 MBJudgeable
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.Hard9Dynamic programmingString+2No attempts yet10s512 MBJudgeable
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.Hard9Brute forceImplementation+2No attempts yet1s512 MBJudgeable
DoublindromesCount distinct substrings of s that are palindromes and split into two non-empty palindromes, with length at least k.Hard9StringString matching+2No attempts yet3s512 MBJudgeable
K-th StringCount permutations t of n distinct letters whose k-th smallest non-empty substring equals s, modulo 1e9+7.Hard9StringCombinatorics+2No attempts yet1s256 MBJudgeable
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.Hard9StringTrie+2No attempts yet1s1024 MBJudgeable
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.Hard9StringString matching+2No attempts yet2s512 MBJudgeable
GeneratorRead an index 0 to 10 and output the exact contents of the matching recovered file gen_i.out from the archive.Hard10ImplementationString+2No attempts yet2s256 MBJudgeable
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.Hard10StringString matching+1No attempts yet2s256 MBJudgeable
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.Hard10ImplementationBit manipulation+2No attempts yet2s512 MBJudgeable