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 results457 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Transforming CometsGiven two cyclic sequences of integer points, decide whether one is a rotation, uniform positive scaling, and translation of the other, and report the matching cyclic offset. | Hard8 | String matchingGeometry+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Ransom NoteGiven a target note and a newspaper text, find the minimum number of contiguous clips (letters and spaces only, case-insensitive, reusable) needed to paste the note. | Hard8 | Dynamic programmingString+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 |
| Similar PolygonsDecide whether two polygons are similar, and if so print the square of the similarity factor as a reduced fraction and the matching vertex index in the second polygon. | Hard8 | GeometryString matching+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Similar PolygonsDecide whether two polygons are similar under rotation, reflection, translation, and scaling, then output the exact squared similarity ratio and the smallest matching vertex index. | Hard8 | GeometryString matching+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Automatic TradingGiven a string and pairs of positions, for each query find the length of the longest common prefix of the two suffixes starting at those positions. | Hard8 | StringString matching+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Address MatchingMatch each student address to a distinct teacher address with minimum total weighted edit distance, and among optimal matchings output the lexicographically smallest index sequence. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Word EncodingGiven up to 1000 forbidden substrings of length 1 to 3, rank valid words by length then alphabetically; answer queries converting a word to its index and an index to its word. | Hard8 | Dynamic programmingString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Morphing is funGiven color mutation rules, decide whether every fixed-height cell eventually stops changing color over the nights. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| NecklacesDecide whether two run-length compressed string descriptions encode the same circular necklace up to rotation. | Hard8 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BeadsSplit the bead string into blocks of size k (leftover dropped) and find the k that maximizes the count of distinct blocks, where a block and its reversal are the same. | Hard8 | StringHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AntisymmetryCount how many contiguous substrings of a binary string are antisymmetric, meaning each character differs from its mirror-position partner. | Hard8 | StringHash map+2 | No attempts yet | 3s | 512 MB | Judgeable |
| A Horrible PoemGiven a string and substring queries, find the length of the shortest full period of each substring, where a full period divides the substring into equal repeats. | Hard8 | StringNumber theory+2 | No attempts yet | 8s | 128 MB | Judgeable |
| PrefixuffixGiven a string t, find the maximum length L, at most n/2, such that the length-L prefix and the length-L suffix of t are cyclic rotations of each other. | Hard8 | StringString matching+2 | No attempts yet | 3s | 512 MB | Judgeable |
| The Shortest PeriodDelete exactly one letter from a string to minimize the length of the shortest period of the resulting word. | Hard8 | StringString matching+2 | No attempts yet | 5s | 128 MB | Judgeable |
| TurnsFor each starting position, find how many turns must be observed before the position on the map becomes uniquely determined. | Hard8 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Almost ConjugatesDecide whether two length-n words are almost conjugates and, if so, list every rotation of the first that differs from the second in exactly one position. | Hard8 | StringString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cyclic NumbersFind the smallest B >= n that is a multiple m*A (1<=m<=k) of some k-digit number A whose multiples 1..k are all cyclic rotations. | Hard8 | String matchingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Folding the MapDecide whether an n by m map with convex or concave creases folds to one square. | Hard8 | SimulationDivide and conquer+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Fibonacci GameDetermine whether the first player wins a game that erases Fibonacci words only from the right end of a given a/b string. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MutationsAnswer many queries whether a fragment of the second array matches a fragment of the first after changing all copies of one value. | Hard8 | String matchingHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TrainSum over all n! orders of the wagon strings the number of occurrences of their concatenation in t. | Hard8 | Dynamic programmingString matching+1 | No attempts yet | 1s | 128 MB | Judgeable |
| DrzewaFor each node of a labeled rooted tree, find the leaf below it whose downward label string is lexicographically largest, breaking ties by smaller leaf number. | Hard8 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Text AlgorithmsMove a pawn from the bottom-right to the top-left of a grid where left and up steps cost 1 and diagonal steps are free when row and column colors match. | Hard8 | Dynamic programmingString matching | No attempts yet | 1s | 128 MB | Judgeable |
| Rotate and RewriteDecide whether two rotatable integer sequences can be reduced to a common sequence by substring rewrite rules and report the greatest such length. | Hard8 | Dynamic programmingString matching+1 | No attempts yet | 15s | 128 MB | Judgeable |
| Fragment ReassemblyArrange the given text fragments so neighbors share an exact overlap and print the joined text in lines of at most 72 characters. | Hard8 | BacktrackingString matching+1 | 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 |
| Correcting CuriosityGiven two strings, find the length of the shortest substitution command that rewrites the first into the second. | Hard8 | String matchingString+1 | No attempts yet | 2s | 256 MB | Judgeable |
| PasswordsFind the longest prefix length and suffix length from two distinct set strings whose repetitions coincide. | Hard8 | String matchingString | No attempts yet | 7s | 128 MB | Judgeable |
| Tandem RepeatsCount substrings of even length whose first half equals the second half in each DNA string. | Hard8 | String matchingDivide and conquer | No attempts yet | 1s | 128 MB | Judgeable |
| KkunglishFor each query range, the program reports the case-insensitive occurrence of T with the most case differences, or -1 if none, then flips the case of the range. | Hard8 | Segment treeString matching | No attempts yet | 2s | 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 |
| C(O|W|A*RD*|S)* CROSSWORD PuzzleFill a 2 to 4 by 2 to 4 grid with capital letters so each row and column matches its regex clue, and report the unique solution, none, or ambiguous. | Hard8 | BacktrackingString matching | No attempts yet | 10s | 128 MB | Judgeable |
| CriminalsFind every house where two given color sequences appear as subsequences on the left and right with both walkers sharing one home color outside. | Hard8 | String matchingGreedy+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Hari MerdekaChoose a string over priced letters with total cost within the budget to maximize the summed scores of all occurrences of the given words. | Hard8 | Dynamic programmingString matching | No attempts yet | 3s | 256 MB | Judgeable |
| Out of contextFor each text line, print the longest substring the given grammar generates, breaking ties by earliest position, or NONE. | Hard8 | Dynamic programmingString matching | No attempts yet | 10s | 256 MB | Judgeable |
| Virus synthesisBuild each DNA string over A, C, G, and T from empty using single-letter attachments or mirrored duplication in the fewest operations. | Hard8 | Dynamic programmingString matching | No attempts yet | 20s | 256 MB | Judgeable |
| Integer in IntegerCount how many times C appears as a (possibly overlapping) substring in the decimal writings of all integers from A to B, modulo 1000000007. | Hard8 | Dynamic programmingString matching+1 | No attempts yet | 10s | 128 MB | Judgeable |
| Revenge of the ants 2Labeled ants walk both ways on a circular rail and bounce on collision; compute when each ant is back at its start with its initial direction. | Hard8 | String matchingSorting+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Evolution in ParallelDecide whether every fossil sequence fits into one of two chains in which each sequence is a subsequence of the next one and of the living species sequence. | Hard8 | GraphBFS+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Bracket StringsFor each queried length L, count bracket strings that match the incorrect or aperiodic filters chosen by flags p and q, modulo m. | Hard8 | CombinatoricsNumber theory+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Finding a Grayscale ImageCount the R by C windows of A that equal B after a linear brightness change of the form p times A plus q. | Hard8 | String matchingMatrix+1 | No attempts yet | 10s | 512 MB | Judgeable |
| Text ProcessorCount the distinct substrings inside each fixed-width window of a lowercase string for many queries. | Hard8 | String matchingSliding window+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Counting palindromesCount the palindromic substrings fully contained in each query interval of a lowercase string. | Hard8 | String matchingSegment tree+2 | No attempts yet | 2s | 64 MB | Judgeable |
| Swapping the StonesMove stones along empty arcs of a circular shore so black and white stones exchange position sets with minimum total carry distance, or report impossibility. | Hard8 | GreedyString matching+1 | No attempts yet | 2s | 32 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 |
| Wildcard (Large)Given two filenames A and B, find the shortest star pattern that matches A but not B, breaking ties by fewer stars then lexicographic order. | Hard8 | Dynamic programmingString matching+1 | No attempts yet | 5s | 512 MB | Judgeable |
| The Great Mixing Song FestivalPartition the given songs into groups of exactly c songs each within a year span of m, maximizing the total length of the longest common substring in each group. | Hard8 | Dynamic programmingBit manipulation+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Shades of the townGiven several integer patterns and one shade array, count every occurrence where a contiguous block equals a pattern scaled by a positive real factor. | Hard8 | String matchingMath | No attempts yet | 1s | 1024 MB | Judgeable |
| Hongjun Likes StringsFor each of up to 100000 queries, find the shortest substring of a fixed string S that contains both given short patterns A and B, allowing overlap. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Maximum substring costGiven a string T, find the maximum of length times number of occurrences over all substrings S of T. | Hard8 | StringSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Substring CountCount length-L lowercase strings that contain exactly C of N given words (N at most 6, L at most 50) as substrings, modulo 1,000,000,009. | Hard8 | Dynamic programmingString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PasswordGiven a length-N string, collect all distinct substrings meeting four counts (length, digits, specials, uppercase), sort them lexicographically, and print the middle one. | Hard8 | StringSorting+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Pseudo PalindromeGiven a string w and a rational theta, split w into the fewest substrings that are each a theta-palindrome (form uvu^R with enough border), or report 0. | Hard8 | Dynamic programmingString matching+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Good SubstringsCount how many distinct substrings of a binary string appear twice at non-overlapping positions. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Palindromes and QueriesSupport range character assignments and count palindromic substrings of length at most K inside a queried range. | Hard8 | Segment treeString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Revenge of the Champernowne ConstantGiven a digit string S of length up to 100, find the 1-indexed position of its first occurrence in the Champernowne constant 0.123456789101112... | Hard8 | StringMath+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Favorite musicGiven n note strings and q pairs, find the shortest string containing both given fragments as contiguous substrings, allowing overlap. | Hard8 | String matchingTrie+2 | No attempts yet | 1s | 256 MB | Judgeable |
| ExamGiven each student's fixed semester points and a distribution of exam points, find the probability that the grade string avoids all forbidden substrings. | Hard8 | Dynamic programmingString matching+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Game of MatchingsCount substrings of S that match pattern P under a bijective letter-to-number mapping, where distinct numbers must get distinct letters. | Hard8 | String matchingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PasswordsCount length A to B alphanumeric passwords with mixed case and a digit that avoid blacklist substrings, where digits can stand in for similar letters. | Hard8 | Dynamic programmingString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Kids Designing KidsGiven three grid pictures, find the translation of the second that makes the XOR of the first two match the third, up to translation. | Hard8 | ImplementationString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Substring appearing twiceGiven a string and at most K letter replacements, maximize the length of the longest substring that occurs at two different starting positions, allowing overlap. | Hard8 | StringBinary search+2 | No attempts yet | 6s | 128 MB | Judgeable |
| Permutations that contain a wordCount distinct permutations of A that contain B as a contiguous substring, modulo 10007. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 128 MB | Judgeable |
| OsmosmjerkaGiven a letter block tiled infinitely in all directions, pick a random start square and one of 8 directions twice, and report the probability that the two read words of length K match, as a reduced fraction. | Hard8 | MathString matching+2 | No attempts yet | 4s | 256 MB | Judgeable |
| String arrayCount strings S of length 1 to W such that the repeated periodic filling of X matches the given patch F at the fixed offset. | Hard8 | String matchingNumber theory+1 | No attempts yet | 2s | 512 MB | Judgeable |
| f(X) = A + X + B + X + CCount occurrences of pattern F in the K-fold string expansion f(X)=A+X+B+X+C applied to S, modulo 1e9+7. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PianoGiven N equally likely piano tones, find the expected number of presses until a fixed M-tone sequence appears, for every prefix of it. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Palindromes and Queries 2Given a string and queries, each query asks how many palindromic substrings start at a given index with length at least a given value. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Period of a Slot MachineGiven a sequence of n outcomes, find k and p minimizing k+p (ties by smaller p) such that T[i+p]=T[i] for all i>k with i+p<=n. | Hard8 | String matchingImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Flipping OutCount the strings that, added to the given patterns, make the flip rule reproduce the given flip sequence, or -1 if infinitely many work. | Hard8 | StringDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Calendar FragmentGiven a small rectangular fragment cut from a fixed-format yearly calendar, list all years from 1900 to 2100 whose calendar could contain that fragment. | Hard8 | ImplementationSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| MarsFor each query substring, find the minimum number of bit flips that make it match no substring of the DNA, or report Impossible. | Hard8 | String matchingDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Vera and the BanquetGiven a circular string S, count the number of distinct substrings appearing in any contiguous block read in either direction around the circle. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Standing Out from the HerdFor each name in the herd, count its substrings that occur in no other name. | Hard8 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Longest Common Palindromic SubstringGiven up to 50 strings with total length 1,000,000, find the length of the longest palindrome that occurs as a substring in every one of them. | Hard8 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Split and MergeGiven two tilings of a 1xL board by 1x1 and 1x2 pieces, find the minimum number of split/merge operations to transform one into the other and count the ways. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| LotteryFor each of n-l+1 length-l windows and each query threshold k, count how many other windows differ from it in at most k positions. | Hard8 | String matchingHash map+2 | No attempts yet | 2s | 32 MB | Judgeable |
| Willy Feels GuiltyBuy, throw, or swap products so the delivered sequence realizes a fixed menu at minimum total cost. | Hard8 | String matchingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Hiding MerlinDecompose a digit string into concatenated perfect squares, each at most 10 digits and starting with 1 to 9, and report the smallest possible total sum. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Binary Tree and SequenceFind the smallest tree depth where one concatenated leaf sequence occurs at least K times under a periodic leaf pattern. | Hard8 | String matchingHash map+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Suffix-FreenessGiven a DFA with n at most 2000 states and f final states, decide whether some accepted string is a proper suffix of another accepted string, and answer 1 or 0. | Hard8 | String matchingGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Isomorphic InversionSplit a digit string into the largest number of contiguous pieces whose sequence of pieces reads the same forward and backward. | Hard8 | GreedyString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Locker RoomPick length-K substrings from a cyclic string covering every position and minimize their lexicographic maximum. | Hard8 | StringGreedy+2 | No attempts yet | 6s | 512 MB | Judgeable |
| Numbers GeneratorGiven up to ten H/T patterns of the same length, compute the expected number of fair coin flips until one pattern first appears contiguous. | Hard8 | String matchingHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Repeated SubstringsFind the longest substring with at least two overlapping occurrences in a string of up to 10^5 letters, breaking ties by the smallest in lexicographic order. | Hard8 | String matchingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| A Sequence That Matches Front and BackChoose how many elements to cut from the array's front so that, if the rest is a k-front-back sequence, k is as large as possible or no k exists. Return k and the cut count. | Hard8 | ArrayString matching+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Bad KemingFill every gap in the spaced copy of S with chosen letters to make the longest prefix of S a contiguous substring, and find that prefix length. | Hard8 | String matchingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct SubstringsGiven a period string p and length n, count distinct substrings of the string formed by repeating p and cutting to n. n may be 1e9. | Hard8 | String matchingMath+1 | No attempts yet | 3s | 512 MB | Judgeable |
| The ABCD MurdererFind the fewest word occurrences needed to cover a target text exactly when cut-outs may overlap on matching text, or report -1 if impossible. | Hard8 | String matchingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Prefix Suffix SearchGiven N words and Q prefix/suffix pairs, report for each query how many words match both prefix and suffix. Total input length is up to 2.5 million. | Hard8 | String matchingTrie+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Naming the ComputerGiven a string S and integer K, find the shortest string that contains S as a substring at least K times, and output its length. | Hard8 | String matchingDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct Substring Queries 2Process a stream of append-character and count-distinct-substrings queries on a growing string, answering each count query online. | Hard8 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Substring ReplacementReplace each question mark in S with a lowercase letter so that T appears as a substring as many times as possible, and report that maximum count. | Hard8 | Dynamic programmingString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| String DecorationGiven a string S and N pattern strings, find the length of the shortest substring of S that contains every pattern as a substring. | Hard8 | StringSliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ZooGiven a string, count for each prefix the non-overlapping prefix-suffix matches and output the product of (count+1) modulo 1e9+7. | Hard8 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Ali's TypewriterGiven a keypress sequence that builds strings in a buffer and prints them, answer queries counting how often printed string x occurs inside printed string y. | Hard8 | StringTrie+2 | No attempts yet | 1s | 512 MB | Judgeable |
| AbbreviationCount the ways to split a query string into pieces, where each piece is a prefix of some dictionary word, with duplicates counted as distinct. | Hard8 | Dynamic programmingString matching+2 | No attempts yet | 2.5s | 1024 MB | Judgeable |
| Fox QuizGiven answer strings S and T over O/X, answer range queries and point flips: for a range, choose positions to mark F to maximize A times correct answers plus B times occurrences of the consecutive pattern F,O,X. | Hard8 | Segment treeDynamic programming+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Copy and PasteGiven a string of up to 200,000 lowercase letters, find the length of the longest substring that appears at least twice at disjoint positions, or -1 if none exists. | Hard8 | StringBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |