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 results6,373 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
RacetrackGiven ordered lap times and lap counts and the rule that passes happen only at the finish line, compute when each runner finishes the race.Hard8SimulationImplementation+2No attempts yet2s512 MBJudgeable
Saturn BeesOn a torus-like hexagonal grid, decide whether nm/4 vertices can each dominate a closed neighborhood of 4 vertices, covering every vertex.Hard8MathCombinatorics+2No attempts yet2s512 MBJudgeable
WolfGiven your n-card pile and the opponent's remaining 51... wait 52-n cards, decide whether reordering both piles can make you win the next turn.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Cumulative CodeFor the complete binary tree of depth k, answer q queries each summing m elements of its Prüfer code at positions a, a+d, ..., a+(m-1)d.Hard8MathTree+2No attempts yet7s512 MBJudgeable
Donut DroneSimulate a drone on a toroidal grid where each step moves to the highest of three rightward neighbors, handling up to 1e9 steps per move query and elevation updates.Hard8SimulationBinary search+2No attempts yet8s512 MBJudgeable
Faulty FactorialGiven n, prime p, and target r mod p, find the faulty factorial (one factor reduced below its index) with remainder r, printing the smallest such (index, value).Hard8Number theoryMath+2No attempts yet3s512 MBJudgeable
Kitchen KnobsGiven n seven-digit knobs, find the fewest range rotations (each turning a contiguous block by the same amount) so every knob reads its maximum-power digit.Hard8GreedyImplementation+2No attempts yet3s512 MBJudgeable
Archery TournamentMaintain a dynamic set of non-overlapping circles tangent to the ground, support insertions and point queries that remove the hit circle, and report which circle each arrow hits.Hard8GeometryBinary search+2No attempts yet3s512 MBJudgeable
BoxGiven a box with edges a, b, c and a w by h cardboard, decide whether some edge-aligned net of the box fits on the cardboard.Hard8GeometryBrute force+2No attempts yet3s512 MBJudgeable
ConnectionsGiven a strongly connected directed graph, run two specified BFS traversals to build a set of 2n kept roads and print the rest in input order.Hard8GraphBFS+2No attempts yet3s512 MBJudgeable
The Final LevelFind the minimum number of L-shaped n-blocks needed to cover a connected path of squares from (0,0) to (a,b) on an infinite grid.Hard8MathGreedy+2No attempts yet3s512 MBJudgeable
SumdokuFill a 9x9 Sudoku grid so that constrained adjacent cells inside each 3x3 block satisfy <, =, or > versus 10, and print the lexicographically smallest solution.Hard8BacktrackingImplementation+1No attempts yet2s512 MBJudgeable
Bang! Bang!Given lines and circles all passing through the origin, count how many regions the plane is divided into, treating duplicates as one shape.Hard8GeometryCombinatorics+2No attempts yet2s512 MBJudgeable
Medical CheckupGiven n students in a fixed queue and their per-item service times, report the item each student is on or waiting for at time t+0.5.Hard8SimulationMath+2No attempts yet2s512 MBJudgeable
Making the Perimeter of the Convex Hull ShortestGiven n points, find the largest decrease in convex hull perimeter achievable by removing exactly two of the points.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Rendezvous on a TetrahedronTwo worms start at vertex A of a regular tetrahedron, crawl straight across faces reflecting off edges, and stop after integer trail lengths; decide whether they end on the same face.Hard8GeometryImplementation+1No attempts yet1s512 MBJudgeable
HomeworkGiven n assignments split into two courses with release days and deadlines, simulate fixed tie-break rules over adaptive coin choices and find the maximum and minimum number he can finish.Hard8Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
String PuzzleGiven equality hints between substrings of a huge implicit string plus some fixed letters, decide the letters at the queried positions. The hint structure is a partition of the string into sections, and a hint joins one section to an earlier same-length section, so the constraints are interval equalities on an unknown string of length n; the task is to propagate equality and fixed letters across positions, answering ? where a position's letter is not forced. The input size is small (at most 1000 hints and 1000 queries) but n can be 10^9, so positions cannot be enumerated directly and the hint/Hard8StringUnion-find+1No attempts yet2s512 MBJudgeable
Border WallGiven two colored point sets and a width d, find the minimum number of points to delete so that a strip of width d separates the remaining points by color.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Homotopic PathsDecide whether two polygonal paths from s to t in a plane with point obstacles are homotopic, that is, deformable into each other without crossing any tree.Hard8GeometryImplementation+2No attempts yet2s512 MBJudgeable
Wookje and His FansMaintain a line of fans with club labels under deletions and range-count queries, where each query counts the maximal same-club run around an element.Hard8Linked listUnion-find+2No attempts yet2.5s256 MBJudgeable
RetroGiven a grid where the player moves horizontally while objects fall one row per turn, collect brackets to form the longest valid expression and output the lexicographically smallest one of that length.Hard8Dynamic programmingGreedy+2No attempts yet0.5s512 MBJudgeable
PortalFind the minimum time for Chell to reach F in a grid, where shooting portals into walls is free and stepping through a portal pair costs 1, with at most two portals alive at once.Hard8GraphBFS+2No attempts yet1s256 MBJudgeable
K-summaryGiven segment lengths K_i, count how many array positions are pinned down by all the K_i-summaries.Hard8MathNumber theory+2No attempts yet0.5s64 MBJudgeable
CesteFor each city, find the route from city 1 that minimizes the product of total travel time and total cost, or report -1 if unreachable.Hard8GraphShortest path+2No attempts yet2.5s128 MBJudgeable
Multiple of a Squared FactorialFor many queries N, find the smallest K such that K! is divisible by (N!)^2. The answer is always between N and 2N, and needs Legendre exponent checks.Hard8Number theoryMath+2No attempts yet3s512 MBJudgeable
Binary TransformationsGiven starting bits, target bits, and per-bit costs, flipping a bit i costs the sum of costs of all bits equal to 1 after the flip; find the minimum total price to reach the target.Hard8Dynamic programmingGreedy+2No attempts yet1s256 MBJudgeable
TetrisOn a 3-wide, 10-tall Tetris board, pieces from a repeating shape sequence arrive forever; maximize how many land before the top fills, or output -1 if play can continue indefinitely.Hard8Dynamic programmingSimulation+2No attempts yet2.5s512 MBJudgeable
Umbral DecodingGiven up to 100 safe points (x, y, b), count lattice points (p, q) in the square [0, n]^2 that are not covered by any region |x-p|^3 + |y-q|^3 <= b.Hard8GeometryMath+1No attempts yet2s512 MBJudgeable
Vera and Canada DayAfter each laser is added, choose one of four L-shaped firing orientations per laser so that the total awe from lasers hit by beams is maximized.Hard8Dynamic programmingGraph+2No attempts yet2s512 MBJudgeable
The Jet-Black WingsMaintain a multiset under global XOR updates and queries asking for the sum of the K smallest elements.Hard8TrieBit manipulation+2No attempts yet3s512 MBJudgeable
LCA and queriesFor each query with a designated root r, report the LCA of u and v in a tree of up to 100,000 vertices.Hard8TreeDFS+2No attempts yet2s512 MBJudgeable
City MaintenanceGiven a tree with a price on every vertex, find the maximum, over all choices of a removed vertex, of the sum of the maximum price within each remaining connected component.Hard8TreeDFS+2No attempts yet2s512 MBJudgeable
Making a Beautiful PuzzleFill each square of an N by M board with one of four colors so that orthogonal neighbors differ, maximizing total beauty and counting optimal placements modulo 1e9+7.Hard8Dynamic programmingBacktracking+2No attempts yet3s128 MBJudgeable
Operation OptimizationFind the shortest sequence of append-0, append-1, and self-doubling operations whose two-fold application to the empty string yields a given binary string S.Hard8StringGreedy+2No attempts yet2s256 MBJudgeable
Escape from HellChoose an order to use N energy drinks so the climber reaches length L on the earliest day without sinners catching up at night.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Share the Ruins PreservationSplit points by a vertical line that avoids all points, build the minimum-area enclosing convex hull of each side, and minimize the total area.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Map of the Ninja HouseReconstruct the graph of a ninja house from the counter and door records produced by a fixed DFS exploration, handling back edges, skips, and multi-edges.Hard8GraphDFS+2No attempts yet2s512 MBJudgeable
Dango MakerChoose disjoint horizontal or vertical runs of three cells reading R, G, W in order on an N by M grid, maximizing how many such sticks fit.Hard8Dynamic programmingMatrix+2No attempts yet2s256 MBJudgeable
MiningGiven a grid of mineral strengths with air only on the top, left, and right faces, find the smallest performance D so that at least K minerals can be removed in some order.Hard8Binary searchBFS+2No attempts yet2s256 MBJudgeable
Big Number Multiplication (2)Multiply two integers of up to 300,000 digits each, too large for quadratic multiplication, and print the exact product.Hard8MathDivide and conquer+2No attempts yet2s512 MBJudgeable
Connect the DotsGiven a 4 by 4 grid labeled 1 to 16, find the minimum number of straight segments a continuous polyline needs so that the dots are visited in numeric order.Hard8GeometryGreedy+2No attempts yet2s512 MBJudgeable
Factor-Free TreeGiven a sequence, decide whether it can be the inorder of a rooted binary tree where every node is coprime with all its ancestors, and if so output each node's parent index.Hard8TreeDivide and conquer+2No attempts yet6s512 MBJudgeable
Juggling TroupeSimulate balls thrown left and right simultaneously until every position holds at most one ball, then report the final configuration.Hard8SimulationGreedy+2No attempts yet3s512 MBJudgeable
PillarsGiven a grid with 2x2 pillars spaced apart, construct the unique Hamiltonian circuit through all free cells defined by a fixed local rule.Hard8ImplementationSimulation+2No attempts yet2s512 MBJudgeable
The StagingGiven n gangsters each aiming at a distinct target, count survivors after each of q updates to the shooting time of one gangster.Hard8GraphDynamic programming+2No attempts yet2s512 MBJudgeable
Drawing a Character FaceGiven three circles, compute the area of their union, counting overlaps once, and print it to six decimal places.Hard8GeometryMath+2No attempts yet0.1s256 MBJudgeable
Two tetrominoesPlace two non-overlapping tetrominoes anywhere on an N by M grid so the total of the covered cells is maximized.Hard8Brute forceDynamic programming+1No attempts yet2s512 MBJudgeable
Spacetime StoneAssign Taekhee's cards to rounds and pick a strength-joker round so that Namgyu's best-case score (over his joker round) is minimized, ties broken lexicographically.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Phantom Thief GangsanDecide whether a thief can collect all jewels and end with zero trackers by repeatedly walking whole rows or columns, never re-entering a row or column after stealing a plain jewel.Hard8GraphSimulation+2No attempts yet1s128 MBJudgeable
Ladder ManipulationGiven a ladder with N vertical lines, H rows, and M existing rungs, find the minimum number of rungs to add so every walk from column i ends at column i, or report -1 if more than 3.Hard8BacktrackingBrute force+2No attempts yet2s512 MBJudgeable
Getting a Jump on CrimeGiven building heights on a grid, find the minimum number of jumps to reach each roof, where a jump is valid only if its parabola clears every building between the two roofs.Hard8GraphBFS+2No attempts yet2s1024 MBJudgeable
Go with the FlowChoose a line width for justified monospaced text, then find the longest run of spaces that drifts by at most one column per line, and report the best width and length.Hard8Brute forceString+2No attempts yet12s1024 MBJudgeable
Panda PreserveGiven a simple polygon and receivers at its vertices with a common radius, find the smallest radius whose union of disks covers the whole polygon.Hard8GeometryBinary search+2No attempts yet10s1024 MBJudgeable
Single Cut of FailureWires cross a rectangle between boundary sides; find the fewest straight cuts connecting different sides that cross every wire, and output the lexicographically smallest such cut.Hard8GeometrySorting+2No attempts yet6s1024 MBJudgeable
Out of SortsGiven an array, simulate a hybrid of quicksort and bubble sort that repeatedly bubbles until partition points appear, then splits, and report the total work counter.Hard8SortingSimulation+2No attempts yet2s512 MBJudgeable
Out of SortsGiven an array, count how many times the outer loop of a forward-backward bubble sort variant runs before the array becomes sorted.Hard8SortingMath+2No attempts yet2s512 MBJudgeable
Multiplayer MooGiven an N x N grid of cow IDs, find the largest connected region of one ID and the largest region formed by two IDs together.Hard8DFSGraph+2No attempts yet2s512 MBJudgeable
Yut NoriModel Yut Nori movement on four board routes and apply carrying, capturing and exit rules after each throw.Hard8ImplementationSimulation+1No attempts yet1s1024 MBJudgeable
ParticlesGiven firing times and speeds of N particles from each of two facing accelerators, report the first K collisions between opposite kinds in chronological order.Hard8SortingTwo pointers+2No attempts yet2s512 MBJudgeable
CamelConstruct a closed knight-like tour for a jumping camel piece on an N x N board where N is a multiple of 5, printing the visit order or NO.Hard8GreedyImplementation+2No attempts yet2s512 MBJudgeable
System CallChoose one buffer size K for all files to minimize sum over files of ceil(F_i/K) times (T+K).Hard8MathNumber theory+2No attempts yet1s512 MBJudgeable
Non-Interactive Guessing NumberGiven N, K, and Theodora's answer string, output guess values that follow the rules, or -1 if impossible.Hard8Binary searchGreedy+2No attempts yet2s512 MBJudgeable
Random Number GeneratorGiven how many values from 1 to N have been seen zero or one time, find the expected number of draws until every value appears at least twice.Hard8ProbabilityDynamic programming+2No attempts yet2s512 MBJudgeable
PermutationGiven a permutation P and queries K, find the exponent T such that P^T is the K-th smallest among P^1 through P^(M-1) in lexicographic order.Hard8MathCombinatorics+2No attempts yet2s512 MBJudgeable
Mysterious ArrayCount permutations of 1..N consistent with Q range-minimum constraints, modulo 1e9+7, with contradictions giving 0.Hard8CombinatoricsSorting+2No attempts yet2s512 MBJudgeable
Turf WarsEach gang owns disjoint axis-aligned rectangles; pick exactly one rectangle to drop per gang so that no two kept rectangles from different gangs overlap, and report whether this is possible.Hard8GeometryBrute force+2No attempts yet2s512 MBJudgeable
Full HouseKnowing only how many cards were removed from a 52-card deck, find the minimum and maximum number of disjoint full houses (3 of one rank plus 2 of another) that can be formed from the remaining cards.Hard8CombinatoricsGreedy+2No attempts yet2s512 MBJudgeable
Matrix MultiplicationFor each prefix of n matrices, decide whether some multiplication order is valid, and if so report the largest possible area of the final product.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Kakao MoneyGiven a log of deposits and withdrawals with resulting balances, find a minimum charge unit M that is consistent with every withdrawal, or report that none exists.Hard8MathNumber theory+2No attempts yet5s256 MBJudgeable
Magnet ToyGiven a simple graph, decide whether its vertices can be removed one by one so that each removed vertex's remaining neighbors form a clique, and output the order if possible.Hard8GraphImplementation+2No attempts yet1.5s256 MBJudgeable
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.Hard8String matchingHash map+2No attempts yet2s32 MBJudgeable
Playoff by all the teamsCount the ways to fill in the unplayed matches of a round-robin tournament so that every team ends with the same number of wins.Hard8Brute forceBacktracking+2No attempts yet2s512 MBJudgeable
Flashing FluorescentsGiven up to 16 initial light states, find the earliest time at which all lights can be simultaneously on, where each button press sends a delayed toggle wave down the line and overlapping waves cancel.Hard8BFSBit manipulation+2No attempts yet2s512 MBJudgeable
Word ClockPlace n distinct words left to right on an h by w grid where words may share letters, or report that no placement exists.Hard8BacktrackingImplementation+2No attempts yet2s512 MBJudgeable
Battle RoyaleFind the shortest path between two points inside a circle while staying outside an inner red circle, touching boundaries only.Hard8GeometryMath+2No attempts yet2s512 MBJudgeable
Grievous Loss of DataGiven the clash graph of N interval lectures, find the minimum number of halls, which equals the chromatic number guaranteed realizable by intervals.Hard8GraphIntervals+2No attempts yet6s512 MBJudgeable
Injecting DNAFor every suffix of a string, compute its toxicity from the number of out-of-order suffix pairs, then output the length of the suffix with the largest effectiveness.Hard8StringSorting+2No attempts yet2s512 MBJudgeable
I'm a FanFind the smallest CCW rotation angle whose swept orbit of a star-shaped polygon around the origin is a full disk.Hard8GeometryMath+2No attempts yet2s512 MBJudgeable
Ttururu TturuCount self-avoiding walks of length 10 on an R x C grid whose cell contents read exactly "ttururu tturu" (the 5-letter chorus "뚜루루뚜루" written row-wise twice).Hard8DFSBrute force+2No attempts yet0.5s512 MBJudgeable
Peace SignFind the similarity transform (translation, rotation, uniform scale) of the first segment set that matches the most segments of the second set, counting exact matches.Hard8GeometryHash map+2No attempts yet2s512 MBJudgeable
Coloring RoadsColor every edge on a root path with a given color and then count colors used on exactly m edges, answering Q updates online.Hard8TreeSegment tree+2No attempts yet4s1024 MBJudgeable
Balcony RepairsGiven a huge R by C grid with at most 1000 blocked cells, place horizontal dominoes on free cells to maximize the count, then report that maximum and the number of ways modulo 1e9+7.Hard8Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
LazinessCut a bar of total length into given pieces with cut cost xy and minimize total cost; the cost is fixed at (sum of squares differences)/2, so just read the lengths.Hard8MathGreedy+1No attempts yet1s512 MBJudgeable
Small NumbersGiven positive integers a and b, reduce their sum using common-divisor divisions and factor moves between them. Report the minimum sum and one minimizing pair.Hard8Number theoryMath+2No attempts yet2s512 MBJudgeable
Folding the FigureGiven a connected polyomino of n cells that results from folding a k-cell polyomino along one grid line, reconstruct any valid original k-cell figure and the fold line.Hard8ImplementationGeometry+2No attempts yet2s512 MBJudgeable
Cosmetic SurveyGiven n evaluators' ranked preference lists over m cosmetics, build the pairwise strict-preference counts and find every cosmetic X with S(X,Y) >= S(Y,X) for all Y, where S is the widest-path bottleneck strength.Hard8GraphShortest path+2No attempts yet2s512 MBJudgeable
ParenthesesClassify a C arithmetic expression as error, proper, or improper depending on validity and the minimality of its parentheses.Hard8StackRecursion+2No attempts yet1s512 MBJudgeable
Secret CodeFind the probability of three uniformly timed agents meeting pairwise through their fixed waiting windows, then print the scenario indices sorted by that probability.Hard8CombinatoricsGeometry+2No attempts yet1s512 MBJudgeable
TV Show GameAssign each of k lamps red or blue so that every one of n triples of color guesses has at least two matches, or report impossible.Hard8Dynamic programmingBrute force+2No attempts yet1s512 MBJudgeable
Prime Tree - 5Assign labels 1 to n to a tree's vertices so that as few edges as possible join two labels sharing a common divisor.Hard8GreedyNumber theory+2No attempts yet10s512 MBJudgeable
A/B - 3Given A and B with up to 10000 digits (possibly negative), compute the quotient and nonnegative remainder of A divided by B.Hard8MathImplementation+2No attempts yet0.5s512 MBJudgeable
Slackline AdventureCount unordered pairs of grid trees at distance in [L, R] whose line segment passes through no other tree, using visible lattice points and inclusion-exclusion over strip indices.Hard8MathNumber theory+2No attempts yet2s512 MBJudgeable
Modified SATGiven a CNF formula whose clauses each have at most 3 literals, decide whether there is an assignment with exactly 1 or exactly 3 true literals per clause, and print the lexicographically largest such assignment.Hard8Dynamic programmingGreedy+1No attempts yet2s512 MBJudgeable
Maple Leaf StoryBind n skills of 2n to n keys so maximum quests each needing k skills all bound can be cleared. n <= 10, m <= 100.Hard8Brute forceCombinatorics+2No attempts yet1s256 MBJudgeable
decryptQuery a black-box encoder up to 320 times to recover three secret seeds of a linear recurrence and a secret byte permutation.Hard8Bit manipulationMath+2No attempts yet1s64 MBJudgeable
Pikachu's Hard ProblemUse Stewart's theorem on isosceles ABC with equal legs N to prove F(i) = N^2, so the answer for any K points is floor(K*N^2).Hard8MathImplementationNo attempts yet1s512 MBJudgeable
Pie Max FlowGiven a wheel of N spokes from vertex 0 with capacities A and a rim cycle with capacities B, compute each sink's max flow from 0 and output their sum.Hard8GraphShortest path+2No attempts yet1s256 MBJudgeable
Pixel TrianglesGiven up to four million right isosceles triangles on a 2000x2000 grid, count the total number of grid cells covered by at least one triangle.Hard8Prefix sumMatrix+2No attempts yet2s512 MBJudgeable
Go Make It CompleteGiven a simple graph, find the largest k such that some ordering of the missing edges, adding a pair when its current endpoint degrees sum to at least k, still yields the complete graph.Hard8GraphGreedy+2No attempts yet1s512 MBJudgeable