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,786 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Health Plan ComparisonParse free-text health plan descriptions to extract premiums and copay rules, then compute each plan's total yearly cost across the given visits. | Medium7 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Polly Wants a CrackerMatch each spoken word to a distinct original word minimizing total Levenshtein edit distance, and report that minimum sum. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MinersAssign each of N shipments in order to one of two mines; each shipment scores 1 to 3 based on how many distinct kinds appear among it and the previous two shipments at that mine, and the goal is to maximize the total. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Run, IOI TrainDiscard a prefix from each of two I/O strings, then interleave the remaining fronts to build the longest alternating string that starts and ends with I. | Medium7 | Dynamic programmingTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| String FarmGiven up to 10^4 strings, find the longest chain where each string is a contiguous substring of the next, all photos distinct. | Medium7 | StringDynamic programming+2 | No attempts yet | 5s | 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 |
| Insidious BrandingCount quadruples of dictionary words A, B, C, D with A+B = C+D and length(A) < length(C). | Medium7 | Hash mapString | No attempts yet | 2s | 128 MB | Judgeable |
| NecklaceGiven a string and a pattern, delete the fewest characters so the pattern no longer appears as a contiguous substring. | Medium7 | Dynamic programmingString matching+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 |
| VimGiven a string over a-j, find the minimum Vim keypresses (x, h, and f C) to delete every 'e' without touching other characters, starting with the cursor at index 0. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Formatting TextBreak a paragraph into lines of fixed width, choosing line breaks to minimize total badness with a lexicographic tie-break on gap widths. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| WordApply a cyclic cellular rewriting rule s times to a binary word of length n, then print the lexicographically smallest rotation. | Medium7 | StringSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DehuffGiven a sample string and its full binary encoding, reconstruct the unique prefix-code table for the alphabet, or report several possible tables. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Calculator LanguageEvaluate expressions in a tiny language with right-associative equal-precedence operators, assignment, and right-to-left operand evaluation, then report changed variables. | Medium7 | ImplementationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| String DecodingGiven a string, a permutation, and a large repetition count m, recover the string that the permutation maps to the given encoded string. | Medium7 | MathImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| New FruitFor each pair of strings, output the shortest common supersequence, breaking ties by choosing the lexicographically smallest one. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Corporate IdentityGiven up to 4000 short lowercase strings, find the longest string that occurs as a contiguous substring of every one, breaking ties by lexicographic order. | Medium7 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| IVXLCDMGiven a lowercase inscription line, find the largest value of a valid Roman numeral readable as a subsequence of its letters, or 0 if none. | Medium7 | GreedyString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RepetitivityCompute the sum of squared occurrence counts over all distinct subsequences of a string, modulo M. | Medium7 | StringDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Mhocskian LanguagesGiven a context-free grammar in Chomsky normal form and a list of words, decide for each word whether the start variable can derive it. | Medium7 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| DinnerGiven a line of G and H programmers, repeatedly remove a run of at least K equal letters; find the minimum number of removals to clear the line, or -1. | Medium7 | Dynamic programmingIntervals+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 |
| TripGiven two strings, print all longest common subsequences in lexicographic order without duplicates. | Medium7 | Dynamic programmingBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Lazy Math InstructorDecide whether two arithmetic expressions with left-to-right equal-precedence operators are identical as polynomials over single-letter variables. | Medium7 | Hash mapString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Shortest Regular Brackets SequenceGiven a string of brackets, find the length of the shortest regular bracket sequence that contains it as a subsequence. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Computer DialogueGiven file names split into name and extension parts, simulate the alternating 'I don't know' messages between two clients and list files still possible after M messages. | Medium7 | SimulationHash map+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 |
| ArtinalsInterpret a small language over hereditarily finite sets, evaluating assignments, expressions and relations, and print reduced canonical set representations. | Medium7 | StringImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Dictionary of Obscene WordsGiven dictionary words and a text, find the length of the shortest prefix of the text containing some word as a subsequence. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Hexaroman NumbersParse and output hexadecimal Roman numerals, choosing the shorter of additive or subtractive notation per digit, then evaluate +, -, and * expressions. | Medium7 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PalindromesFor each number in a small interval written in base b, apply reverse-and-add up to l times and count how many do not reach a palindrome. | Medium7 | SimulationMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| List CalculatorImplement an interpreter for a small list language with slicing, unary and binary elementwise operators, concatenation, and single-character variable assignment. | Medium7 | ImplementationRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Edit DistanceGiven strings A and B up to length 17000, find the minimum number of insert, delete, and substitute operations to turn A into B. | Medium7 | Dynamic programmingString | No attempts yet | 8s | 128 MB | Judgeable |
| Reverse NumbersGiven up to 10000-digit numbers M, decide whether some N satisfies M = N + Rev(N). | Medium7 | StringMath+1 | No attempts yet | 1s | 32 MB | Judgeable |
| Roman CorridorFind a left-to-right path through the grid whose symbol string is a valid Roman numeral and has the smallest decimal value. | Medium7 | DFSGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TemplateFind a template whose overlapping occurrences cover every position of S, minimizing the template length. | Medium7 | StringString matching+1 | No attempts yet | 3s | 128 MB | Judgeable |
| The Number of Symmetrical ChoicesGiven two word sequences of length n, count how many of the 2^n ways of picking one word per index produce a palindrome when concatenated. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GenotypesGiven budding rules A1 -> A2 A3, decide for each target word whether it can be derived from some number of supergenes S, and report the minimum count. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Word EqualizingAppend the given words to x and y any number of times to make them equal, and output the minimum total number of appends, or NIE if impossible. | Medium7 | StringGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Even Palindrome DecompositionDecide whether a string can be split entirely into even-length palindromes, and if so report the minimum and maximum number of parts. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PalindromesGiven n distinct palindromes, count ordered pairs whose concatenation is also a palindrome, with total length up to 2,000,000. | Medium7 | StringHash map+2 | No attempts yet | 5s | 256 MB | Judgeable |
| BBBFind the minimum cost to fix a + and - statement so the balance starts at p, never goes negative, and ends at q, using character flips and rotations. | Medium7 | GreedyPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TrainsAfter each of m car swaps, track the largest number of trains that ever shared each train's exact colour string. | Medium7 | Hash mapString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Squared WordsGiven a lowercase string, delete the fewest letters so the remaining letters, in order, form a squared word xx. | Medium7 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| Type Two de Bruijn SequencesGiven a binary string, append the fewest digits so that every length-n binary word appears as a subsequence. | Medium7 | GreedyString+1 | No attempts yet | 2s | 512 MB | Judgeable |
| WordsGiven a word of length n, find the smallest number of blocks in a word that differs from it in at most k positions. | Medium7 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| Room NumbersCount the distinct numbers formed by flipping each 6 or 9 in n independently that are at most h, modulo 9999997. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Banner RepairTransform one uppercase banner string into another with block insertions and deletions where each block of length S costs X plus S times Y. | Medium7 | Dynamic programmingString | No attempts yet | 10s | 128 MB | Judgeable |
| Popping GroupsDecide whether a string of a and b can be fully erased by repeatedly deleting maximal runs of at least two equal letters. | Medium7 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| CipherGiven total character volume, word count, and rank, reconstruct the I-th message in lexicographic order or report corruption. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Heavy Chain ClusterizationSplit n antibody chains into the fewest groups so each group shares the same first k or last k letters. | Medium7 | GraphString | No attempts yet | 2s | 256 MB | Judgeable |
| Nested PalindromeFill each question mark with a digit to build the k-th smallest nested palindrome with no equal adjacent digits, or print -1. | Medium7 | RecursionCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Decoding the HallwayFor each query, decide whether the given string appears as a contiguous substring of the turn record built after n hallway walks. | Medium7 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Infix to PrefixGiven a prefix expression with spaces and parentheses removed, compute the smallest and largest values over all valid parses. | Medium7 | Dynamic programmingIntervals+1 | No attempts yet | 5s | 128 MB | Judgeable |
| WeatherReconstruct the first and last days of a weather string from its multiset of length-d substrings, choosing the alphabetically smallest pair when several fit. | Medium7 | GraphString | No attempts yet | 2s | 512 MB | Judgeable |
| XenospeakGiven words per page and a page number, print the first and last words on that page over tilings of a, ab and bb ordered by length then alphabetically. | Medium7 | CombinatoricsDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Secret MessageCount the operation sequences that build the given string by repeatedly prepending or appending a proper prefix or suffix. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PalindromeFind the palindromic substring that maximizes its length times its number of occurrences in the given string. | Medium7 | String matchingString | No attempts yet | 2s | 128 MB | Judgeable |
| A Cure for the Common CodeCompute the shortest encoded length of each lowercase string using count-plus-parentheses notation for repeats. | Medium7 | Dynamic programmingString | No attempts yet | 5s | 256 MB | Judgeable |
| Black and White StonesShagga reorders black and white stones so all black stones stand left of white ones with minimum cost, paying A per swap and A minus B for adjacent swaps. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Repeated Substring CountCount the distinct substrings that occur at least twice in each string of up to 100000 letters. | Medium7 | String matchingString | No attempts yet | 5s | 256 MB | Judgeable |
| VocabularyCount ways to replace every question mark with a lowercase letter so the three words are distinct and in lexicographic order. | Medium7 | Dynamic programmingString+1 | No attempts yet | 5s | 256 MB | Judgeable |
| LRFill each ? with an allowed character to form a valid L and R expression with the largest possible value, or report invalid. | Medium7 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Palindromic PathsCount distinct palindromic strings spelled by right-down paths from the top-left to the bottom-right of an N by N letter grid. | Medium7 | DFSHash map+1 | No attempts yet | 1s | 256 MB | Judgeable |
| 369 Game CountCount numbers from A to B that are multiples of 3 or contain the digit 3, 6, or 9, and output the count modulo 20150523. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Counting Soundex StringsCount case-insensitive strings up to length L whose Soundex code equals the given code, modulo 1000000007. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 256 MB | Judgeable |
| String StretchingGiven a lowercase string up to length 200, find the shortest base string that builds it by repeated insertions anywhere, breaking ties alphabetically. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Word LadderPick one new word to add to the dictionary so the single-letter ladder from the first word to the second is as short as possible. | Medium7 | BFSGraph+2 | No attempts yet | 3s | 256 MB | Judgeable |
| The Fox and the OwlGiven a huge integer N, print the largest integer below N whose digit sum is exactly one more than that of N. | Medium7 | GreedyString+1 | No attempts yet | 1s | 256 MB | Judgeable |
| PLAY in BASICGiven a Music Macro Language score, find the character length of the shortest score with identical pitches, note lengths, volumes, and rests. | Medium7 | Dynamic programmingSimulation+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Alpaca SentenceFind the K-th string in lexicographic order among the shortest palindromes that contain S as a subsequence, or report NONE. | Medium7 | Dynamic programmingString+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Albocede DNA (Small)Count subsequences of S that split into blocks of the form a^i b^j c^i d^j with i and j at least 1, modulo 1e9+7. | Medium7 | Dynamic programmingString+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Reordering Train Cars (Small)Count the orders of the given letter strings whose concatenation keeps every equal letter in one contiguous block. | Medium7 | GraphCombinatorics+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Reordering Train Cars (Large)Count the orders of the given strings that keep all equal letters contiguous without reversing any string, modulo 1,000,000,007. | Medium7 | GraphCombinatorics+1 | No attempts yet | 5s | 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 |
| Distinct valid bracket subsequencesCount distinct non-empty balanced bracket strings that appear as subsequences of a given bracket string of length at most 100, modulo 1,000,000,007. | Medium7 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Next Special StringGiven a binary special string (each split satisfies U < V), find the next special string of the same length in lexicographic order, or -1 if none exists. | Medium7 | StringGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Palindrome WalkGiven an undirected labeled graph, find the length of the shortest walk from vertex 0 to vertex 1 whose edge-label string is a palindrome, or -1 if none exists. | Medium7 | BFSGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Splitting a StringChoose K non-overlapping substrings of A that also appear in B in the same non-overlapping order, maximizing their total length. | Medium7 | Dynamic programmingString+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Suffix Array 1Given S, decide whether some lexicographically smaller string of the same length has an identical suffix array. Constraints: |S| <= 50. | Medium7 | StringSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| K-InversionsFor every distance k, count pairs (i,j) with i<j, s[i]='B', s[j]='A', and j-i=k, over a string of up to a million characters. | Medium7 | Divide and conquerString+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Bracket MatchGiven a lowercase string S, find the lexicographically smallest matching bracket sequence, or print -1 if none exists. | Medium7 | StackGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Reading the stone slabAfter each range replacement on a string, count the number of subsequences equal to a given name of length at most 5, modulo 1e9+7. | Medium7 | Dynamic programmingSegment tree+1 | No attempts yet | 4s | 256 MB | Judgeable |
| Suffix array 2Sort all suffixes of a string lexicographically and output the starting index of each suffix in sorted order. | Medium7 | StringSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Longest palindromic substringFind the length of the longest contiguous substring of S that reads the same forwards and backwards. | Medium7 | StringBinary search+1 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Pry Sequence TransformationFind the minimum edit distance between strings A and B under weighted insert, delete, and replace costs, or print TOSS if it exceeds budget K. | Medium7 | Dynamic programmingString | No attempts yet | 2s | 512 MB | Judgeable |
| Chameleon SubstringGiven a string S, find the longest substring that is both a prefix and a suffix of S and also appears somewhere strictly inside S. | Medium7 | String matchingString+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Bracket substring queriesFor each query substring, find the length of the longest balanced bracket subsequence within it. | Medium7 | Prefix sumString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| K-th SubstringSort every substring of S lexicographically and print the K-th one, or -1 if there are fewer than K substrings. | Medium7 | StringSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Prefix and SuffixFor each prefix of S that is also a suffix, output its length and how many times it occurs as a substring. | Medium7 | String matchingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Palindromic SubsequenceGiven a string and marked positions, find a palindromic subsequence covering the most marked positions, and report the length of the longest such one. | Medium7 | Dynamic programmingString | No attempts yet | 1s | 512 MB | Judgeable |
| Same wordGiven two sets of binary words, decide whether some nonempty concatenation of words from the first set equals some nonempty concatenation from the second. | Medium7 | StringBFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Strings and QueriesFor a string S, F(i) is the length of the longest common suffix of S and the prefix of S ending at position i; answer M queries for F(i). | Medium7 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Buggy RobotGiven a grid and an existing command string, insert or delete single commands at minimum cost so the robot reaches the exit. | Medium7 | Dynamic programmingBFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Full Text SearchFor each query, find the shortest letter string whose set of length-1 and length-2 substrings contains the query's set but which does not contain the query itself. | Medium7 | StringGraph+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Alice in FoxlandGiven two strings X and Y, find the longest common subsequence of X and Y that contains a required substring C as a contiguous block, or report impossible; among ties pick the lexicographically smallest. | Medium7 | Dynamic programmingString+2 | No attempts yet | 8s | 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 |
| Reading DigitsDecode the given run-length-encoded string k times, then report the digit at index pos of the original string s. | Medium7 | StringImplementation+1 | No attempts yet | 0.1s | 256 MB | Judgeable |
| StickersParse a comma-separated list of sticker numbers and ranges with leading zeros, deduplicate, then output the shortest valid representation with fewest commas. | Medium7 | StringImplementation+2 | No attempts yet | 0.5s | 256 MB | Judgeable |