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 |
|---|---|---|---|---|---|---|
| Red RoverGiven a route string over N, S, E, W of length at most 100, find the minimum total length of a message using one optional macro M and its definition that expands to the route. | Medium6 | Dynamic programmingString | No attempts yet | 2s | 512 MB | Judgeable |
| Orderly ClassGiven two equal-length strings A and B, count the intervals in A such that reversing that interval turns A into B. | Medium6 | StringTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Jumbled passwordGiven a string, find the smallest index past the midpoint where the suffix differs from the prefix of equal length in exactly one character. | Medium6 | StringString matching+2 | No attempts yet | 0.5s | 1024 MB | Judgeable |
| Hay BalesGiven a string of C and P, each move sorts any three consecutive characters so all C come before all P; find the minimum number of moves to fully sort the whole row. | Medium6 | GreedyString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Minimum editCompute the Levenshtein distance between two lowercase strings, using the fewest insert, delete, and replace operations to change A into B. | Medium6 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| An Unfair PuzzleGiven two permutations of 1..n, decide whether cyclic rotations and reversals can turn the first into the second, printing good puzzle or bad puzzle. | Medium6 | StringString matching+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Thinking StationFor each K from 1 to N, split the first N cars into blocks of K (dropping the remainder) and count distinct blocks up to reversal; report the K values with the maximum count. | Medium6 | StringHash map+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Comma SprinklerGiven a text, repeatedly add commas before or after every occurrence of a word that already has a comma on that side, until nothing changes; print the result. | Medium6 | GraphBFS+2 | No attempts yet | 8s | 1024 MB | Judgeable |
| AnagramsGiven two equal-length uppercase strings A and B, find the minimum total number of cyclic letter increments applied to positions of A so the result is an anagram of B. | Medium6 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| GeneticsGiven N DNA strings of length M, find the one string that differs from every other string in exactly K positions. | Medium6 | StringBrute force+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Pseudo-Banana StringsGiven a string of B, A, N, find the minimum number of character replacements that turn it into a concatenation of blocks of the form B+ANANA(NA)*. | Medium6 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hyunwook Is the Parenthesis King!!Given a string of parentheses, find the length of the longest contiguous substring that forms a correct parenthesis string. | Medium6 | StackString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| BracketGiven a bracket pattern with some fixed brackets and some dots, count the ways to fill the dots so the whole string is a balanced bracket sequence. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Chinese ID NumberCheck an 18-character Chinese ID: region code from a given list, birthday in 1900 to 2011, sequence code not 000, then for valid IDs report gender by odd/even sequence code. The checksum is a mod 11 weighted sum of the first 17 digits plus a digit x making the total 1, with x=10 written as 'X'. | Medium6 | StringArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Jurassic JigsawGiven n DNA strings of length k, build a spanning tree minimizing the total Hamming distance over its edges, and print the cost plus the edges. | Medium6 | Minimum spanning treeGraph+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Game NightGiven a circular arrangement of A, B, and C seats, find the minimum people to move so each team forms one contiguous block. | Medium6 | StringSliding window+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Circle Cross StampsGiven a row of O and X marks printed by single circles, single crosses, and two-mark circle-cross stamps in either orientation, find the largest possible count of circle-cross stamps. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| ParametriziranCount pairs of equal-length words over lowercase letters and question marks that can be made identical by filling the question marks. | Medium6 | Bit manipulationHash map+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Rainbow BeadsFind the longest contiguous substring of a string over R, B, V that has no equal adjacent pair under any of the three color-blind views. | Medium6 | Two pointersSliding window+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Comparing StringsGiven two lowercase strings, align them by repeating characters of either string, keeping order, and minimize the sum of absolute alphabet-position differences over aligned pairs. | Medium6 | Dynamic programmingString+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Bracket String and QueriesFlip one character per query and count how many prefixes of the query sequence leave the string as a correct bracket sequence. | Medium6 | StringPrefix sum+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Christmalo.winGiven N short strings, pick two and a shared letter to splice their prefix and suffix, minimizing the total deleted characters. | Medium6 | StringHash map+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Balanced StringCount binary strings of length n where every prefix has at most one more 0 than 1 or one more 1 than 0, modulo 16769023. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Gathering BallsGiven a row of red and blue balls, find the minimum number of jumps (moving only one color) to group each color together. | Medium6 | GreedyString+2 | No attempts yet | 1s | 512 MB | Judgeable |
| JOIOJIGiven a string of J, O, and I, find the longest contiguous substring with equal counts of all three letters. | Medium6 | Prefix sumHash map+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Typo SquattingFor each domain name, count how many other given domains differ from it in exactly one character position. | Medium6 | Hash mapString+2 | No attempts yet | 4s | 512 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 |
| Sculptural ProjectGiven a string of work and market days, cancel the fewest days so materials never run out and end at zero. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hard Sculptural ProjectGiven a string of 'w' (work, consume 1) and 'o' (rest, gain 1), delete the fewest characters so every prefix has more gains than work and the total balances, then count the ways. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Assessing GenomesCompute each DNA string's smallest repeating unit length, then pair the two sets of scores to minimize the sum of squared differences. | Medium6 | StringSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Is There a Divisor?Given a digit string, find a base B and a divisor X (both at most 10^9) making the string's value composite in base B, or report that none exists. | Medium6 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| LJUSTRead lines up to ENDOFINPUT, wrap each to a width C, and justify any line whose length is at least floor(C/2) by spreading spaces left to right. | Medium6 | StringImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ASLRDRReorder a string with adjacent swaps so it becomes a palindrome, reporting the minimum number of swaps or Impossible. | Medium6 | GreedyTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| DISHFor each pair of strings, output a shortest string that contains both input strings as substrings. | Medium6 | StringDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| JJOOII 2Given a string of J, O, I and a level K, delete characters from the ends or middle to obtain K J's then K O's then K I's, minimizing middle deletions. | Medium6 | GreedyTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CatCount how many distinct strings you can form by joining a non-empty suffix of a with a non-empty prefix of b. | Medium6 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Balls of BumaGiven a row of colored balls, count the color and insertion position pairs that make the chain reaction remove every ball. | Medium6 | StringImplementation+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Two PrefixesGiven strings s and t, count distinct strings formed by concatenating a non-empty prefix of s with a non-empty prefix of t. | Medium6 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Page NumberGiven a digit string, count the ways to split it into two positive integers i and n with no leading zeros, representing "Page i of n". | Medium6 | StringImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| DNA Deletions and Protein CountCount, modulo 1e9+7, the distinct proteins obtainable by deleting some nucleotides from a DNA string and translating the remaining codons via a given table. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Palindrome FactoryCompute the minimum number of insertions, deletions, replacements, and at most one swap needed to turn a given string into a palindrome. | Medium7 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Largest Room Number 2Given per-digit purchase costs and a budget, find the largest number (no leading zero) affordable, then output its length and its first and last 50 digits. | Medium7 | GreedyMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Restore an Addition EquationFill the ? digits in an addition equation A+B=C with digits (no leading zeros) so the sum holds, maximizing C then A. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Palindrome Word SequencesCount ordered sequences of given words, reused any number of times, whose concatenation has exact length L and forms a palindrome. | Medium7 | Dynamic programmingString matching+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Palindrome SmartCount palindromic strings of length 1 to N built from lowercase letters that use at most K distinct letters, modulo 1234567891. | Medium7 | CombinatoricsMath+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Group Word ReconstructionReconstruct the unique group word, where every letter forms one contiguous block, by arranging all given unordered pieces, or report impossibility or multiple solutions. | Medium7 | GraphString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Ideal StringBuild the lexicographically smallest length-N string where each character's total occurrence count equals the position of its first appearance, or output -1 if none exists. | Medium7 | GreedyDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Number of Strings Matching Exactly K PatternsCount lowercase strings that match exactly K out of N given letter/question-mark patterns of equal length, modulo 1,000,003. | Medium7 | CombinatoricsBit manipulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Syum CrosswordCount distinct grid arrangements of four given words split into two horizontal and two vertical words that cross each other exactly once under strict adjacency and gap rules. | Medium7 | CombinatoricsBrute force+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Oh SejunConstruct the lexicographically smallest length-N repeating sequence of U/R moves that makes a robot land exactly on a target cell, or report impossibility. | Medium7 | GreedyMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| MusicInsert non-consecutive rest symbols into three note sequences to equalize their lengths while maximizing a column-matching score, or report impossibility. | Medium7 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Top Shelf of the BookshelfPick up to 10 book titles, sorted lexicographically, so that no two neighboring titles share the same letter at any aligned alphabetic position, maximizing total preference score. | Medium7 | Dynamic programmingString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| String Period PredictionUsing KMP-style prefix functions, find for every prefix the largest period-like split point and sum these values across the whole string. | Medium7 | String matchingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Increasing SequenceGiven a digit string up to 80 characters, split it into a strictly increasing sequence of integers (leading zeros allowed) minimizing the last number's value. | Medium7 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Counting Base RepresentationsCount the ways to split a digit string into a base suffix and a sequence of no-leading-zero digit values all less than that base. | Medium7 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Compare Tree Traversal PathsGiven two 0/1 Euler-tour strings from DFS traversals of a tree rooted at the same vertex, decide whether both could come from the same underlying tree. | Medium7 | TreeString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Mobile Binary NumberGiven a nested-bar mobile whose bars may each be flipped independently, find the K-th lexicographically smallest distinct binary string obtainable across all flip combinations. | Medium7 | Dynamic programmingRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DNA SimilarityFind the lexicographically smallest longest common subsequence of two DNA strings where adjacent picked characters in each string must be within index-distance K. | Medium7 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| I²CParse raw I2C SCL/SDA bit-sample sequences to decode start/stop bits, address, direction, ACKs, and data bytes, reporting the transaction or the first protocol error. | Medium7 | SimulationString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| How Was Typesetting Done in the Past?Simulate historical typesetting rules by replacing letter combinations with ligature codes and correctly choosing long s versus short s per word based on multiple context-dependent rules. | Medium7 | StringImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Optimizing Mobile Phone Text EntryPartition the 26 letters into K ordered contiguous groups (max 8 each) to minimize frequency-weighted key presses, breaking ties by lexicographically smallest concatenated output. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Secret WordsGiven secret words and a target string, find minimum total rearrangement cost to build the target by concatenating (possibly rearranged) copies of the words, or -1 if impossible. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 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 |
| Tap DanceMaintain, after each single-character flip in a binary string, the length of the longest alternating (no two equal adjacent) substring, supporting online point updates. | Medium7 | Segment treeString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| A=SInsert plus signs between digits of a huge number A so the resulting sum equals a small target S, using as few plus signs as possible. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Closest Permutation NumbersGiven digit string a and a multiset of digits from b, find the smallest permutation of b's digits that is >= a and the largest that is < a, with no leading zero. | Medium7 | GreedyString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Repeated SubstringGiven a lowercase string of up to 200000 characters, compute the length of the longest substring that occurs at least twice, allowing overlaps. | Medium7 | StringBinary search+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Sierpinski TriangleGiven a Sierpinski-triangle sub-triangle's name string, output the names of all triangles it leans against based on the fractal's midpoint-subdivision structure. | Medium7 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Formula SubstitutionGiven two formula strings with variables 0 and 1, find basic-formula substitutions for both variables that make the two formulas syntactically identical, similar to unification. | Medium7 | RecursionString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Character EquationGiven a recursive definition of a huge string T through variable concatenation equations, determine whether a pattern P is a subsequence of T without expanding T explicitly. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Complicated ExpressionsParse an arithmetic expression with parentheses and reprint it with every redundant parenthesis removed while preserving exact operator precedence and associativity semantics. | Medium7 | StringRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CaptionGiven a fixed current pixel grid layout and a new text with letter width k and spacing bounds smin/smax, find the layout minimizing flipped pixels using DP over positions and letters with precomputed per-letter overlap costs. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| High SecurityGiven up to 50000 length-5 passwords over 62 characters, count pairs of passwords for each Hamming distance from 0 to 5. | Medium7 | StringCombinatorics+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Auxiliary Question of the UniverseGiven a fragment of an arithmetic expression grammar (numbers, plus, parentheses), find the minimum insertions needed to make it a valid expression while keeping the fragment as a subsequence. | Medium7 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| KINA Is Not AbbreviationGiven a text, find the abbreviation (initials of a consecutive word window) that is unambiguous per the stated rules and maximizes letter-count reduction, breaking ties lexicographically. | Medium7 | String matchingHash map+2 | No attempts yet | 2s | 512 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 |
| A+BGiven forbidden strings V, find the lexicographic index sum of A and B among all strings orthogonal to V, then output the string at that index modulo the count. | Medium7 | MathCombinatorics+1 | No attempts yet | 2s | 64 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 |
| AmbiguousSplit a scrambled, space-free string into a unique sequence of dictionary words matching letter multisets, first and last letters, reporting ambiguity or impossibility. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Best Name for Your BabyGiven a context-free grammar-like rewriting rule set, find the lexicographically smallest terminal string of exactly length l derivable from start symbol S. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MysteryGiven a character set and N integers in [-X, X] where X is one less than the set size, output the unique length-N string those integers encode. | Medium7 | StringMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| HyperdromeCount substrings of S whose characters can be rearranged into a palindrome, where only the parity of each letter's count matters. | Medium7 | Bit manipulationPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| AbbreviationsGiven ignored stopwords, an abbreviation, and a sentence, count the distinct ways to split the abbreviation into pieces matched as subsequences of the meaningful words in order. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| OctagonsGiven words over {a,b,c} describing paths in the labeled (3,3,3,8) octagon tessellation, decide whether each path returns to its start. | Medium7 | MathString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Life FormsGiven up to 100 DNA strings, find every longest contiguous substring that appears in strictly more than half of them, printed in alphabetical order. | Medium7 | StringBinary search+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Cousin StringsFind the smallest n such that x is an n-th cousin of y, where each cousin step requires a common string reachable by deleting at most half of each string, or report that no n exists. | Medium7 | GraphBFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Help!Given two patterns of literal words and named placeholders, find the lexicographically smallest word phrase matching both, or output a minus sign if none exists. | Medium7 | StringHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Edit Step LaddersGiven a lexicographically sorted dictionary, find the longest sequence of words where each consecutive pair differs by one insertion, deletion, or substitution, and the sequence follows dictionary order. | Medium7 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DoubletsGiven a dictionary, answer queries for the shortest chain of words where consecutive words differ in exactly one letter, choosing the lexicographically smallest chain. | Medium7 | BFSGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BraceletsGiven two circular strings, find the longest common subsequence that can be read in the same or opposite orientation on the two bracelets, and report twice its length. | Medium7 | Dynamic programmingString+2 | No attempts yet | 30s | 256 MB | Judgeable |
| BeadsGiven two 13-bead rings, each with 13 gray and 13 yellow beads, find the fewest swaps of a 3-bead block between the rings to put all gray on top. | Medium7 | BFSString+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 |
| Syntax IncludedParse each HTML-like string against the given grammar and decide whether it is syntactically valid. | Medium7 | StringRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Stems SellApply ordered pattern-to-replacement rewrite rules, which support *, V, C, and back-references, to every word in each paragraph. | Medium7 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Shape NumberGiven a chain code, take its first difference mod 8 and print the lexicographically smallest cyclic rotation of that sequence. | Medium7 | StringString matching+1 | No attempts yet | 2s | 128 MB | Judgeable |
| ClickomaniaGiven a string over uppercase letters, decide whether the one dimensional Clickomania puzzle can be fully cleared. | Medium7 | Dynamic programmingIntervals+1 | No attempts yet | 10s | 128 MB | Judgeable |
| The Sorcerer's DonutOn a torus grid of letters, find the longest string that can be read twice along two non-self-overlapping straight runs in the 8 directions, breaking ties lexicographically. | Medium7 | StringBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Word AdditionCount letter-to-digit assignments that make a cryptarithmetic addition of up to 12 words valid, with no leading zeros and distinct digits per letter. | Medium7 | BacktrackingBrute force+2 | No attempts yet | 40s | 128 MB | Judgeable |
| Code TheftNormalize two sets of source lines and find the longest consecutive run of lines common to both, reporting the length and which files achieve it. | Medium7 | StringHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Gooseberry Tart BASICImplement a fast interpreter for a small BASIC subset with LET, GOTO, IF, FOR/NEXT, OUT, and COMMENT, printing each program's output. | Medium7 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |