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
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| 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. | Hard8 | TreeGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+1 | No attempts yet | 5s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+1 | No attempts yet | 5s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphBFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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). | Hard8 | GraphUnion-find+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Hard8 | GraphGeometry+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Hard8 | BacktrackingDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Hard8 | TreeDynamic programming+2 | No attempts yet | 1s | 64 MB | Judgeable |
| 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. | Hard8 | Game theoryBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | BacktrackingDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rotate to RootGiven a binary tree, compute the height of the tree after each node is rotated to the root one at a time. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 5s | 128 MB | Judgeable |
| 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. | Hard8 | Union-findGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TreequivalenceGiven two textual tree notations, decide whether they describe the same unrooted planar drawing, allowing any root and cyclic order around each vertex. | Hard8 | TreeHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | BacktrackingDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Hard8 | GeometryBrute force+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Flight PlanningGiven a tree, delete one edge and add one edge so the result is a tree with the smallest possible diameter. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | DFSBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fan GroupsGiven a directed graph and which streets saw fights, output the lexicographically smallest group ordering consistent with the marked fights, or -1. | Hard8 | GraphTopological sort+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RaceGiven a weighted tree, find a path of total length exactly K that uses the fewest edges, or report -1 if none exists. | Hard8 | TreeDivide and conquer+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Balanced TreesGiven a tree whose nodes are labeled with parentheses, find the maximum nesting depth over all paths that spell a balanced parenthesis string. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | DFSBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeSegment tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | DFSBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | DFSBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphUnion-find+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rectangular PaintingGiven a nesting tree of rectangles and photo leaf sizes, orient each sibling group horizontally or vertically to minimize the root rectangle area. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| NurikabeSolve Nurikabe puzzles on grids up to 9x9 by coloring cells black or white so all six connectivity and counting rules hold. | Hard8 | BacktrackingDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GreedyDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphGreedy+2 | No attempts yet | 2s | 1300 MB | Judgeable |
| 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. | Hard8 | Brute forceDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GeometryGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GeometryGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Addition ChainsFor each n up to 100, find a shortest addition chain ending at n and print the lexicographically smallest among all shortest ones. | Hard8 | DFSBacktracking+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingGraph+2 | No attempts yet | 3s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Divide and conquerTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+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 |
| Winter RoadsAfter a series of road capacity updates, answer queries asking whether two landmarks stay connected using only roads of capacity at least w. | Hard8 | GraphUnion-find+2 | No attempts yet | 10s | 128 MB | Judgeable |
| 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. | Hard8 | SortingBinary search+2 | No attempts yet | 3s | 128 MB | Judgeable |
| UnterA connected graph with N houses and exactly N edges (one cycle) must answer up to 1e6 shortest distance queries. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| 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). | Hard8 | TreeDynamic programming+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| 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. | Hard8 | GreedyTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Vote-Value Disparity 1Partition N connected provinces into K connected districts to minimize the ratio between the most and least powerful single vote. | Hard8 | GraphBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| SynchronizationGiven a tree whose edges toggle on and off over time, report how many distinct information pieces each queried server holds at the end. | Hard8 | Union-findDivide and conquer+2 | No attempts yet | 8s | 128 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 3s | 128 MB | Judgeable |
| City DrivingIn a connected graph with N nodes and N edges, answer many shortest-path queries between pairs of nodes. | Hard8 | TreeGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphTopological sort+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 64 MB | Judgeable |
| Fool GameGiven a trump suit and both hands, find the lowest-ranked opening card that forces the defender to take, assuming optimal defense. | Hard8 | Game theoryDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphSimulation+2 | No attempts yet | 1s | 512 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 |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 3s | 64 MB | Judgeable |
| CaveGiven a tree of n nodes, find every k such that the tree splits into k connected parts of equal size. | Hard8 | TreeDFS+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Greedy FarmersAssign each node the smallest Grundy number absent from its neighbors, maximizing the count of nodes that get infinity (-1). | Hard8 | GraphGame theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Curious PrinceFind the shortest path along the surface of a convex polyhedron between two given points. | Hard8 | GeometryShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphGame theory+2 | No attempts yet | 10s | 128 MB | Judgeable |
| 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. | Hard8 | Game theoryGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Peaceful CommissionPick exactly one deputy from each of n pairs, avoiding forbidden deputy pairs, and print the lexicographically smallest valid choice or NIE. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| IslandGiven all pairwise shortest tolls among the n seaside triangles, recover the adjacency structure and edge weights of the underlying border tree. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Game theoryTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Fire Extinguisher InstallationPlace extinguishers on tree rooms, each covering at most S rooms within distance K, so every room is covered; minimize the count. | Hard8 | TreeGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeBinary search+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Hard8 | TreeDFS+2 | No attempts yet | 5s | 128 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 4s | 128 MB | Judgeable |
| 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. | Hard8 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FuelFind the maximum number of distinct vertices of a tree that can be visited by a walk of length at most m edges. | Hard8 | TreeDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Number of Tree AutomorphismsCount the automorphisms of a tree modulo 1e9+7. | Hard8 | TreeDFS+2 | No attempts yet | 5s | 128 MB | Judgeable |
| FirmProcess hires and queries on a growing rooted tree, counting employees at exact depth offset k below a given node at query time. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | Game theoryTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bachelor PartyGiven a tree and one-way tickets, decide if a vertex-simple walk from s to t uses every ticket exactly once. | Hard8 | GraphDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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]. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SpidersGiven two planar triangulations built by repeatedly attaching a new vertex to an outer edge, decide whether they are isomorphic as graphs. | Hard8 | GraphTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Autumn TripDecide whether an undirected graph contains a simple cycle that visits an even number of vertices. | Hard8 | GraphDFS | No attempts yet | 1s | 128 MB | Judgeable |