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
TitleLevelTopicsSolvedTime limitMemory limitJudge
Codejamon Cipher (Large)Count how many sentences built from vocabulary words, each word internally shuffled, concatenate to each given enciphered string.Medium7Dynamic programmingString+1No attempts yet5s512 MBJudgeable
Interleaved Output: Part 1Given a string over I, O, i, o, find the maximum number of times the event IO could have been printed.Medium7GreedyStack+1No attempts yet20s1024 MBJudgeable
Interleaved Output: Part 2Given a string that four computers can interleave into, find the largest number of times the IO computer could have printed its name.Medium7Dynamic programmingGreedy+1No attempts yet20s1024 MBJudgeable
Close Match (Large)Fill question marks in two equal-length digit strings to make the scores as close as possible, breaking ties by the smallest C then smallest J.Medium7Dynamic programmingGreedy+2No attempts yet5s512 MBJudgeable
Longest Palindromic SubstringGiven a lowercase string of up to 100,000 characters, report the length of its longest palindromic substring.Medium7StringString matching+2No attempts yet2s512 MBJudgeable
Counting Palindromes (Small)Count how many subsequences of a string of length up to 30 are palindromes, treating subsequences that use different positions as distinct.Medium7Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Unbalanced ParenthesesFlip some parentheses, each at a given cost (possibly negative), so that no sequence of at most k more flips can balance the string; minimize total cost.Medium7GreedyString+2No attempts yet2s512 MBJudgeable
Counting Palindromic Subsequences (Large)Count subsequences of a string (positions distinguish repeats) that read as palindromes, modulo 10007.Medium7Dynamic programmingStringNo attempts yet2s512 MBJudgeable
Stack ConstructionFor each message, compute the minimum number of stack push, pop, and print operations needed to print it and leave the stack empty.Medium7Dynamic programmingString+1No attempts yet2s512 MBJudgeable
Buggy ICPCCount the strings W of the same length as T that produce T on a machine that reverses the line every time a vowel is typed.Medium7CombinatoricsString+1No attempts yet1s1024 MBJudgeable
Palindromic PartitionsSplit a string into chunks so the chunk sequence is a palindrome, and report the maximum number of chunks possible.Medium7StringGreedy+2No attempts yet10s128 MBJudgeable
InitialsEach student's directory starts as last-initial plus first-initial; append letters from the full names so names strictly increase in class order, minimizing total letters added.Medium7Dynamic programmingString+2No attempts yet3s512 MBJudgeable
Column AdditionGiven three n-digit strings, erase the fewest digit columns so the first number plus the second equals the third.Medium7Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Vera and LCSGiven string A and target K, find the smallest i where A's prefix of length i plus N-i copies of A's least frequent letter has LCS exactly K with A.Medium7StringDynamic programming+1No attempts yet2s256 MBJudgeable
Minimum Edit 2Compute the minimum number of insertions, deletions, replacements, and adjacent swaps needed to turn string A into string B, with both strings up to length 1000.Medium7Dynamic programmingString+2No attempts yet2s512 MBJudgeable
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.Medium7Dynamic programmingTrie+2No attempts yet2s512 MBJudgeable
ParenthesesGiven A, output the shortest parentheses string whose minimum number of adjacent swaps to become balanced is exactly A, breaking ties lexicographically.Medium7GreedyMath+2No attempts yet2s512 MBJudgeable
Compressed FormulaEvaluate an arithmetic formula with +, -, * over non-negative integers, given as N runs where each short string repeats r_i times, and print the result modulo 1,000,000,007.Medium7MathString+2No attempts yet2s512 MBJudgeable
Equals are EqualsParse multivariate polynomial expressions with integer coefficients and decide whether each student answer is equivalent to the reference expression.Medium7StringImplementation+2No attempts yet2s512 MBJudgeable
Winter Olympic GamesReplace one contiguous block of a binary string (possibly empty) by a single 1, empty block inserts without deleting, to make the resulting string lexicographically largest.Medium7GreedyString+2No attempts yet5s1024 MBJudgeable
Repeated PatternAppend at most K letters to S so it becomes repetitions of one word, and output the longest possible word length (at most N), or 0.Medium7String matchingString+2No attempts yet1s1024 MBJudgeable
Jumbled StringGiven counts of subsequences 00, 01, 10, and 11, output a bit string producing exactly those counts.Medium7CombinatoricsGreedy+2No attempts yet1s512 MBJudgeable
Future GenerationChoose a nonempty subsequence of each given name so the chosen strings are strictly increasing lexicographically and their total length is maximized.Medium7Binary searchBit manipulation+2No attempts yet1s512 MBJudgeable
KMPEach of N scientists has letters from the first characters of their name words. For each query, decide whether its letters can be matched one each to distinct scientists, with order ignored.Medium7Bit manipulationDFS+2No attempts yet2s512 MBJudgeable
Selling RNA StrandsGiven N RNA strings, answer M queries that count strings matching a prefix P and suffix Q.Medium7String matchingHash map+2No attempts yet1.5s1536 MBJudgeable
Comfortable StringCount how many substrings of a bracket string are both correctly balanced and symmetric under reversal with bracket swap.Medium7Dynamic programmingString+2No attempts yet1s512 MBJudgeable
Longest Common SubstringGiven up to 10 lowercase strings, each up to 100,000 characters, find the length of the longest substring shared by all of them.Medium7StringBinary search+2No attempts yet2s512 MBJudgeable
Contiguous Repeated StringGiven string S and k, choose k appended characters so that the resulting string has the longest substring of the form TT (a block repeated twice back to back), and report that length.Medium7StringBrute force+2No attempts yet2s512 MBJudgeable
Subsequences in SubstringsCount how many substrings of s contain t as a subsequence at least once.Medium7Two pointersDynamic programming+2No attempts yet2s512 MBJudgeable
IspitDecide whether some block of K consecutive columns can have its letters shuffled within each row so that two rows become equal.Medium7Sliding windowHash map+2No attempts yet2s512 MBJudgeable
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.Medium7StringTrie+2No attempts yet10s512 MBJudgeable
Alphabet StringCount distinct strings formed by sorting the distinct characters of every substring of an uppercase string and removing duplicates.Medium7StringHash map+2No attempts yet1s256 MBJudgeable
Choosing a BiasGiven N friends and M members, each friend lists acceptable members; decide if a distinct member can be assigned to each of the N friends.Medium7GraphString+2No attempts yet2s256 MBJudgeable
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.Medium7Dynamic programmingString+2No attempts yet6s1024 MBJudgeable
MathemagiciansGiven two red/blue colorings of a circle of n people, decide whether repeated moves, where one person copies a neighbor's color, can turn the first coloring into the second.Medium7StringGreedy+2No attempts yet1s512 MBJudgeable
Eggfruit CakeCount the circular contiguous slices of a fruit border that contain at least one eggfruit ('E') and at most S fruits, where slices are distinguished by which fruits they include.Medium7Two pointersSliding window+2No attempts yet0.1s512 MBJudgeable
Parentheses EditorAfter each push of '(' or ')' or one backspace, print the number of balanced substrings in the current text.Medium7StackDynamic programming+2No attempts yet2s512 MBJudgeable
Letter WheelsThree cyclic strings over {A,B,C}; rotate each independently to make every column have three distinct letters, minimizing total rotation steps.Medium7StringBrute force+2No attempts yet3s512 MBJudgeable
Beautiful NowGiven an integer n and a swap budget k, find the smallest and largest numbers reachable by swapping digit positions, where no intermediate or final number may have a leading zero.Medium7GreedyBrute force+2No attempts yet2s512 MBJudgeable
Equal DigitsCount the ways to delete disjoint substrings of length over 1 whose first and last digits match, so the remaining non-empty string has all distinct digits.Medium7Dynamic programmingCombinatorics+2No attempts yet3s256 MBJudgeable
Shortest Accepted WordParse a regular expression over a, b, c and $ into a tree, then compute the shortest lexicographically smallest string each node accepts.Medium7Dynamic programmingString+2No attempts yet1s256 MBJudgeable
Geese vs. HawksMatch games of two teams so that every paired game's win/loss outcome agrees, maximizing the total points scored by both teams in the matched games.Medium7Dynamic programmingString+2No attempts yet1s512 MBJudgeable
Error ReportGiven a sequence of function numbers from concatenated stack traces, build a call graph of minimum edge count where all traces come from errors in at most two functions.Medium7GraphGreedy+2No attempts yet2s512 MBJudgeable
Palindrome SentencesGiven up to 13 distinct words, count ordered arrangements of a subset of them whose concatenation without spaces forms a palindrome.Hard8Dynamic programmingBit manipulation+2No attempts yet2s128 MBJudgeable
Zero Run PatternGiven two binary strings repeated in a growing pattern, find the first position within the first 10^16 characters where C consecutive zeros occur.Hard8StringBinary search+2No attempts yet2s128 MBJudgeable
Non-Repeating WordFind the lexicographically smallest length-N string over the first A letters that never contains K consecutive copies of any nonempty block.Hard8BacktrackingString+2No attempts yet2s128 MBJudgeable
Increasing ListReplace every '?' in a string with a digit or comma to form the lexicographically smallest strictly increasing list of positive integers with no leading zeros, or print -1 if impossible.Hard8BacktrackingGreedy+2No attempts yet2s128 MBJudgeable
Count Palindromic Word SequencesCount ordered sequences of given words, space-joined, whose concatenation (ignoring spaces) is a palindrome of length at most K, modulo a prime.Hard8Dynamic programmingString matching+2No attempts yet2s128 MBJudgeable
Magic StoneGiven n, k, and i, find the i-th lexicographically smallest length-n I/X string with at most k differing adjacent pairs, treating a string and its reverse as identical.Hard8CombinatoricsDynamic programming+2No attempts yet2s128 MBJudgeable
Increasing SequenceSplit a digit string into pieces forming a strictly increasing sequence of numbers, minimizing the last value with tie-breaks favoring larger earlier numbers.Hard8Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Merge WordsGiven up to 12 uppercase words, find the shortest string containing all of them as substrings, breaking ties by lexicographic order.Hard8Dynamic programmingBit manipulation+2No attempts yet5s128 MBJudgeable
Increasing SequenceSplit a huge digit string into pieces forming a strictly increasing sequence of numbers, breaking ties by minimizing the last piece then maximizing earlier pieces, and output the product mod 1,000,000,003.Hard8Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Nested Reversal SequenceGiven two binary strings, find the minimum number of substring reversals, each interval nested inside the previous one, needed to turn the first string into the second, or report impossibility.Hard8StringGreedy+2No attempts yet2s128 MBJudgeable
DuelTwo players alternately mark empty cells on a strip, winning instantly by forming three consecutive marks, and the task is to decide if the first player can force a win and list all winning first moves.Hard8Game theoryCombinatorics+2No attempts yet2s128 MBJudgeable
Palindrome EncodingGiven a binary string, repeatedly delete the second half of any even-length palindromic substring and find the minimum length achievable.Hard8Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Partial DNA SubstringsGiven a DNA string, count distinct substrings occurring at least m times and find the K-th one under length-then-lex order.Hard8String matchingBinary search+1No attempts yet2s16 MBJudgeable
Number of TreesCount the number of rooted ordered trees whose DFS-with-repeated-parent-writes traversal string equals a given string, modulo 1e9.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Compressing a StringFind the minimum length of a string obtained by optimally applying nested k(S) run-length style compression to a given lowercase string of length up to 200.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Tennis MatchSimulate a multi-player variant of tennis with custom scoring, serving rotation, and set/match rules to determine the overall winner from a sequence of game winners.Hard8SimulationImplementation+1No attempts yet2s128 MBJudgeable
Number of Expression ValuesCount the distinct values an unspaced digit/operator string can yield when each subexpression is parsed as prefix, infix, or postfix.Hard8Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Binary Sequence RotationGiven the last column of a sorted matrix of all circular rotations of an unknown binary string, reconstruct the lexicographically smallest rotation (first row) or report impossibility.Hard8String matchingSorting+2No attempts yet2s128 MBJudgeable
Finding a Momentum SequenceGiven a digit string, decide if it can be split into an arithmetic progression followed by a term equal to the last progression term times some integer f, and output the minimal possible f.Hard8StringMath+2No attempts yet1s1024 MBJudgeable
Message ConverterParse a MULTI markup string with tags for newline, justification, and spacing, then render it into a fixed-size character grid while detecting conflict, size, and syntax errors.Hard8StringSimulation+1No attempts yet1s128 MBJudgeable
Beautiful WordSimulate a turn-based letter-picking game where one player greedily takes the rightmost slip while the other picks optimally to form the lexicographically smallest possible word, then compare outcomes.Hard8GreedyGame theory+1No attempts yet1s128 MBJudgeable
Roman Numeral WalkFind the longest path from the grid center through empty-separated cells that spells consecutive Roman numerals starting at 1, and print the last number reached.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
Martian DNA FormulaCompress a DNA string into the shortest possible run-length style notation using nested parentheses with repeat counts.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
RLE CompressionDecode a custom run-length encoding scheme and compute the minimum possible length of any code that decodes to the same character sequence.Hard8Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Vigenère Cipher AnalysisDetermine, for each candidate Vigenère key length up to K, whether the unique decrypted plaintext contains two given cribs at non-overlapping positions, and report the plaintext, ambiguous, or impossible.Hard8String matchingString+2No attempts yet1s128 MBJudgeable
InsultsParse a string against a context-free grammar defining insults, then find the lexicographically next same-length valid insult or report invalid/ultimate.Hard8StringDynamic programming+2No attempts yet1s128 MBJudgeable
Repetition-Free FormulaParse a Boolean formula that may repeat variables, determine if the underlying function is read-once, and if so print its canonical repetition-free formula.Hard8RecursionString+2No attempts yet2s64 MBJudgeable
Secret Code: Largest NumberGiven a noisy string, find the largest decimal number it could decode to, either fixing one language for all digits or allowing a different language per digit, using digit-word subsequence matching.Hard8Dynamic programmingString matching+2No attempts yet3s128 MBJudgeable
Software Industry RevolutionGiven a wildcard pattern (with ? and *) and a text, find the minimum-complexity substring of the text that matches the whole pattern, or report impossible.Hard8String matchingDynamic programming+1No attempts yet1s128 MBJudgeable
ACGUGiven an RLE-encoded RNA-like string, find the maximum number of non-crossing A-U and C-G pairs with at most K C-G pairs, exploiting the special RLE size constraints.Hard8Dynamic programmingString+1No attempts yet2s128 MBJudgeable
GeneticsSimulate a topological genus-computing reduction system on circular DNA strings of paired letters to determine the resulting count of arms or legs.Hard8SimulationString+2No attempts yet1s128 MBJudgeable
Stammering AliensGiven a string and a minimum repeat count m, find the longest substring occurring at least m times (overlaps allowed), breaking ties by rightmost starting position, using suffix array or suffix automaton techniques.Hard8String matchingBinary search+1No attempts yet1s128 MBJudgeable
Matrix CalculatorParse and evaluate a matrix expression language with block matrices, transpose, indexing, and modular arithmetic, printing each assignment's resulting matrix.Hard8RecursionMatrix+2No attempts yet1s128 MBJudgeable
Organize Your TrainGiven a small rail-yard graph with parking lines and exchange links, compute the minimum number of sub-train moves to transform an initial arrangement of typed cars into a target arrangement.Hard8BFSSimulation+2No attempts yet3s128 MBJudgeable
Magical CraftingGiven binary crafting recipes with diamond costs, decide for each target string of glow stones whether it can be produced from 'A' and find the minimum diamond cost.Hard8Dynamic programmingGreedy+2No attempts yet5s128 MBJudgeable
Disjoint Regular ExpressionsGiven two regular expressions, decide whether any non-empty string matches both, and if so print the shortest lexicographically smallest such string.Hard8Dynamic programmingBFS+2No attempts yet2s128 MBJudgeable
Fibonacci WordGiven a bit pattern p and an index n up to 100, count the possibly overlapping occurrences of p inside the Fibonacci word F(n), whose length grows exponentially.Hard8String matchingDynamic programming+2No attempts yet1s128 MBJudgeable
Intellectual PropertyGiven two code bases as raw strings, find the k longest maximal substrings of the JCN base that also occur in the TDP base, with exact positions and lengths.Hard8String matchingSorting+2No attempts yet1s128 MBJudgeable
Language CardinalityCount the distinct strings a string-rewriting grammar generates from a start string, printing Too many. if the count exceeds 1000.Hard8StringBFS+2No attempts yet1s128 MBJudgeable
Tail PalindromeGiven two lowercase strings a and b, find the shortest string x such that exactly one of ax, bx is a palindrome, and among ties the lexicographically smallest x.Hard8StringString matching+2No attempts yet1s128 MBJudgeable
Crypt KickerDecrypt each line of a substitution cipher so every word appears in a given dictionary, choosing the lexicographically smallest result, or mask the line if none exists.Hard8BacktrackingString+2No attempts yet1s128 MBJudgeable
Barcode of JudgmentA barcode is a fixed 7x9 grid pattern placed somewhere in a binary image, possibly rotated; find all valid placements and decode the data bits, or report none or ambiguity.Hard8StringImplementation+2No attempts yet1s128 MBJudgeable
Word LadderGiven a vocabulary, find the longest shortest path (number of words) between any two words where a move changes, adds, or removes one letter.Hard8GraphBFS+2No attempts yet1s128 MBJudgeable
WhenExecute a complete When program, an event-driven language with simultaneous Set assignments and a rotating active-clause scheduler, and print its output.Hard8SimulationImplementation+2No attempts yet1s128 MBJudgeable
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.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
Alpha of Degree kGiven a dictionary, answer queries asking for the shortest chain from word s to word t where each step shares a suffix-prefix overlap of length at least k, with a cap on chain length.Hard8GraphBFS+2No attempts yet1s128 MBJudgeable
Weaker than PlannedGiven candidate plaintext words and a ciphertext message, recover the plaintext under one unknown letter-pair substitution, or report that it is not unique.Hard8BacktrackingString+2No attempts yet1s128 MBJudgeable
City MergerGiven up to 14 uppercase city names, find the length of the shortest string that contains every name as a consecutive substring, allowing overlaps.Hard8Dynamic programmingBit manipulation+2No attempts yet2s128 MBJudgeable
InfiltrationGiven an encrypted line using a one-to-one letter substitution, recover the plaintext if exactly one consistent mapping exists using a subset of twelve known words that covers all distinct cipher letters.Hard8StringHash map+2No attempts yet1s128 MBJudgeable
DNA CopyGiven a source string S of length at most 18, find the minimum number of copy operations (each taking a contiguous substring of S or of the already-built target, optionally reversed) needed to assemble T.Hard8Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
CipherFind the a x b subarray that occurs exactly k times (k >= 3) in an n x m character grid and list all its top-left positions in row-major order.Hard8Hash mapString+2No attempts yet1s128 MBJudgeable
Spelling SuggestionGiven weighted edit costs including keyboard-aware substitution and transposition, find the dictionary words closest to each query word.Hard8Dynamic programmingString+2No attempts yet12s128 MBJudgeable
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.Hard8TrieString+2No attempts yet1s128 MBJudgeable
File SearchCount how many non-empty subsets of the files can be exactly the result set of some substring query.Hard8StringTrie+2No attempts yet5s128 MBJudgeable
Code LockGiven a target lowercase string starting from all 'a', find the minimum number of moves where each move shifts a contiguous block of wheels up or down by one.Hard8Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
File RecoverCount the distinct contiguous substrings that occur at least twice in a given string, for several test cases up to 100000 characters each.Hard8StringString matching+1No attempts yet5s128 MBJudgeable
DNA SubsequenceFind the longest common subsequence of two words where every maximal matched run must be a contiguous block of at least K characters in both words.Hard8Dynamic programmingString+1No attempts yet1s128 MBJudgeable