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
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Huffman EncodingGiven prefix-free binary codes for up to 20 letters, decode a binary string of at most 250 digits back into the original letters. | Easy3 | TrieString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| File Fix-it (Small)Count the mkdir commands needed to create each requested path from its missing prefixes. | Easy3 | TrieString | No attempts yet | 5s | 512 MB | Judgeable |
| File Fix-it (Large)Count the directories along each wanted path that do not exist yet and report how many mkdir calls they need. | Easy3 | TrieString | No attempts yet | 5s | 512 MB | Judgeable |
| Shortest PrefixesFor each word in a list, find the shortest prefix that matches only that word, counting an exact match as unique even if longer words share it. | Medium4 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Phone ListGiven a list of distinct phone numbers, decide whether any number is a prefix of another. | Medium4 | TrieString+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Disk TreeGiven full directory paths, rebuild the tree and print every directory name on its own line, indented by depth, with siblings in ASCII order. | Medium4 | TrieSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Auto-CompleteThe app prints the original index of the K-th dictionary word with each query prefix in alphabetical order, or -1. | Medium4 | TrieSorting | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Prefix MatchGiven X bit prefixes with ids and Y destination addresses, print the id of the longest matching prefix for each address or -1. | Medium4 | TrieBit manipulation | No attempts yet | 1s | 256 MB | Judgeable |
| PrefixGiven up to 50 words, find the largest subset where no word is a prefix of another, using a trie and tree DP. | Medium5 | TrieDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Similar WordsGiven up to 20,000 distinct words, find the pair with the longest common prefix, breaking ties by input order. | Medium5 | StringSorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Word SearchGiven N database words compared in order against a query using character-by-character matching that also checks for word-end, compute total comparisons per query. | Medium5 | TrieString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Decoding Morse SequencesCount the number of ways to split a given Morse code string into a sequence of dictionary words, using dynamic programming with Morse-to-word conversion. | Medium5 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow TypingGiven a dictionary and short email words, simulate the cow's letter selector with a trie and count total button presses, including circular highlight moves and prints. | Medium5 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| No Pause TelegraphGiven a string of dots and dashes and seven fixed letter codes, split it into codewords that minimize the resulting message alphabetically, or report that no split exists. | Medium5 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 77377Split a digit string into dictionary words whose telephone-keypad encoding matches each segment. | Medium5 | Dynamic programmingTrie+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Prefix-Free SubsetsCount the subsets of the given word set in which no word is a prefix of another word. | Medium5 | TrieDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Find the Hidden WordGiven a list of known words and several messages, find which listed words occur as substrings in each message and report NO, the unique word, or AMBIGUOUS. | Medium5 | String matchingTrie | No attempts yet | 1s | 256 MB | Judgeable |
| BoggleFind every dictionary word that can be spelled on each letter grid with adjacent cells and no cell reused, treating q as qu. | Medium5 | BacktrackingTrie+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Trie Sharding (Small)Split up to 8 strings across labeled servers to maximize the summed trie node counts and count the optimal splits. | Medium5 | Brute forceTrie+1 | No attempts yet | 5s | 512 MB | Judgeable |
| DNA SequencingEach printed line can be trimmed to any prefix; pick prefixes of length at least M so the number of distinct resulting strings is maximized. | Medium5 | TrieString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Finding PrefixesGiven a set of N strings, count how many of M query strings appear as a prefix of at least one string in the set. | Medium5 | TrieString | No attempts yet | 1s | 1536 MB | Judgeable |
| PasswordsCount ordered pairs of distinct passwords where one string is a substring of the other, treating the passwords as a multiset of short strings. | Medium5 | String matchingHash map+1 | No attempts yet | 1s | 64 MB | Judgeable |
| TypoGiven a dictionary of unique words, print each word that becomes another dictionary word after deleting exactly one character, in input order. | Medium5 | Hash mapString+2 | No attempts yet | 6s | 512 MB | Judgeable |
| Word PuzzleCount how many words from a fixed dictionary can be spelled by paths of adjacent, non-repeating cells in a 5x5 letter grid. | Medium6 | TrieBacktracking+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Beautiful NamesCount the number of orderings of N distinct strings such that all strings sharing a common prefix always form a contiguous block, modulo 1e9+7. | Medium6 | TrieCombinatorics+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Word DivisionCount the number of ways to split a long word (up to length 300,000) into consecutive substrings all belonging to a dictionary of up to 4000 short words, modulo 1337377. | Medium6 | Dynamic programmingString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| KokosGiven N words of length 2K, build a trie for the first K letters and a reversed trie for the last K letters and find the minimum vertex count of a graph satisfying strict in/out degree branching-then-merging structure. | Medium6 | TrieString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Compound WordsGiven a dictionary of up to 120,000 sorted lowercase words, list every word that can be split into two shorter dictionary words. | Medium6 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Card HandsGiven several ordered card hands, merge lists that share a common suffix and report the total number of linked list nodes needed. | Medium6 | TrieString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Monkeys at TypewritersGiven per-letter and space probabilities, find the probability that a random key sequence terminates at its first space in one of the given words. | Medium6 | ProbabilityTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ToponymsGiven up to a million strings, find a subset maximizing the longest common prefix length times the subset size. | Medium6 | StringTrie+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Cellphone Keypad AutocompleteFor each word in a dictionary, compute how many letters a phone keypad must type when unique suffixes are autofilled, then print the average presses. | Medium6 | TrieTree+2 | No attempts yet | 1s | 192 MB | Judgeable |
| Villain RobotsChoose a string of K characters over {A,B,C} maximizing the total number of substring occurrences of the given pattern strings. | Medium6 | Dynamic programmingString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Secret MessageGiven M binary messages and N binary codewords, count for each codeword how many messages share a prefix relation with it in either direction. | Medium6 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dory's PhonebookGiven a dictionary of words and a phone number, find every encoding of the number as a space-separated sequence of dictionary words, sorted lexicographically. | Medium6 | TrieBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BoggleFind all dictionary words on each 4x4 Boggle board with 8-direction steps without reuse, then report the total score, longest word, and word count. | Medium6 | TrieDFS+1 | No attempts yet | 10s | 512 MB | Judgeable |
| Substring Set MembershipYou receive a set of patterns and query strings and print YES for each query containing a pattern as a contiguous substring, NO otherwise. | Medium6 | String matchingTrie | No attempts yet | 1s | 256 MB | Judgeable |
| T9Simulate T9 predictive text: map digit presses to dictionary words ordered by frequency, cycle candidates with star, and update frequencies on accept. | Medium6 | TrieSimulation+1 | No attempts yet | 1s | 256 MB | Judgeable |
| IP Address Summarization (Large)The task merges the given IPv4 subnets into the shortest sorted list of normalized subnets covering exactly the same addresses. | Medium6 | TrieBit manipulation+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Garbled Email (Small)Split the received string into dictionary words with changed letters at least 5 apart and as few changes as possible. | Medium6 | Dynamic programmingTrie | No attempts yet | 30s | 512 MB | Judgeable |
| Bless You Autocorrect!For each target word, compute the fewest keystrokes using letter keys, tab (autocomplete to the most common dictionary word matching the typed prefix), and backspace. | Medium6 | TrieDynamic programming+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Word Puzzle 2Given a 5x5 letter grid and up to 20000 dictionary words, count how many words can be traced through adjacent cells without reusing a cell. | Medium6 | DFSBacktracking+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Maximum XOR of two numbersGiven N non-negative integers, find the maximum XOR over all pairs of distinct elements. | Medium6 | Bit manipulationTrie | No attempts yet | 2s | 512 MB | Judgeable |
| CoggleGiven a 5x5 letter grid and a dictionary, count how many dictionary words can be traced through adjacent cells without reusing a cell. | Medium6 | BacktrackingTrie+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Ant NestGiven paths of food names from the top floor down, print the merged tree with each node indented by two dashes per depth and children in dictionary order. | Medium6 | TrieTree+2 | No attempts yet | 1s | 256 MB | Judgeable |
| HaikuGiven a set of syllables, decide whether the three input phrases can each be split into syllables so their syllable counts are 5, 7, and 5. | Medium6 | Dynamic programmingString+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Gluing PicturesGiven a city string C, find for each friend name the fewest substrings of C that concatenate to form it, or -1 if impossible. | Medium6 | Dynamic programmingString matching+2 | No attempts yet | 0.3s | 512 MB | Judgeable |
| ASCII StreetGiven a street string and multiple pattern tiles, count how many street positions are never covered by any occurrence of any pattern, requiring efficient multi-pattern matching like Aho-Corasick. | Medium7 | String matchingTrie+1 | No attempts yet | 4s | 512 MB | Judgeable |
| Size of the DictionaryCount distinct words formed as base words themselves, plus prefix-of-one-base-word concatenated with suffix-of-another-base-word combinations. | Medium7 | TrieString matching+1 | No attempts yet | 2s | 128 MB | Judgeable |
| DFAGiven a finite set of words, compute the minimum number of states of a DFA recognizing exactly that language. | Medium7 | TrieDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| DecipheringCount the ways to split an unspaced text into dictionary words, group them into sentences, and match each sentence to a valid part-of-speech rule, capping the huge counts. | Medium7 | Dynamic programmingString+2 | No attempts yet | 2s | 64 MB | Judgeable |
| CrabblesGiven a dictionary and hands of at most 10 lettered tiles with values, find the maximum-scoring dictionary word formable from each hand's tiles. | Medium7 | TrieBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| YO!Count paint-over patterns of a short string whose remaining letters, read left to right, form one or more dictionary words without overlap. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Insufficient Disk SpaceGiven files to delete and files to keep, find the minimum number of rm commands (exact or prefix wildcard) to remove all deletable files while keeping the rest. | Medium7 | TrieGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Type PrinterFind the minimum number of add, remove, and print operations to type N distinct words on a printer that keeps a single editable string, with any print order allowed. | Medium7 | TrieDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Emoticons :-)Given a set of emoticon strings, replace the fewest characters with spaces across several text lines so that no emoticon appears consecutively in any line. | Medium7 | String matchingDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Threatening LetterGiven a newspaper string and a message, split the message into the fewest contiguous pieces, each of which appears somewhere in the newspaper. Output that minimum count. | Medium7 | StringDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Forgotten PasswordFind the lexicographically smallest length-L string that matches a pattern of known letters and '?' and can be written as a concatenation of given dictionary words. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SubstringsCount the distinct substrings of a string, including the empty string and the whole string, for up to 5000 characters per test case. | Medium7 | StringTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Walk the TalkCount the number of distinct monotone paths (only right and/or up hops) through an H by W letter grid whose visited letters spell one of N given words. | Medium7 | Dynamic programmingTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Color PaletteMaintain a set of K-bit colors under insertions and, for each query color, return the stored color with the maximum number of matching bit positions, breaking ties by smallest value. | Medium7 | TrieBit manipulation+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| ACM-TelecomGiven a prefix table that assigns costs to 8-digit numbers, find the minimum number of prefix rows preserving every number's charged cost. | Medium7 | TrieGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Amusing NumbersGiven K and M, find the smallest N such that K sits at lexicographic position M among the numbers 1 to N. | Medium7 | MathBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DictionaryGiven a list of words, insert leading spaces so the list satisfies a recursive definition: every maximal run of words sharing a first letter must, after removing the first word and that letter, again be a dictionary. | Medium7 | TrieRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| VirusesGiven a set of forbidden binary words, decide whether an infinite binary sequence exists that avoids all of them as contiguous substrings. | Medium7 | String matchingTrie+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Error CorrectionGiven letter-to-bits codebook and binary strings, decide if exactly one letter sequence encodes to within one bit flip. | Medium7 | Dynamic programmingString matching+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Dividing the namesSplit 2N names into N streets and N avenues so the total length of shortest unique prefixes on all N by N crossing signs is minimal. | Medium7 | TrieDynamic programming | No attempts yet | 3s | 256 MB | Judgeable |
| Barbarian TabletsEach query asks how many words shown so far contain the tablet word of barbarian S as a contiguous substring. | Medium7 | String matchingTrie | No attempts yet | 4s | 768 MB | Judgeable |
| XOR SumYou insert numbers into a list and each print query asks for the XOR of the K largest values. | Medium7 | TrieBit manipulation | No attempts yet | 2s | 256 MB | Judgeable |
| Number of distinct substrings 2Count how many different contiguous substrings appear in the given lowercase string of length up to 1,000,000. | Medium7 | String matchingSorting+1 | No attempts yet | 5s | 256 MB | Judgeable |
| XORPrint the start and length of the longest contiguous segment whose xor is at least x. | Medium7 | TrieBit manipulation+1 | No attempts yet | 5s | 256 MB | Judgeable |
| OOPCount for each pattern with one asterisk how many given words equal it after replacing the asterisk with any string, possibly empty. | Medium7 | String matchingHash map+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Garbled EmailSplit the garbled string into dictionary words with changed letters spaced at least 5 apart while changing as few letters as possible. | Medium7 | Dynamic programmingTrie+1 | No attempts yet | 60s | 512 MB | Judgeable |
| The Killer Word (Large)Choose the dictionary word that forces the most wrong letter guesses from a guesser who tries letters in a fixed order while ruling out inconsistent words. | Medium7 | TrieSimulation+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Selling RNA StrandsFor each query pair P, Q, count how many dictionary strings start with P and end with Q, where the prefix and suffix may overlap. | Medium7 | TrieString matching | No attempts yet | 2s | 1536 MB | Judgeable |
| Contiguous Subsequence XORCount contiguous subsequences of the given sequence whose bitwise XOR is less than K. | Medium7 | Bit manipulationTrie+1 | No attempts yet | 1s | 512 MB | Judgeable |
| The Witch's PuzzleGiven N words, permute the letters of each word independently and find the minimum number of nodes in the prefix tree (trie) of the resulting set. | Medium7 | TrieDynamic programming+2 | No attempts yet | 2s | 64 MB | Judgeable |
| Largest XOR sum subarrayGiven a sequence, find the maximum XOR value over all contiguous subarrays of length at least one. | Medium7 | Bit manipulationTrie+2 | No attempts yet | 10s | 512 MB | Judgeable |
| CastleMaintain a growing string under appends, insertions of the whole current string into a set, and queries counting how many stored strings are suffixes of the current string. | Medium7 | StringTrie | No attempts yet | 0.5s | 256 MB | Judgeable |
| XOR Sum 2Process a stream of insertions and queries, printing the XOR of the K largest stored values. | Medium7 | TrieBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Separate StringCount the ways to split string t into a sequence of pieces, each of which is one of N given dictionary strings, modulo 1e9+7. | Medium7 | Dynamic programmingTrie+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Prefix Free CodeGiven n prefix-free strings, rank a given concatenation of k of them among all ordered k-selections sorted alphabetically, modulo 1e9+7. | Medium7 | TrieCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| First of Her NameGiven a family tree where each lady's name is her first letter prepended to her mother's name, count for each query string how many lady names have it as a prefix. | Medium7 | StringTrie+2 | No attempts yet | 10s | 512 MB | Judgeable |
| NVWLSGiven a dictionary of words and a consonant-only message, reconstruct a sentence whose words concatenate to the message after vowels and spaces are removed, maximizing total vowels. | Medium7 | Dynamic programmingString+2 | No attempts yet | 6s | 1024 MB | Judgeable |
| Hidden WordsGiven a grid of up to 10x10 letters and up to 100,000 query words of length at most 10, count how many words can be traced through adjacent, non-repeating cells. | Medium7 | BacktrackingDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Billing TablesGiven an ordered old billing table with range-based prefix rules, build the minimal prefix-only dictionary table (no prefix a prefix of another) that reproduces exactly the same plan decisions for all 11-digit numbers. | Hard8 | TrieGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fill the CrosswordFill a crossword grid with a given word list so every slot holds a listed word exactly once and crossings match; also decide if no solution exists. | Hard8 | BacktrackingTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GHOSTGiven a GHOST position and dictionary, decide whether the computer should challenge, add the smallest safe letter, or bluff. | Hard8 | Game theoryTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A-to-ZGiven a word dictionary, for each pair of letters find the minimum total width of a word chain where consecutive words overlap by at least two letters, and the first starts with C1, the last ends with C2. | Hard8 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Spelling SuggestionGiven weighted edit costs including keyboard-aware substitution and transposition, find the dictionary words closest to each query word. | Hard8 | Dynamic programmingString+2 | No attempts yet | 12s | 128 MB | Judgeable |
| Sanghak LanguageCount the distinct strings formed by concatenating any nonempty prefix of a Namgyu word with any nonempty suffix of a Jaehyeok word, summing over several test cases. | Hard8 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| File SearchCount how many non-empty subsets of the files can be exactly the result set of some substring query. | Hard8 | StringTrie+2 | No attempts yet | 5s | 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 |
| TreasureGiven a connected graph with N nodes and N edges and max degree 4, count the distinct rooted versions of the graph up to isomorphism, where each root is a non-4-degree node. | Hard8 | GraphTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Word CountingGiven a rooted tree whose edges carry letter strings, count distinct occurrences of a query word along all paths from the root to the leaves, identifying each occurrence by its start and end position. | Hard8 | String matchingTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree Rotations 2Given a binary tree with distinct leaf labels, rotations swap children at any node; find the minimum possible inversion count of the leaf sequence. | Hard8 | Divide and conquerRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fine Dining RestaurantFor each banned serial number, count the digit comparisons the described naive left-to-right substring search performs against the concatenated string A. | Hard8 | String matchingTrie+1 | No attempts yet | 3s | 128 MB | Judgeable |
| DictionaryGiven up to 50 short words, find the fewest vertices of an edge-labeled tree whose downward paths contain every word. | Hard8 | TrieString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Just a QuizTeresa interrupts randomly drawn known questions at chosen words to maximize expected correct answers within t seconds. | Hard8 | Dynamic programmingTrie+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Alphabet Blocks and PasswordsArrange A to Z into the lexicographically smallest permutation with none of the given passwords appearing as a contiguous block. | Hard8 | BacktrackingString matching+1 | No attempts yet | 5s | 512 MB | Judgeable |