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 results139 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Trie ShardingSplit the strings among N labeled non-empty servers to maximize the total trie node count and report the maximum and the count of optimal splits modulo 1e9+7.Hard8Dynamic programmingTrie+1No attempts yet5s512 MBJudgeable
A Lot of GamesGiven a trie of strings, play the prefix-building game k times with the loser starting next; report who wins the last game.Hard8TrieGame theory+2No attempts yet2s512 MBJudgeable
Substring CountCount length-L lowercase strings that contain exactly C of N given words (N at most 6, L at most 50) as substrings, modulo 1,000,000,009.Hard8Dynamic programmingString matching+2No attempts yet2s512 MBJudgeable
Subsets whose lexicographic order matchesCount non-empty subsets of the integers from A to B whose numeric order equals their lexicographic decimal order, modulo P.Hard8CombinatoricsDynamic programming+2No attempts yet8s512 MBJudgeable
Favorite musicGiven n note strings and q pairs, find the shortest string containing both given fragments as contiguous substrings, allowing overlap.Hard8String matchingTrie+2No attempts yet1s256 MBJudgeable
ExamGiven each student's fixed semester points and a distribution of exam points, find the probability that the grade string avoids all forbidden substrings.Hard8Dynamic programmingString matching+2No attempts yet1.5s512 MBJudgeable
Dictionary GameWords are destroyed by prefix cuts; after each insertion into the dictionary, report which player wins the impartial game under optimal play.Hard8Game theoryTrie+2No attempts yet5s512 MBJudgeable
PasswordsCount length A to B alphanumeric passwords with mixed case and a digit that avoid blacklist substrings, where digits can stand in for similar letters.Hard8Dynamic programmingString matching+2No attempts yet2s512 MBJudgeable
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.Hard8TrieGreedy+2No attempts yet2s2048 MBJudgeable
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.Hard8StringTrie+2No attempts yet1s256 MBJudgeable
Standing Out from the HerdFor each name in the herd, count its substrings that occur in no other name.Hard8StringString matching+2No attempts yet2s512 MBJudgeable
The Jet-Black WingsMaintain a multiset under global XOR updates and queries asking for the sum of the K smallest elements.Hard8TrieBit manipulation+2No attempts yet3s512 MBJudgeable
Similar WordsGiven a set of distinct words, choose as many prefixes as possible so that no two chosen words differ by deleting one leading letter.Hard8TrieTree+2No attempts yet4s512 MBJudgeable
Prefix Suffix SearchGiven N words and Q prefix/suffix pairs, report for each query how many words match both prefix and suffix. Total input length is up to 2.5 million.Hard8String matchingTrie+2No attempts yet3s512 MBJudgeable
XOR MSTGiven N labeled vertices where the edge between any two has weight equal to the XOR of their labels, find the total cost of the minimum spanning tree.Hard8TrieMinimum spanning tree+2No attempts yet2s512 MBJudgeable
Sequence and Queries 20Maintain a multiset that starts with only 0, supporting insert, delete, and max-XOR queries where every element is XORed with x.Hard8TrieBit manipulation+2No attempts yet1s512 MBJudgeable
XOR SubmatrixBuild the N by M matrix with A[i][j] = V[i] xor U[j] and find the submatrix whose elementwise xor is maximal.Hard8Bit manipulationTrie+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
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
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
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
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
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
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
min-xorMaintain a dynamic set under insertions and deletions, and after each min-xor query report the smallest XOR of any two elements currently in the set.Hard8TrieBit manipulation+2No attempts yet0.4s8 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
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
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
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
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
XOR QueriesMaintain an array under appends, rollbacks of the last k elements, and range queries for max XOR, count <= x, and k-th smallest.Hard9TrieSegment tree+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
mexAfter XORing every element of a sequence with each query value x, report the mex (smallest missing non-negative integer) of the sequence.Hard9Bit manipulationTrie+2No attempts yet1s512 MBJudgeable
Beautiful ManyeongroCount directed paths in a rooted tree whose edge-label string equals a given pattern P.Hard9TrieDFS+2No attempts yet2s512 MBJudgeable
Bitwise XorCount non-empty subsequences in which the pairwise xor of every two chosen elements is at least x, modulo 998244353.Hard9Bit manipulationTrie+2No attempts yet2s512 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
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