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
ICPCConcatenate all lowercase words of length 1 through N in length-then-alphabetical order; count occurrences of the substring "icpc" modulo 1e9+7, with N up to 1e9.Hard8CombinatoricsString matching+2No attempts yet2s512 MBJudgeable
K==SCount sequences of length N over 26 letters that avoid any of Q given forbidden strings as contiguous substrings, modulo 1e9+7, where N can be up to 1e9.Hard8String matchingDynamic programming+2No attempts yet1s512 MBJudgeable
Ambiguous EncodingGiven a set of distinct binary codewords, decide whether two different character sequences can encode to the same bit string, and if so print the length of the shortest such string.Hard8String matchingBFS+2No attempts yet2s512 MBJudgeable
Fantastic FožgajCount length-m lowercase strings over 26 letters that avoid any of n forbidden patterns as a substring, modulo 1e9+7, with m up to 1e9.Hard8Dynamic programmingString matching+2No attempts yet1.5s512 MBJudgeable
Banned WordsCount length-L strings over 26 letters avoiding a given set of banned substrings, modulo 998244353, with L up to 1e9.Hard8String matchingTrie+2No attempts yet2s512 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
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
Heavy BurgerMaintain a string of parentheses under range flips, and for each query on a substring report the minimum number of characters to insert so the substring becomes a balanced parenthesis sequence.Hard8Segment treeString matching+2No attempts yet3s1024 MBJudgeable
Shom CodeGiven binary codes assigned to up to 26 letters, find the minimum length of a binary string decodable as three or more distinct letter sequences, or -1 if none exists.Hard9TrieBFS+2No attempts yet2s128 MBJudgeable
Hard MatchingGiven a text sequence and two number patterns, count positions where consecutive-sum grouping matches each pattern, then find the smallest glue value x maximizing matches of the concatenated pattern with x inserted between them and report that match count.Hard9String matchingPrefix sum+2No attempts yet30s1536 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
OutsourcingGiven two directed labeled graphs (factories) with start and final nodes, decide whether the two sets of label sequences realizable as paths from start to final are identical.Hard9GraphDFS+2No attempts yet1s128 MBJudgeable
Old MemoriesGiven pieces of an original text and an altered copy with at most d edits, list all original strings whose edit distance to the copy is at most d and where every position lies inside some piece occurrence.Hard9String matchingDynamic programming+2No attempts yet10s128 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
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
ExamGiven each student's distribution over exam scores, find the exact probability that the sequence of European marks from all students avoids every listed unpleasant string.Hard9Dynamic programmingString matching+2No attempts yet2s128 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
Axes of SymmetryFor each simple polygon, count its axes of symmetry; n can reach 100000, so the check must run in near-linear time.Hard9String matchingGeometry+2No attempts yet1s128 MBJudgeable
Isles in a Triangular GridEnumerate all non-congruent triangular-grid isles of up to ten triangles, canonicalizing each by the lexicographically smallest clockwise boundary-turn word.Hard9GeometryBrute force+2No attempts yet1s128 MBJudgeable
HamstersFind the shortest lowercase string containing at least m occurrences of the given hamster names, counted with multiplicity.Hard9String matchingDynamic programming+2No attempts yet3s512 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
FragmentsCount how many times each digit string appears as a contiguous substring across the decimal forms of all numbers in a union of disjoint integer intervals up to 10^18.Hard9String matchingDynamic programming+2No attempts yet1s128 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
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
PuzzleBuild the longest string over the first n capital letters that avoids all forbidden substrings, or print No when no maximum exists.Hard9String matchingTrie+2No attempts yet1s128 MBJudgeable
Dragon PatternCount how many times pattern S appears as a contiguous block in the length 2^n direction string of the order-n left dragon curve.Hard9String matchingRecursion+2No attempts yet5s128 MBJudgeable
Expression and SubstringFind the shortest string that matches the given regular expression and contains S as a substring, breaking ties by lexicographic order.Hard9Shortest pathGraph+1No attempts yet10s256 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
Counting StringsCount strings over the lowercase alphabet whose length lies between L*K and L*K+N and in which at most K non-overlapping copies of a given pattern S can be found.Hard9Dynamic programmingString matching+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
HackerSimulate substring comparisons, substring copy from a fixed string, and range letter-increment operations on a mutable string of length N.Hard9Segment treeHash map+2No attempts yet4s512 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
Incremental Double Free StringsFind the nth string of length k(k+1)/2 that uses one letter j times for each j up to k and has no two equal adjacent letters, in alphabetical order.Hard9CombinatoricsDynamic programming+2No attempts yet2s512 MBJudgeable
Tarot Sham BoastGiven up to 10 equal-length strings over {R,P,S} and a length n random string, sort the strings by the probability each occurs as a contiguous block.Hard9String matchingProbability+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
Crazy RotationsGiven a row of coloured lights, find the smallest rotation amount that can appear at position p in a non-decreasing sequence of rotation craziness values.Hard9String matchingCombinatorics+2No attempts yet15s512 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
Want to solve a problem?For given K and C, choose A > 0 to maximize the characters saved by writing K+A repeated K+A times instead of K repeated K times, minus C times A.Hard9String matchingMath+2No attempts yet1s128 MBJudgeable
MessageCount length-n lowercase strings that contain a given pattern p as a substring, modulo m, where n can reach 10^12 and p has length at most 50.Hard9Dynamic programmingString matching+2No attempts yet5s512 MBJudgeable
Beautiful ManyeongroCount directed paths in a rooted tree whose edge-label string equals a given pattern P.Hard9TrieDFS+2No attempts yet2s512 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
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
Speed Reading CourseCount how many positions i where c contains the given m-bit word w, with c defined by an arithmetic progression modulo n against threshold p.Hard9Number theoryString matching+2No attempts yet2s512 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
AdditionDesign a short string-rewriting script in a custom language that reads two binary numbers joined by + and rewrites them into their binary sum.Hard9String matchingSimulation+2No attempts yet1s256 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
JokeGiven a text and up to ten patterns with per-letter erasure costs, delete letters so that no pattern occurs, minimizing total cost.Hard9String matchingDynamic programming+2No attempts yet1s512 MBJudgeable
Flip a CoinTwo players each pick a heads/tails string of length up to 20; a fair coin is flipped until one or both strings appear, and we must output the probabilities of Alice winning, Bob winning, and a tie.Hard9ProbabilityDynamic programming+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
Fibonacci Digit CountCount occurrences of the substring "11" within the first N characters of the infinite string formed by writing 1, 2, 3, ... in Fibonacci (Zeckendorf) representation.Hard9MathDynamic programming+2No attempts yet2s1024 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