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,020 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Queen CollisionsGiven groups of queens placed along arithmetic progressions on an n by n board, count pairs that share a row, column, or diagonal with no queen between them. | Medium7 | MathSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Trie, Again TrieGiven trees encoded in preorder, find the repeated subtree whose replacement by one shared copy saves the most nodes, breaking ties by size then preorder. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Walk in the ParkCount trees visible from at least one given horizontal or vertical path, where a tree is visible if no other tree blocks the line of sight. | Medium7 | SortingHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| String EquationsDecide whether a subset of distinct short strings and their repeats can be split into two groups whose multiset union of characters is identical. | Medium7 | MathNumber theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Incidental PointsFor each test case, choose two points whose segment contains the most other given points and report that count. | Medium7 | GeometryHash map+2 | No attempts yet | 5s | 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 |
| 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 |
| Functional Programming CountsImplement an interpreter for a tiny functional language with variables, single-parameter functions, and call-count profiling per definition line. | Medium7 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PointsCount the distinct straight lines in 3D space that pass through at least three of the given points. | Medium7 | GeometryHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Acrobat ReaderFor each test case, decide whether two sets of N points match under rotation by a multiple of 90 degrees, translation, and positive uniform scaling, with reflections disallowed. | Medium7 | GeometryHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Comparing CodeFind the longest run of HAL's lines that matches a run of RBN's lines up to injective variable renaming and swapping the two right-hand operands. | Medium7 | String matchingHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Electrical PollutionGiven consistent anomaly measurements at grid points, determine for each queried point whether its anomaly is uniquely forced by propagation along rows and columns of generators on the diagonal line. | Medium7 | Union-findGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cocircular PointsFor each test case with up to 100 distinct points, find the largest subset that lies on one common circle and print its size. | Medium7 | GeometryHash map+2 | No attempts yet | 5s | 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 |
| Party InvitationsInviting cow 1 forces whole groups once all but one member is in; find the smallest set of cows that must be invited. | Medium7 | GraphBFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MirrorsGiven N small mirrors tilted at 45 degrees, find the first mirror whose flip lets a horizontal ray from the origin reflect to reach point (a,b). | Medium7 | GeometrySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Concurrently Balanced StringsGiven K parenthesis strings of length N, count index ranges whose substring is balanced in all K strings at once. | Medium7 | Hash mapPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Wrong DirectionsGiven a command string of F, L, and R, count the distinct final positions reachable by changing exactly one character to a different one. | Medium7 | SimulationHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow PhotographyGiven five orderings of N cows where each cow moves in at most one photo, reconstruct the original intended order. | Medium7 | SortingImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cows on IceBessie slides on ice until a rock stops her; find the minimum number of pushes to move from her start cell to the goal cell. | Medium7 | BFSGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Gold Balanced LineupGiven N cows each with a K-bit feature ID, find the longest contiguous range where every one of the K features appears the same number of times. | Medium7 | Hash mapPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SolitaireGiven two placements of four identical pieces on an 8x8 board, decide whether slides and jumps reach the second from the first within 8 moves. | Medium7 | BFSGraph+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 |
| MobileDecide whether two mobiles, given as rooted binary structures with negated weight labels, can be rotated to look identical. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Guessing Game IIGiven up to 8 guess/response pairs, decide whether the 4-digit secret is already unique, find the smallest next guess that identifies it, or report that none can. | Medium7 | Brute forceHash map+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Shopping OffersGiven regular item prices and bundle offers, find the minimum cost to buy exactly the listed quantities without buying extras. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Uniform SubtreesGiven a parenthesis-encoded tree, list every distinct uniform subtree (same child count at each depth) in lexicographic order. | Medium7 | TreeDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Cake CuttingCount the distinct rectangular pieces that can be left after repeatedly halving a cake into two equal halves with equal candle counts. | Medium7 | Divide and conquerRecursion+1 | No attempts yet | 1s | 1024 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 |
| Lattice AnimalsCount free n-polyominoes (up to rotation and reflection) that fit inside a w by h rectangle, with n up to 10. | Medium7 | BacktrackingBrute force+2 | No attempts yet | 2s | 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 |
| UFO Cubes in RoswellGiven a cube with mirrors at integer points, trace every downward light ray and report how many exit each face and how many deflections they took. | Medium7 | SimulationImplementation+2 | No attempts yet | 2s | 1024 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 |
| NeighboursGiven n peaks on a w by h grid, count non-peak grid points by how many of their four axis directions contain a peak. | Medium7 | SortingHash map+2 | No attempts yet | 2s | 64 MB | Judgeable |
| Counting Rectangles Drawn with SegmentsCount axis-aligned rectangles whose four sides are fully covered by the union of the given collinear segments. | Medium7 | GeometryHash map+2 | No attempts yet | 1s | 16 MB | Judgeable |
| Texture TileGiven an N x N image, find the largest square subimage whose top row equals its bottom row and left column equals its right column. | Medium7 | Dynamic programmingHash map+1 | No attempts yet | 2s | 256 MB | Judgeable |
| PointsGiven a pattern point set and up to 20 query sets, decide for each whether it is similar to the pattern under rotation, translation, reflection, and scaling. | Medium7 | GeometrySorting+2 | No attempts yet | 3s | 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 |
| 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 |
| Algorithm SpeedupDecide whether a recursively defined Boolean function F on two sequences returns 1 or 0, where F strips the longest prefix and suffix that drop some value. | Medium7 | RecursionHash map+2 | No attempts yet | 8s | 128 MB | Judgeable |
| WalkGiven up to one million missing strings among n-bit names, decide whether two present names are connected through single-bit flips avoiding blocked names. | Medium7 | BFSGraph+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Fiber Optic NetworkReserve bandwidth on tree paths for connect requests when capacity allows and release per-pair reservations on disconnect. | Medium7 | Segment treeTree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Guessing GameFind the largest prefix of interval parity answers that stays consistent with some 0/1 sequence of length one billion. | Medium7 | Union-findPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Weights and ScalesPlace one gray weight on the empty pan, then repeatedly merge each balanced scale in the nested tower, and report the fewest weights that can remain. | Medium7 | Prefix sumHash map | No attempts yet | 1s | 128 MB | Judgeable |
| Lost ListsRebuild the lexicographically smallest increasing list of distinct positive integers matching each sorted pairwise sum list, or print -1 when none exists. | Medium7 | BacktrackingSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Common SubstringFind the length of the longest substring shared by two lowercase strings and print the lexicographically smallest one of that length. | Medium7 | String matchingBinary search+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Conditional StatementsGiven one-variable if lines that switch on numbered lights, delete as many lines as possible without changing which lights turn on for any input values. | Medium7 | IntervalsHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Nearby GravitationCount pairs of 3D points whose Euclidean distance is smaller than k for each test case. | Medium7 | Hash mapGeometry | No attempts yet | 5s | 128 MB | Judgeable |
| Hack ProtectionCount the subarrays of the given array whose bitwise XOR equals their bitwise AND. | Medium7 | Bit manipulationPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Directional ResemblanceFind the pair with the smallest nonzero angle among up to 120000 3D vectors per dataset, where some vectors come from a given pseudorandom generator. | Medium7 | GeometrySorting+1 | No attempts yet | 10s | 128 MB | Judgeable |
| Endless Candy PartyFor each s from 1 to N, find the smallest day k on which exactly s tables share the same floor(b_i/k) candies per person. | Medium7 | MathHash map+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Hash functionCount the length-N lowercase words whose repeated multiply-by-33 xor hash modulo 2^M equals K. | Medium7 | Divide and conquerHash map+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Fair PhotographyAfter sorting cows by position, find the widest contiguous group containing at least K breeds with each present breed appearing equally often. | Medium7 | Prefix sumHash map | No attempts yet | 1s | 128 MB | Judgeable |
| LanguagesGuess the language of each 100-symbol excerpt, learning online from the correct answer returned after every guess, and maximize accuracy over 10000 turns. | Medium7 | SimulationImplementation+2 | No attempts yet | 10s | 256 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 |
| Attacked squaresAfter each rook relocation on a large board, count squares where the xor of powers of rooks in the same row or column is nonzero. | Medium7 | Bit manipulationHash map+1 | No attempts yet | 2s | 64 MB | Judgeable |
| Digit DivisionCount the ways to split a digit string into contiguous blocks so each block is divisible by m, modulo 1e9+7. | Medium7 | Dynamic programmingMath+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Boring Planet PairsCount the planet pairs whose path xor is zero before any deletion and after each edge removal in order. | Medium7 | Union-findHash map | No attempts yet | 1s | 64 MB | Judgeable |
| SymmetryGiven up to 100000 planar points per test case, decide whether any line reflects the set onto itself. | Medium7 | GeometryHash map+1 | No attempts yet | 2s | 256 MB | Judgeable |
| OOPCount for each pattern with one asterisk how many given words equal it after replacing the asterisk with any string, possibly empty. | Medium7 | String matchingHash map+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Joy's TerritoryCount the unit squares with all four corners visited by repeating the same N-step walk for K days from each day's endpoint. | Medium7 | GeometrySimulation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Reassembling the Glass CowCount the triples of scattered pieces that rebuild the colored figurine after rotation, reflection, and shifting. | Medium7 | Brute forceGeometry+2 | No attempts yet | 5s | 512 MB | Judgeable |
| gWheels (Large)Decide whether pedal, middle, and tire gear choices with two different middle gears produce each target speed ratio. | Medium7 | Number theoryHash map | No attempts yet | 15s | 512 MB | Judgeable |
| Snake Game SimulationSimulate a snake that grows on checkerboard food on a wrapping board with timed turns and report its length after death or one billion steps. | Medium7 | SimulationQueue+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Log Set (Small)Reconstruct the original integer multiset from the frequencies of all its subset sums, breaking ties by sorted order. | Medium7 | BacktrackingSorting+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Symmetric Trees (Large)Decide whether a color-painted tree can be drawn in the plane with a vertical line of symmetry. | Medium7 | TreeRecursion+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Diamond InheritanceProcess class declarations in order, accepting each only if the name is fresh, all parents exist, and no diamond forms. | Medium7 | GraphDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| GCD TableGiven all N^2 pairwise gcd values of a hidden sequence in random order, recover the sequence. | Medium7 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Celtic SymmetryGiven up to 1000 distinct integer points in the plane, count the distinct lines of symmetry of the set. | Medium7 | GeometryHash map+2 | 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 |
| Easy ReadingGiven a book text and a picture of painted cells, find the shortest prefix-contiguous text segment whose pen strokes draw exactly that picture up to translation. | Medium7 | String matchingHash map+1 | No attempts yet | 2s | 256 MB | Judgeable |
| BabelGiven M words, each shared by two languages, find the shortest word sequence from an origin to a destination language where adjacent words differ in first letter. | Medium7 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct AND values of subsequencesCount how many distinct values can appear as the bitwise AND of some subsequence of a given array, including the empty subsequence whose AND is 0. | Medium7 | Bit manipulationDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Jazz JourneyGiven a fixed closed tour and ticket prices for one-way and round-trip fares, find the minimum cost to cover every leg of the tour. | Medium7 | GraphGreedy+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Pascal's Hyper-PyramidsCompute the distinct multinomial coefficients on the base layer of a D-dimensional Pascal hyper-pyramid of height H, printed in ascending order. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Happy sequenceGiven a non-happy sequence, count and list every single-element replacement that makes all adjacent absolute differences exactly the set 1..N-1. | Medium7 | ArrayHash map+1 | No attempts yet | 1.5s | 256 MB | Judgeable |
| Lasers and MirrorsGiven a laser, a barn, and up to 100,000 posts, find the fewest posts to mount mirrors on so the beam travels from laser to barn. | Medium7 | GraphBFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Sherlock and Watson Gym Secrets (Large)Count ordered pairs (i, j), i != j, i, j 1..N, with i^A + j^B divisible by K, output mod 1e9+7. | Medium7 | Number theoryMath+2 | No attempts yet | 5s | 512 MB | Judgeable |
| ParrotsGiven N parrot sentences and one written sequence, decide whether distinct words can interleave so that each parrot's words stay in order and no word repeats. | Medium7 | SimulationGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Dice Straight (Large)Each die shows six distinct numbers; choose at most one number per die so the chosen values form a consecutive run, and maximize its length. | Medium7 | GraphDynamic programming+2 | No attempts yet | 30s | 512 MB | Judgeable |
| Equinox Roller CoasterGiven stable grid points, find the largest axis-aligned square whose four corners are all stable points, and output its side length. | Medium7 | Hash mapGeometry+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Round the world ticketCount distinct city sequences, starting and ending at ZAG, that can be flown using a subsequence of the ordered coupons, modulo 1e9+7. | Medium7 | Dynamic programmingHash map+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Palindromic PartitionsSplit a string into chunks so the chunk sequence is a palindrome, and report the maximum number of chunks possible. | Medium7 | StringGreedy+2 | No attempts yet | 10s | 128 MB | Judgeable |
| AlchemyGiven starting substances and reactions that each require holding a whole set of substances to produce another set, find everything Josko can eventually obtain. | Medium7 | GraphBFS+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Similarity of SubtreesFor every node, count how many nodes share its depth profile in the rooted tree; sum the number of pairs with identical profiles. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Thor's JourneyIn a perfect binary tree of up to 2^17-1 nodes with node weights, count for each query (start node A, target sum D) how many nodes B lie on a path from A with sum D. | Medium7 | TreePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| EmpireSimulate a tree of kingdoms and wars: process each battle in order, transfer vassal subtrees on losses and successful rebellions, then report the root kingdoms sorted by ASCII order. | Medium7 | TreeSimulation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| TextbooksGiven up to 16 priced book titles and a target word of length at most 10, find the cheapest subset of books whose letters can be rearranged to form the target. | Medium7 | Bit manipulationDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Bingo TiesGiven n 5x5 bingo cards where only rows count as winning lines, find whether any two cards can complete their winning rows simultaneously on the same called number. | Medium7 | Hash mapImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ImputationAssign A, T, C, or G in place of each '?' on tree leaves to minimize total transition costs along edges, summed over all string positions independently. | Medium7 | Dynamic programmingTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CowpatibilityCount pairs of cows whose five favorite ice-cream flavors are pairwise disjoint, with up to 50000 cows and flavors up to 10^6. | Medium7 | MathBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Selling RNA StrandsGiven N RNA strings, answer M queries that count strings matching a prefix P and suffix Q. | Medium7 | String matchingHash map+2 | No attempts yet | 1.5s | 1536 MB | Judgeable |
| Sum Source DetectionFor each queried sum X, find every open holder that appears in all valid subsets making X, where secret values must each be below the smallest open value. | Medium7 | Dynamic programmingHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Matrix GameGiven an N by M matrix, it asks who wins a take-away game where a move subtracts 1 to K from the leftmost nonzero entry of some row. | Medium7 | Game theoryGreedy+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| 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. | Medium7 | StringBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| IspitDecide whether some block of K consecutive columns can have its letters shuffled within each row so that two rows become equal. | Medium7 | Sliding windowHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Alphabet StringCount distinct strings formed by sorting the distinct characters of every substring of an uppercase string and removing duplicates. | Medium7 | StringHash map+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium7 | GraphString+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Beer MugsGiven a string of N characters over 20 brands, find the longest substring that is a palindrome after permuting it freely. | Medium7 | Bit manipulationHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Flight PlansEach airport lists either its outgoing destinations or its non-destinations; find the fewest flights from s to t in the resulting implicit graph. | Medium7 | GraphBFS+2 | No attempts yet | 1s | 512 MB | Judgeable |