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 results14,366 problems
TopicsJudge
GCD SumFor each k from 1 to n, split a multiset of n numbers into k nonempty groups to maximize the sum of the groups' gcds. n is up to 500000 and each value up to 10^12.Hard9Number theoryGreedy+2No attempts yet2s1024 MBJudgeable
SkiingFind the shortest polygonal path from S down to F that crosses n horizontal gates in top-to-bottom order, and output its breakpoints.Hard9GeometryGreedy+2No attempts yet1s1024 MBJudgeable
Restaurant BribesGiven a friendship graph and a list of k people to bribe, choose a real bribe for each so the total restaurant revenue minus bribe money is maximized, and print the answer as an exact reduced fraction.Hard9GraphMath+2No attempts yet2s512 MBJudgeable
One-Way StreetsGiven an undirected multigraph and required reachable pairs, decide for each edge whether every valid orientation matches the input direction (R), the reverse (L), or both are possible (B).Hard9GraphDFS+2No attempts yet3s256 MBJudgeable
Intrinsic IntervalFor each query range in a permutation, find the smallest subarray containing it whose values form a set of consecutive integers.Hard9Segment treeStack+1No attempts yet3s512 MBJudgeable
Lunar LandscapeCompute the total area covered by axis-aligned squares and 45-degree rotated squares, counting overlaps once.Hard9GeometrySorting+1No attempts yet2s512 MBJudgeable
Journey from Petersburg to MoscowFind the minimum cost path from city 1 to city n where only the k most expensive edges of the path are paid for, or all edges if the path has k or fewer.Hard9GraphShortest path+2No attempts yet3s512 MBJudgeable
Laminar FamilyGiven an undirected tree and f vertex sets, each a simple path, decide whether the family of paths is laminar.Hard9TreeDFS+2No attempts yet2s512 MBJudgeable
ToysCount the number of distinct toys formed by strings joining n evenly spaced clamps on one disc to m on another, where rotating each disc independently gives the same toy, modulo 1,000,000,007.Hard9CombinatoricsNumber theory+2No attempts yet2s512 MBJudgeable
Workbook AlgorithmsCount the number of undirected graphs X on N vertices whose number of permutations P satisfying G(P)=X lies between l and r, modulo 1e9+7.Hard9CombinatoricsGraph+2No attempts yet1s512 MBJudgeable
Secret AgentGiven a planar straight-line graph (castle walls) where crossing a wall costs its height, find the minimum cost to travel between successive query points, starting from infinity.Hard9GraphGeometry+2No attempts yet2s512 MBJudgeable
GarageMaintain a sequence under point updates, and for each range query count subarrays whose elements share a common divisor greater than 1.Hard9Segment treeNumber theory+2No attempts yet4s256 MBJudgeable
Counting CyclesA connected undirected graph with n vertices and at most n+15 edges is given; count all simple cycles, where a simple cycle is a connected subgraph with every degree exactly two.Hard9GraphDFS+2No attempts yet4s512 MBJudgeable
LeadersAnimals in a circle alternately raise a running number by 1 to K; whoever is forced to say M loses, and we find the winner of every start position.Hard9Game theoryDynamic programming+2No attempts yet3s512 MBJudgeable
Disco Dance DebacleGiven a grid where some cells are unlit (unions of rectangles), find the fewest cell states to flip so that a set of alternating row-column dances can cover all lit cells, each dance starting and ending on the same cell with different first and last feet.Hard9GraphGreedy+2No attempts yet5s512 MBJudgeable
Imelda's Shopping SpreeMaintain a sequence of prices under range-add and range-reverse, and after each update output the number of contiguous segments whose values are strictly increasing.Hard9Segment treeArray+2No attempts yet5s512 MBJudgeable
Majestic Gourmet UniversityGiven proposed FC and IC lab slots with teacher conflicts, seat limits, and timing rules, choose a valid set of labs using the fewest distinct starting days.Hard9GraphBFS+2No attempts yet2s512 MBJudgeable
KabobsCount length-K strings over the given alphabet that satisfy all substring-implication rules of the form b>e, modulo 10^7.Hard9Dynamic programmingString+2No attempts yet5s512 MBJudgeable
Vera and Love TrianglesFor each pair of friends, a crush direction is set by the parity of the bit-count of a modular power expression; count cyclic triples.Hard9CombinatoricsNumber theory+2No attempts yet2s256 MBJudgeable
DramaCount the number of valid pyramid colourings of an H by N grid with exactly N black cells, modulo 10^9+7.Hard9CombinatoricsDynamic programming+1No attempts yet2s512 MBJudgeable
Push a BoxGiven a grid with Bessie and a pushable box, decide for each queried cell whether the box can reach it.Hard9GraphBFS+1No attempts yet2s512 MBJudgeable
L-th K-th numberGiven N cards, take the K-th smallest value of every contiguous block of length at least K, then report the L-th smallest of all those values.Hard9Binary searchArray+2No attempts yet2s512 MBJudgeable
GardenerMaintain N gardens under plantings, range deletions of plants taller than h, and range count queries, all with time-dependent growth.Hard9Segment treeBinary search+2No attempts yet3s128 MBJudgeable
Revenge of the Broken DoorAn adversary hides one edge under construction; the traveler learns about an edge only upon reaching its endpoint and must minimize the worst-case distance from S to T.Hard9GraphShortest path+2No attempts yet10s512 MBJudgeable
Revenge of the Endless BFSDecide whether a buggy BFS that forgets visited vertices ever terminates on a given directed graph, and if so output the loop count modulo 1e9+7.Hard9GraphBFS+2No attempts yet2s512 MBJudgeable
Conveyor BeltAfter each of Q delivery requests (a, b, p) is added, report the minimum time to finish all tasks, given plates arrive one per second and each plate carries one product.Hard9MathGreedy+2No attempts yet2s512 MBJudgeable
Pipe Fitter and the Fierce DogsIn a grid where every odd row and column holds a house, cover all houses with downhill chains, minimizing the cost of pipes through dog blocks, using at most K chains.Hard9Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
Blocks 2Count the ways to tile an N x M rectangle with rotated k x N blocks (k=1..N), modulo 1999, where M can be as large as 10^10.Hard9CombinatoricsDynamic programming+2No attempts yet1s256 MBJudgeable
Stamp PaintingCount the distinct colorings of an N-unit canvas obtainable by stamping K-wide colored stamps so every unit ends up painted, modulo 1e9+7.Hard9Dynamic programmingCombinatorics+1No attempts yet2s512 MBJudgeable
Euclidean NimFor each pair of move sizes p and q and starting pile n, decide which player wins the take-or-add game, or that it draws.Hard9Game theoryMath+1No attempts yet2s512 MBJudgeable
Maximal polygon brightnessGiven a convex polygon and a sequence of vertex deletions, compute after each deletion the largest total length of edges that a single external light point can illuminate.Hard9GeometryDynamic programming+2No attempts yet3s1024 MBJudgeable
Street TreesMaintain a minimum-cost coloring of N vertices with two colors under incremental equality/inequality constraints and point cost updates, reporting the optimum after each operation.Hard9Union-findGraph+2No attempts yet2s256 MBJudgeable
In honor of Taekhee's graduationDeer bounce on a line segment [0,T], each with strength; a statue at x falls when the net force of deer that have reached it exceeds W. Maximize the fall time over x.Hard9MathSimulation+2No attempts yet3s128 MBJudgeable
Want to solve a problem?For given K and C, choose A > 0 to maximize the characters saved by writing K+A repeated K+A times instead of K repeated K times, minus C times A.Hard9String matchingMath+2No attempts yet1s128 MBJudgeable
The Number of SequencesFor a given N and C, find the lexicographically smallest triple (X, Y, Z) such that exactly C ordered N-tuples of 31-bit integers have OR X, AND Y, XOR Z, or report none exists.Hard9Bit manipulationCombinatorics+2No attempts yet1s128 MBJudgeable
Uncrossed Knight's TourGiven an m by n board (m at most 8, n up to 1e15), find the maximum number of squares a closed knight tour can visit without crossing itself.Hard9GreedyDynamic programming+2No attempts yet2s1024 MBJudgeable
TteokpireCount the number of ways to write N as an ordered sequence of one or more positive integers; equivalently, count compositions of N, modulo 1e9+7, for N up to 1e12.Hard9CombinatoricsMath+2No attempts yet1s128 MBJudgeable
General graph matchingGiven an undirected graph with N vertices and M edges, print the size of a maximum matching.Hard9GraphGreedy+2No attempts yet1s128 MBJudgeable
Maximum Weight Matching in a General GraphGiven a weighted undirected graph, find a matching with maximum total edge weight.Hard9GraphGreedy+1No attempts yet2s512 MBJudgeable
New HomeStores of k types each occupy a point and an open year interval; for each (location, year) query, report the maximum over types of the distance to the nearest open store of that type, or -1 if some type is missing.Hard9Segment treeBinary search+2No attempts yet5s1024 MBJudgeable
Circle SelectionProcess circles in decreasing radius order; each chosen circle removes all remaining circles that intersect it, and for every circle you must report which chosen circle eliminated it.Hard9GeometrySorting+2No attempts yet3s1024 MBJudgeable
United States of EurasiaSplit N points sorted by x into at most K contiguous groups, minimizing the largest squared diameter within any group.Hard9Binary searchDynamic programming+2No attempts yet20s1024 MBJudgeable
Voronoi DiagramGiven a connected weighted graph and a set of source vertices, assign every point on every edge to its nearest source (smallest index on ties) and report the total length each source owns.Hard9GraphShortest path+2No attempts yet2s1024 MBJudgeable
Xtreme NP-hard Problem?!Find the minimum-weight simple path from vertex 1 to vertex n that uses exactly k edges, or report -1; with n, m, k up to 10^6 this is explicitly NP-hard.Hard9GraphShortest path+2No attempts yet5s1024 MBJudgeable
Cryptarithm?!Given three letter strings A+B=C, decide whether some assignment of distinct digits to letters makes the addition valid, columns up to 18 long.Hard9BacktrackingMath+2No attempts yet1s128 MBJudgeable
Travelling MerchantGiven a directed weighted graph and per-market buy/sell prices for K items, find the maximum profit-to-duration ratio of a closed walk trading at most one item at a time, floor it.Hard9GraphShortest path+2No attempts yet2s512 MBJudgeable
Tree EscapeOn a rooted tree where each leaf starts with one piece, players alternately move a piece to its parent and remove it at the root; decide if the first player wins.Hard9Game theoryTree+2No attempts yet2s512 MBJudgeable
SquareFreeGiven n up to 10^18, find the n-th squarefree positive integer using Mobius inversion and binary search.Hard9MathNumber theory+2No attempts yet5s512 MBJudgeable
Fibonacci Digit CountCount occurrences of the substring "11" within the first N characters of the infinite string formed by writing 1, 2, 3, ... in Fibonacci (Zeckendorf) representation.Hard9MathDynamic programming+2No attempts yet2s1024 MBJudgeable
f and gCompute g(T,k)=sum_{x=0}^{T} sum_i (x+a_i)^k mod 1e9+7 for every k from 0 to K, given N up to 1e5, K up to 5e4, T up to 1e18.Hard10MathCombinatorics+2No attempts yet3s512 MBJudgeable
Find Marble Positions and VelocitiesReconstruct each marble's starting x-coordinate and constant velocity from N+1 unordered snapshots of N linearly moving marbles.Hard10MathCombinatorics+2No attempts yet2s128 MBJudgeable
Tree and Queries 20Maintain a dynamic forest with link/cut and weighted edges, supporting toggling a vertex weight and querying the minimum weighted sum of tree distances from any vertex, with encrypted vertex indices.Hard10TreeSegment tree+1No attempts yet5s512 MBJudgeable
Coalescing ContinentsGiven K rectangles with total area 25 on a 20x20 grid, decide if they can be translated to tile a square, and find the minimum total moves.Hard10Brute forceMath+2No attempts yet1s128 MBJudgeable
CubesCount the orbits of general-purpose chip placements on cube faces under face rotations and cube rearrangement, given a fixed pattern of encoding chips.Hard10CombinatoricsMath+2No attempts yet1s128 MBJudgeable
GeneratorRead an index 0 to 10 and output the exact contents of the matching recovered file gen_i.out from the archive.Hard10ImplementationString+2No attempts yet2s256 MBJudgeable
LogoGiven up to five polyomino patch shapes (each a subset of a 3x3 grid, flippable and rotatable) and up to three grid designs up to 55x5, decide if each design can be tiled exactly by non-overlapping patches and find the minimum patch count, or report NIE.Hard10Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
String Palindrome QueriesMaintain a lowercase string under block moves, reversals, and single-character insertions, answering after each change whether a given substring reads the same forwards and backwards.Hard10StringString matching+1No attempts yet2s256 MBJudgeable
Rational ApproximationUnratedNot classified yetNo attempts yet1s128 MBJudgeable
ZuUnratedNot classified yetNo attempts yet1s256 MBJudgeable
Star Pattern 15UnratedNot classified yetNo attempts yet1s256 MBJudgeable
Star Pattern - 16UnratedNot classified yetNo attempts yet1s256 MBJudgeable
Printing Stars 20UnratedNot classified yetNo attempts yet1s256 MBJudgeable
Star pattern 22UnratedNot classified yetNo attempts yet1s256 MBJudgeable
Project Team Vacation ScheduleUnratedNot classified yetNo attempts yet1s512 MBJudgeable
Maximum edge cost on a tree pathUnratedNot classified yetNo attempts yet2s512 MBJudgeable
Distinct weights on a tree pathUnratedNot classified yetNo attempts yet2s512 MBJudgeable