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,013 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
ParkingGiven a rooted tree garage with occupied rooms, find the minimum number of car pushes to clear the path from room P to the exit root, or report impossibility.Hard8TreeGreedy+1No attempts yet1s128 MBJudgeable
TrafficGiven a planar graph of junctions on an island with one-way and two-way streets, count for each western-side junction how many eastern-side junctions it can reach, exploiting planarity and geometric structure since streets cannot cross.Hard8GraphDFS+1No attempts yet5s128 MBJudgeable
Racing Car TrailFor each empty cell in a grid, determine whether the first or second player wins a Tron-style trail game under perfect play, treated as a classic maximum matching / Sprague-Grundy style graph game.Hard8GraphDFS+1No attempts yet5s128 MBJudgeable
JourneySimulate a robot following recursive turtle-graphics functions with possible infinite recursion or unbounded movement, and output the maximum Manhattan distance from origin or detect Infinity.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Exclusive AccessGiven two threads of branching pseudo-code over three shared bits, decide whether every legal schedule satisfies mutual exclusion, deadlock freedom, and starvation freedom.Hard8GraphBFS+2No attempts yet2s128 MBJudgeable
BeehivesGiven a graph, find the smallest set of at least two vertices such that the induced subgraph is 2-edge-connected (no bridge disconnects the hive trees).Hard8GraphUnion-find+1No attempts yet2s128 MBJudgeable
Digits on the FloorGiven bar segments on a plane, reconstruct their connection graph with signed right-angle joints and count how many of each seven-segment-style digit shape (0-9) appears, ignoring shapes nested inside larger ones.Hard8GraphGeometry+2No attempts yet2s128 MBJudgeable
Snake CubeGiven a snake cube flattened on a 15x15 grid as 27 labelled cells, fold it back into a 3x3x3 cube and print the lexicographically smallest of all valid layer arrangements.Hard8BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Ninja AssignmentChoose a manager and up to budget many ninjas from the manager's subtree, possibly passing through unassigned ninjas, to maximize assigned count times the manager's leadership.Hard8TreeDFS+2No attempts yet1s256 MBJudgeable
PatrolBuild K (1 or 2) unit-length shortcuts in a tree so that the shortest closed walk from village 1 covering every edge exactly as required is minimized.Hard8TreeDynamic programming+2No attempts yet1s64 MBJudgeable
Stake Your ClaimOn an n by n board with 1 to 10 empty squares, find the current player's optimal move and final score difference under optimal play.Hard8Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
Paper RouteWith N+1 nodes and exactly N roads, find the cheapest closed walk from node 0 covering all addresses, then add the campus travel cost from wherever you end.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
PipesGiven a grid of pipe tiles that may be rotated by multiples of 90 degrees, decide whether the tiles can be oriented so that every internal border edge is covered by lines on both sides or neither side.Hard8BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Rotate to RootGiven a binary tree, compute the height of the tree after each node is rotated to the root one at a time.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
Mining Your Own BusinessFor each connected mine graph, find the minimum number of escape shafts so that after any single junction collapse every survivor reaches a shaft, and count the ways to place that minimum.Hard8GraphDFS+2No attempts yet5s128 MBJudgeable
Structural EquivalenceGiven recursive type definitions with aliases and structs, group type names into the smallest set of lines where each line holds names that are structurally equivalent after full unfolding.Hard8Union-findGraph+2No attempts yet1s128 MBJudgeable
TreequivalenceGiven two textual tree notations, decide whether they describe the same unrooted planar drawing, allowing any root and cyclic order around each vertex.Hard8TreeHash map+2No attempts yet1s128 MBJudgeable
CatenymsFind the lexicographically smallest ordering of dictionary words where each word's last letter equals the next word's first letter, using every word once.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Su-domino-kuComplete a 9x9 Sudoku grid in which 36 dominoes cover the empty cells and every distinct digit pair appears as exactly one domino.Hard8BacktrackingDFS+2No attempts yet2s128 MBJudgeable
Laser Beam ReflectionsWith up to five mirrors and fewer than six reflections on the shortest path, compute the length of the generator-to-target path, rounding to three decimals.Hard8GeometryBrute force+1No attempts yet2s128 MBJudgeable
Dr. Podboq, or: How We Became AsymmetricRead a binary tree of cells, define each cell's left-right similarity by shared subtree shapes up to child swaps, then reorder children by asymmetry and print the normalized tree.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
Flight PlanningGiven a tree, delete one edge and add one edge so the result is a tree with the smallest possible diameter.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
The Rotation GameGiven a 24-cell board, find the shortest sequence of the eight line-rotation moves that makes the eight center cells show the same symbol.Hard8DFSBrute force+2No attempts yet1s128 MBJudgeable
Safety PrecautionsGiven a DAG where each node fails only after at least t dependencies have failed, choose nodes to protect so node n never fails, minimizing protection cost.Hard8Dynamic programmingGraph+2No attempts yet1s128 MBJudgeable
Circle of FriendsFor each queried node in an undirected graph, find the largest k-core containing it, then output the largest connected component of that core with its members sorted.Hard8GraphImplementation+2No attempts yet1s128 MBJudgeable
Fan GroupsGiven a directed graph and which streets saw fights, output the lexicographically smallest group ordering consistent with the marked fights, or -1.Hard8GraphTopological sort+2No attempts yet1s128 MBJudgeable
Crossing Thin IceGiven an m by n grid of ice cells, find the longest path that starts anywhere and only steps onto unbroken ice, breaking each visited cell.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Hedge MazesFor each query (S,T) decide whether the undirected graph has exactly one simple path between S and T, and print Y or N per query.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Optical FiberGiven a tree of cities, each with up to 50 candidate router sites, pick one site per city to minimize the sum of Euclidean edge lengths.Hard8Dynamic programmingTree+2No attempts yet1s128 MBJudgeable
Pahom on WaterDecide whether Pahom can travel from the red pad to the violet pad and back, stepping only to strictly higher frequencies outbound and strictly lower ones inbound, with each non-red pad vanishing after he leaves it.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
RaceGiven a weighted tree, find a path of total length exactly K that uses the fewest edges, or report -1 if none exists.Hard8TreeDivide and conquer+2No attempts yet3s256 MBJudgeable
Balanced TreesGiven a tree whose nodes are labeled with parentheses, find the maximum nesting depth over all paths that spell a balanced parenthesis string.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
Junkyu and the ApplesOn a 5x5 grid with K blocked cells (K even, up to 22), count the ways two harvesters starting at opposite corners can each tour all open cells and meet at the end.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
Farm ManagementA tree of N farms gets path updates that add 1 to every edge on a path, plus path queries that sum edge values on a path; process M operations online.Hard8TreeSegment tree+2No attempts yet1s128 MBJudgeable
The Continental CowngressEach of M cows casts yes/no votes on two distinct bills, and every cow must win at least one vote; decide for each bill whether it passes in all valid outcomes, fails in all, or varies.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Cow TelephonesGiven a tree with cows at its leaves and vertex capacity K plus unit edge capacity, find the maximum number of disjoint leaf-to-leaf conversation paths.Hard8TreeDynamic programming+2No attempts yet1s128 MBJudgeable
Winning CheckersFind the lexicographically smallest sequence of diagonal jumps by which a single king captures every opponent checker on an N x N board, or report that none exists.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
CheckersOn an N x N board, decide whether one king can capture every opponent checker in a single move of consecutive diagonal jumps, and print the unique landing sequence if so.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
Earthquake DamageGiven a graph and reports that certain damaged pastures cannot reach the barn, find the minimum total number of pastures that cannot return to the barn.Hard8GraphUnion-find+2No attempts yet1s128 MBJudgeable
TreasureGiven a connected graph with N nodes and N edges and max degree 4, count the distinct rooted versions of the graph up to isomorphism, where each root is a non-4-degree node.Hard8GraphTrie+2No attempts yet1s128 MBJudgeable
Rectangular PaintingGiven a nesting tree of rectangles and photo leaf sizes, orient each sibling group horizontally or vertically to minimize the root rectangle area.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
NurikabeSolve Nurikabe puzzles on grids up to 9x9 by coloring cells black or white so all six connectivity and counting rules hold.Hard8BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Quelling BladeGiven a tree of weapon prerequisites with costs and benefits, find a buying order that reaches the root in minimum time while maximizing the sum over time of owned benefit.Hard8GreedyDFS+2No attempts yet1s128 MBJudgeable
Ball MachineSimulate a ball machine on a rooted tree: dropping balls follows a fixed priority path, and removing a ball makes balls above roll down; report resting node or number of moves.Hard8TreeSimulation+2No attempts yet1s128 MBJudgeable
Tracks in the SnowGiven a grid where each tracked cell shows the most recent animal (R or F), find the minimum number of animals that crossed from the top-left to the bottom-right.Hard8GraphGreedy+2No attempts yet2s1300 MBJudgeable
Optimal ProgramsFor each set of input/output pairs, find the shortest stack-machine program of at most 10 commands made of ADD, SUB, MUL, DIV, and DUP, with lexicographically smallest ties.Hard8Brute forceDFS+2No attempts yet1s128 MBJudgeable
Fold-up PatternsGiven a planar net of unit squares with specified fold directions on shared edges, determine whether folding yields a closed surface of a solid and report its volume.Hard8GeometryGraph+2No attempts yet1s128 MBJudgeable
Tin CutterGiven up to 100 axis-parallel cuts inside a plate, count how many holes (closed regions not touching the plate border) remain after all cuts are made.Hard8GeometryGraph+2No attempts yet1s128 MBJudgeable
Addition ChainsFor each n up to 100, find a shortest addition chain ending at n and print the lexicographically smallest among all shortest ones.Hard8DFSBacktracking+2No attempts yet1s256 MBJudgeable
Letter LiesCount the number of length-L paths from a greeting sentence to a closing sentence in a directed graph whose successor rules guarantee no sentence repeats.Hard8Dynamic programmingGraph+2No attempts yet3s128 MBJudgeable
AgentsGiven a graph of dislikes where at most three agents touch everyone else, decide whether the vertices 3-color into at most three independent sets and output the lexicographically smallest coloring.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
BoatherdsGiven a weighted tree and up to 100 queries, decide for each target value whether some pair of vertices has a path cost exactly equal to it.Hard8Divide and conquerTree+2No attempts yet1s128 MBJudgeable
Nutrient TreeGiven a binary tree whose leaves produce nutrients and whose edges have capacity (1+w)^2 after spending w agents, distribute X agents over edges and leaves to maximize the flow reaching the root.Hard8TreeDynamic programming+2No attempts yet2s512 MBJudgeable
CubeGiven an n by n by n grid of letters, decide whether the connected same-letter pieces can be pulled apart without cutting, meaning no single piece separates the cube.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Cow Ski AreaBuild the directed graph where each square has edges to same-or-lower neighbors, then find the minimum number of bidirectional edges to add so the whole graph becomes strongly connected.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
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.Hard8String matchingTrie+2No attempts yet1s128 MBJudgeable
Winter RoadsAfter a series of road capacity updates, answer queries asking whether two landmarks stay connected using only roads of capacity at least w.Hard8GraphUnion-find+2No attempts yet10s128 MBJudgeable
Can of WormsFor each can, count how many cans explode when it is shot, following the chain reaction where each blast hits cans within its radius.Hard8SortingBinary search+2No attempts yet3s128 MBJudgeable
UnterA connected graph with N houses and exactly N edges (one cycle) must answer up to 1e6 shortest distance queries.Hard8GraphDFS+2No attempts yet1s1024 MBJudgeable
ThievesGiven a tree with K robbed cities, block some cities at cost a_i so that the reachable set of cities from the robbed nodes through unblocked cities is minimized in total cost (blocking plus M per searched city).Hard8TreeDynamic programming+2No attempts yet1s1024 MBJudgeable
Fixing CodesGiven a prefix-free code and a new binary string, find the minimum total number of bits to append so the whole multiset becomes prefix-free again.Hard8GreedyTree+2No attempts yet1s128 MBJudgeable
FarmlandGiven a planar graph of farming regions, count the proper regions bounded by a simple cycle with no interior vertices or edges and exactly k boundary edges.Hard8GraphGeometry+2No attempts yet1s128 MBJudgeable
Vote-Value Disparity 1Partition N connected provinces into K connected districts to minimize the ratio between the most and least powerful single vote.Hard8GraphBinary search+1No attempts yet1s128 MBJudgeable
SynchronizationGiven a tree whose edges toggle on and off over time, report how many distinct information pieces each queried server holds at the end.Hard8Union-findDivide and conquer+2No attempts yet8s128 MBJudgeable
Tree SimilarityGiven two ordered rooted trees, find the minimum number of node relabel, delete, and insert operations to turn the first tree into the second.Hard8Dynamic programmingTree+2No attempts yet3s128 MBJudgeable
City DrivingIn a connected graph with N nodes and N edges, answer many shortest-path queries between pairs of nodes.Hard8TreeGraph+2No attempts yet1s128 MBJudgeable
Game RiggingGiven a set of players, a subset of friends, and known guaranteed match-up outcomes, decide whether a friend can be made to win the elimination tournament.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Highway ConstructionChoose a path in a weighted tree so that the maximum distance from any node to the path is minimized, and report that distance.Hard8TreeBinary search+2No attempts yet1s128 MBJudgeable
A Reasonable RankingGiven a complete tournament's win-loss table, find the lexicographically smallest ranking in which each higher player is connected to each lower player through a chain of intermediate wins.Hard8GraphTopological sort+2No attempts yet1s128 MBJudgeable
One-Way RoadsDecide whether the undirected streets of a graph can all be oriented so that each required ordered pair stays reachable from the first to the second.Hard8GraphDFS+2No attempts yet2s64 MBJudgeable
Fool GameGiven a trump suit and both hands, find the lowest-ranked opening card that forces the defender to take, assuming optimal defense.Hard8Game theoryDFS+2No attempts yet1s128 MBJudgeable
Museum TourGiven a connected graph with max degree 3 and a fixed cyclic door order per room, count starting rooms whose edge-following walk eventually traverses every corridor.Hard8GraphSimulation+2No attempts yet1s512 MBJudgeable
Morphing is funGiven color mutation rules, decide whether every fixed-height cell eventually stops changing color over the nights.Hard8GraphDFS+2No attempts yet1s512 MBJudgeable
Bytean Road RaceGiven a planar south/east DAG from node 1 to node n, answer queries asking whether some monotone path passes through both given crossings.Hard8GraphDFS+2No attempts yet3s64 MBJudgeable
CaveGiven a tree of n nodes, find every k such that the tree splits into k connected parts of equal size.Hard8TreeDFS+2No attempts yet3s256 MBJudgeable
Greedy FarmersAssign each node the smallest Grundy number absent from its neighbors, maximizing the count of nodes that get infinity (-1).Hard8GraphGame theory+2No attempts yet1s128 MBJudgeable
The Curious PrinceFind the shortest path along the surface of a convex polyhedron between two given points.Hard8GeometryShortest path+2No attempts yet1s128 MBJudgeable
Showy Self-DefenseGiven n game states, each with optional A/B moves to other states, decide if for every attacker start there is a distinct defender start that can mirror every move.Hard8GraphGame theory+2No attempts yet10s128 MBJudgeable
Green GameOn a bipartite board where Ann and Billy alternately move a pawn, find all starting fields from which Ann can force the first repeated field's cycle to contain a green field.Hard8Game theoryGraph+2No attempts yet1s128 MBJudgeable
Peaceful CommissionPick exactly one deputy from each of n pairs, avoiding forbidden deputy pairs, and print the lexicographically smallest valid choice or NIE.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
IslandGiven all pairwise shortest tolls among the n seaside triangles, recover the adjacency structure and edge weights of the underlying border tree.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
PolygonsA convex polygon is triangulated, one triangle is black; players alternately cut off an ear triangle, and whoever removes the black triangle wins. Decide if the first player wins.Hard8Game theoryTree+2No attempts yet1s128 MBJudgeable
Step Traversing a TreeGiven a tree on n vertices, find the smallest c such that the vertices can be visited in some order where each consecutive pair is at distance at most c.Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
The PostmanDecide whether a directed graph has an Euler circuit from node 1 that contains each given sequence as a contiguous run of the route.Hard8GraphDFS+1No attempts yet1s128 MBJudgeable
Fire Extinguisher InstallationPlace extinguishers on tree rooms, each covering at most S rooms within distance K, so every room is covered; minimize the count.Hard8TreeGreedy+1No attempts yet1s128 MBJudgeable
DynamiteLight the fuses in exactly m chambers of a tree so that every charge-detonation is covered as early as possible, and report the last detonation time.Hard8TreeBinary search+2No attempts yet2s128 MBJudgeable
InspectionFor each root of a tree, find the minimum time for a tour that inspects every node and returns to the root each time, with no two consecutive trips using the same first edge.Hard8TreeDFS+2No attempts yet5s128 MBJudgeable
Minimalist SecurityEach vertex v loses z(v) officers with 0 <= z(v) <= p(v), and every edge uv must end with exactly p(u)-z(u)+p(v)-z(v) = b(u,v); find the min and max of the total sum of z(v), or report impossible.Hard8GraphDFS+2No attempts yet4s128 MBJudgeable
Triumphal ArchGiven a tree rooted at town 1, find the minimum number of crews so that each town gets its arch built before the king's first arrival, where the king's walk is unknown.Hard8TreeGreedy+2No attempts yet1s128 MBJudgeable
FuelFind the maximum number of distinct vertices of a tree that can be visited by a walk of length at most m edges.Hard8TreeDFS+1No attempts yet1s128 MBJudgeable
Number of Tree AutomorphismsCount the automorphisms of a tree modulo 1e9+7.Hard8TreeDFS+2No attempts yet5s128 MBJudgeable
FirmProcess hires and queries on a growing rooted tree, counting employees at exact depth offset k below a given node at query time.Hard8TreeDFS+2No attempts yet2s512 MBJudgeable
Termites 2Given a tree with its edges ordered, two players alternately remove an uneaten endpoint of the next edge; report the round the loser is forced and loses, or -1 for a draw.Hard8Game theoryTree+2No attempts yet2s512 MBJudgeable
TramFor each junction, find the greatest common divisor of all cycle lengths reachable from and returning to it, or -1 if no return is possible.Hard8GraphDFS+2No attempts yet2s512 MBJudgeable
CrayfishFor each house, count how many turtles are reachable on a round trip that starts and ends moving backward, where special edges flip the direction of travel.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Bachelor PartyGiven a tree and one-way tickets, decide if a vertex-simple walk from s to t uses every ticket exactly once.Hard8GraphDFS+1No attempts yet1s128 MBJudgeable
The Company ChoirGiven a rooted tree where each node has a pitch and a distinct ability score, answer queries that ask for the k highest-ability subordinates of a node whose pitch lies in a range [a,b].Hard8TreeDFS+2No attempts yet1s128 MBJudgeable
RacesGiven a tree and a set of allowed endpoints, find the maximum number of vertex-disjoint paths whose endpoints both lie in the allowed set.Hard8TreeDynamic programming+2No attempts yet1s128 MBJudgeable
SpidersGiven two planar triangulations built by repeatedly attaching a new vertex to an outer edge, decide whether they are isomorphic as graphs.Hard8GraphTree+2No attempts yet1s128 MBJudgeable
Autumn TripDecide whether an undirected graph contains a simple cycle that visits an even number of vertices.Hard8GraphDFSNo attempts yet1s128 MBJudgeable