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 |
|---|---|---|---|---|---|---|
| Maximum weight in a monochromatic componentOn a colored tree, handle color flips, weight updates, and queries for the maximum weight in the monochromatic component containing a vertex. | Medium7 | TreeSegment tree+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Power SupplyGiven a tree whose vertices are supplies or demands and whose edges have capacities, decide if deleting some edges yields subtrees each holding exactly one supply that meets its demands. | Medium7 | TreeDFS+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Countries at WarGiven directed weighted edges between cities, treat mutually reachable cities as zero-cost (same country), then answer shortest path queries. | Medium7 | Shortest pathGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| MegaDamasGiven a checkers-like board with your and opponent pieces, find the maximum number of opponent pieces one capture move can take. | Medium7 | DFSBacktracking+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Critical RouteGiven a directed multigraph where every city reaches the capital, list every road segment whose removal disconnects some city from the capital. | Medium7 | GraphDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Tecle & SomeList every way to split S into terms of at most D digits whose concatenated digits form a path on a phone keypad using each digit at most once. | Medium7 | DFSBacktracking+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Entangled TreeGiven a forest of split nodes, order the leaf labels so each split node's leaves are consecutive, choosing the lexicographically smallest sequence, then answer position queries. | Medium7 | TreeDFS+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Trees and PrimesGiven a tree on N vertices, find the probability that a uniformly random pair of distinct vertices has a prime distance. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Performance ReviewFor each employee, sum t_j over all descendants j whose rank r_j is lower than the employee's rank. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Maximum IslandsGiven an n by m grid of land, water, and cloud cells where clouds may be either, maximize the number of 4-connected land components. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cars on IceCars point in fixed directions and slide out along that direction; find the lexicographically smallest order that pushes every car out without collisions. | Medium7 | Topological sortGraph+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Through a Maze DarklyA planar maze lists each room's neighbors in clockwise order; for each starting room, find the longest wall-following (right-hand rule) closed walk before returning to the start. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sorting with allowed swapsGiven a permutation and allowed swaps, decide if the given pairs can sort it and output the swaps produced by the described leaf-removal rule on the spanning forest. | Medium7 | GraphDFS+2 | No attempts yet | 0.5s | 128 MB | Judgeable |
| Tree and PrimesIn a tree, count pairs of nodes whose path length is prime, and output the probability as a reduced fraction. | Medium7 | TreeDFS+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Explosion at CafebazaarA directed multigraph alternates send and receive rounds from an initial 1-bit packet; count the starting switches whose bit makes some buffer grow without bound. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| BFFs (Large)Each kid points to one BFF; find the largest circular seating where everyone sits next to their BFF. | Medium7 | GraphDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Promotion CountingFor each node of a rooted tree, count descendants whose value is larger than the node's own value. | Medium7 | TreeDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| IliGiven a DAG of two-input OR gates where some gate outputs are measured, determine which remaining gate outputs are forced to a single value across all valid assignments of the wires. | Medium7 | GraphDFS+2 | No attempts yet | 4s | 1024 MB | Judgeable |
| Junoh is top talent!!In a weighted tree, find a simple path with the maximum number of nodes, then among those pick the one with the smallest total edge weight, and report that weight divided by T rounded up. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hiking GwanaksanOn a graph with distinct vertex heights, each hiker at a vertex must move along an edge to a strictly higher neighbor, repeating until stuck; for every start vertex find the longest such strictly increasing path length. | Medium7 | GraphDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Grasshopper RouteGiven a tree and two vertices s and t, construct the specific valid Grasshopper route defined by a recursive rule on the path components. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| AntsEach room of a weighted tree rooted at room 1 holds an ant with limited energy; for every ant, find the closest-to-root room it can reach moving toward room 1. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Treetop WalkwayGiven a weakly connected directed graph, find the minimum number of edges to add so every vertex reaches every other. | Medium7 | GraphGreedy+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Intelligence InfectionFind the minimum number of spies to message so that every non-enemy spy receives the message and no enemy spy does, given a directed contact graph and a set of enemy spies. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Journal EditingGiven theorems that depend on other theorems and multiple possible proofs with costs, find the minimum total cost to prove Theorem 0. | Medium7 | Dynamic programmingGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Gates of uncertaintyGiven a binary tree of two-input NAND gates where some gates may be stuck, count input assignments that make the faulty circuit differ from the fault-free one. | Medium7 | TreeDynamic programming+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| Is-A? Has-A? Who Knows-A?Given is-a and has-a facts between at most 500 classes, apply the four transitivity rules and answer whether each queried relation holds. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Keeping On TrackGiven a tree with n+1 nodes, find the node whose removal splits it worst, then pick the best non-edge to add so the remaining disconnected pairs are minimized. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| UnsatisfyingGiven 2-SAT clauses, find the minimum number of clauses of the form (p_a OR p_b) to add so the whole formula becomes unsatisfiable, or -1. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Grand TestFor each undirected graph, decide whether some pair of vertices admits three routes whose internal vertices and edges are all disjoint. | Medium7 | GraphDFS+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Deck of CardsTwo players alternate playing a card matching the table card in color or value; the first unable to move loses, so find the winner under optimal play. | Medium7 | Game theoryGraph+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Cactus graph edge removalDelete uniformly random edges one at a time from a cactus graph until it disconnects, and output the expected number of deletions to six decimals. | Medium7 | ProbabilityGraph+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Justified JungleGiven a tree with n nodes, find every k such that removing exactly k edges leaves a forest whose connected components all have the same size. | Medium7 | TreeDFS+2 | No attempts yet | 6s | 512 MB | Judgeable |
| KDH, Son of the TyphoonOn a tree where every pair of vertices adds 1 traffic to each path edge, vertices survive independently with probability p; find the expected total traffic. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| HikingOn a bipartite graph of peaks and valleys, two players alternate choosing an unvisited neighbor and the player who cannot move loses; report the winner for every starting peak. | Medium7 | Game theoryGraph+2 | No attempts yet | 1s | 256 MB | Judgeable |
| LoL TournamentGiven a tournament bracket where each winner is renumbered, find which starting positions give the highest chance of winning all n-1 rounds with per-round win probability p. | Medium7 | GraphTree+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Divide and ConquerEach of two kings owns a spanning tree on N towns; find the fewest roads to destroy so some pair becomes disconnected and count the minimum-size cut sets. | Medium7 | TreeGraph+2 | No attempts yet | 2s | 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 |
| Please Take My GiftEach cell of a grid holds a direction; every walk follows those arrows forever. Find the fewest cells to mark so every walk visits a marked cell. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Delivery GuyOn a tree of N restaurants with demand A_i, maximize total delivered peppers in M time units, where each visit costs 1 to deliver and each edge costs 1 to traverse. | Medium7 | TreeDynamic programming+2 | No attempts yet | 2s | 64 MB | Judgeable |
| MooTube (Gold)On a weighted tree, USADO between two videos is the minimum edge weight on their path. For each query (K, v), count vertices whose USADO with v is at least K. | Medium7 | GraphUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| A Particle on the TreeFor each query edge (U,V) and final color C, count pairs (start, end) whose shortest path uses that edge in that direction and whose arrival color matches C. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Calculate! 2On a rooted tree, handle subtree XOR queries and subtree XOR updates, printing the XOR of a vertex and its descendants. | Medium7 | TreeSegment tree+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Please Take My Gift 2Given a 1 by N arrow map where every walk stays inside, place the fewest gifts so that a walk from any starting cell hits a gift. | Medium7 | GraphGreedy+2 | No attempts yet | 2s | 256 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 |
| Network HackingGiven a weighted tree, cut one edge, then reconnect its two endpoints with an edge of the same weight to maximize the resulting tree's diameter. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| A Very Nasty Graph ProblemBuild the lexicographically smallest de Bruijn sequence of order N over two symbols, a shortest binary string containing every N-bit number. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Path EmbeddingGiven a tree and an ordering of its vertices, find the maximum tree distance between consecutive vertices in the ordering, capping the answer at 99. | Medium7 | TreeLinked list+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Computer networkGiven a directed graph, find the minimum number of source computers that reach all nodes, and the minimum edges to add to make it strongly connected. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| KMPEach of N scientists has letters from the first characters of their name words. For each query, decide whether its letters can be matched one each to distinct scientists, with order ignored. | Medium7 | Bit manipulationDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Peg Game for TwoGiven a weighted triangular peg board with one empty hole, compute the optimal difference of Jacquez's score minus Alia's when both alternately jump and play to maximize their margin. | Medium7 | DFSGame theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WandGiven M duels with fixed winners, in any order, decide which wizards can hold the wand (initially with wizard 1) after all duels. | Medium7 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Rainwater on a TreeWater starts at the root and each vertex sends 1 unit per second to a uniformly random child; find the average expected final water over vertices that hold any water. | Medium7 | TreeProbability+2 | No attempts yet | 1s | 512 MB | Judgeable |
| BoomerangsCount pairs of adjacent edges in a connected graph whose removal disconnects the graph. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Five Color TheoremGiven a planar graph with coordinates and edges, assign each vertex one of five colors so no edge joins two vertices of the same color. | Medium7 | GraphGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| First of Her NameGiven a family tree where each lady's name is her first letter prepended to her mother's name, count for each query string how many lady names have it as a prefix. | Medium7 | StringTrie+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Newcomer and VeteranGiven a directed reporting graph on N participants where newcomers speak truth and veterans lie, find the maximum possible number of veterans. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| HashgraphBuild a hashgraph from M directed communications, then decide whether one given event can reach another through the precedence (see) relation. | Medium7 | GraphDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Ant in a Hexagonal WebOn an infinite hexagonal web, count the ant walks that make exactly N turns before first revisiting a vertex, where the first step is fixed north. | Medium7 | DFSBacktracking+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| TrapCount the self-avoiding walks of n unit grid steps that start at (0,0) going right and are trapped: no further step can be added without self-intersection. | Medium7 | BacktrackingDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Rail GaugesAssign real gauges to domestic stations in a tree whose leaves are foreign stations with fixed gauges, minimizing the sum of absolute differences along edges, and output the floor of the minimum. | Medium7 | TreeGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Appeal to the AudienceAssign k given skill values to the k leaves of a rooted tree to maximize the sum over all internal nodes of the skill values in that node's subtree's leaves. | Medium7 | TreeGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Beer Flood SystemGiven a DAG with a unique source and unique sink, find the maximum number of edges that can be deleted while keeping every remaining edge on a valid source-to-pump-to-sink flow path. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Big Company Seungbeom'sGiven a rooted tree of employees, pick a matching of edges where each node touches at most one chosen edge, maximizing the sum of products of endpoint skill values. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Bus RoutesCover every edge of a tree with the fewest simple paths, where each path visits distinct vertices in order along tree edges. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Folding a CubeGiven a connected arrangement of six unit squares with no 2x2 block, decide whether it can be folded into a cube. | Medium7 | DFSGeometry+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Hidden WordsGiven a grid of up to 10x10 letters and up to 100,000 query words of length at most 10, count how many words can be traced through adjacent, non-repeating cells. | Medium7 | BacktrackingDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Gene TreeGiven an unrooted tree with positive edge lengths and up to 100,000 nodes, compute the sum of squared path-lengths over all unordered pairs of leaves. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Maze ConnectGiven an ASCII maze of slashes and dots on a 45-degree grid, find the fewest walls to remove so every cell connects to the outside. | Medium7 | GraphUnion-find+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Flow FinderGiven a rooted tree with some known vertex flows, where every leaf is a free positive integer and each internal node equals the sum of its children, decide whether all flows are uniquely determined and output them, otherwise print impossible. | Medium7 | TreeDFS+2 | No attempts yet | 4s | 512 MB | Judgeable |
| EquidistantGiven a tree and a set of marked vertices, find any vertex equidistant from all marked vertices, or report that none exists. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Parallel UniverseGiven up to a million small trees (each up to 30 nodes), count how many are pairwise non-isomorphic, since Hanna can photograph one tree per distinct topology. | Medium7 | TreeHash map+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Radio PrizeIn a weighted tree, for every city u output the sum of (t[u] + t[v]) * dist(u, v) over all other cities v. | Medium7 | TreeDFS+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Milk VisitsGiven a tree with a cow type at each node, answer for each of M queries whether a node on the path from A to B has type C. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Wormhole SortPermutation of cows at locations with weighted wormholes; maximize the minimum wormhole width used to place every cow at its own location. | Medium7 | Union-findGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Plan BFind every city that cannot be surrounded by forces, where a city is surrounded only when every neighbor holds a base or can be reached without passing through the protest city. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PutovanjeOn a tree, visit towns 1 through N in order; each edge costs C1 per traversal or C2 once, so minimize total ticket cost. | Medium7 | TreeGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Company Culture 5A supervisor tree supports turning all subordinates of a worker on or off, and counting how many subordinates of a worker are currently on. Initially only the computer of node 1 is on. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Beautiful NowGiven an integer n and a swap budget k, find the smallest and largest numbers reachable by swapping digit positions, where no intermediate or final number may have a leading zero. | Medium7 | GreedyBrute force+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Christmas TreeMaintain a dynamic set of colored nodes in a rooted tree under insertions and deletions, and after each update report the lowest common ancestor of all colored nodes. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| UberficationIn an undirected unit graph, sum the shortest path distances over all unordered pairs of nodes that are connected by exactly one simple path. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Even SeparationSplit the vertices of an undirected graph into two parts so that every vertex has even degree in the subgraph induced on its own part. | Medium7 | GraphDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| FantasiaFor each vertex i, compute the weight of the graph with i removed, where a connected graph weighs the product of its vertex weights and a disconnected one weighs the sum of its components. | Medium7 | GraphDFS+2 | No attempts yet | 5s | 64 MB | Judgeable |
| Police StationsGiven costs and one-way roads among N villages, pick police-station villages so every village is reachable, minimizing the average station cost. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Dance, DanceFind the maximum number of rounds of perfect man-woman pairings, with no repeated pair and each person dancing with a disliked partner at most K times. | Hard8 | GraphBinary search+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Strategy Game TournamentGiven fixed win results between some pairs of N tournament players, determine every player who could still end up as champion. | Hard8 | GraphUnion-find+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Traffic SystemGiven a connected graph of cities and roads, answer many queries asking if two cities stay connected after deleting one specific road or all roads of a chosen city. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| AlleywaysFind the maximum-value path from node 1 to node n in a directed weighted graph, or report -1 if the value can grow without bound due to a positive cycle on a valid path. | Hard8 | Shortest pathGraph+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Road Direction PlanningDecide if directions for N horizontal and M vertical one-way roads can be chosen so every bus route still has a shortest path using at most one horizontal and one vertical road. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| N-RookGiven a grid with walls blocking line of sight and pit cells that block placement but not sight, find the maximum number of mutually non-attacking rooks. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tree Height ReductionGiven a rooted tree and target height H, find the minimum total cost of repeatedly reattaching vertices to ancestors (cost based on level gap) to bring the tree height down to at most H. | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Broadcast NetworkPick which edges of a rooted tree to install so that total user fees minus installation cost stays non-negative while maximizing the number of served users, solved with tree knapsack DP. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 2s | 128 MB | Judgeable |
| MazeGiven a tree-like maze grid, compute the expected number of steps for a random depth-first exploration (choosing unvisited branches uniformly, backtracking on dead ends) to travel from entrance to exit. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Planning a TripGiven a directed graph, find the maximum number of distinct cities visitable on a walk from S to T, allowing revisits of cities and edges. | Hard8 | GraphDFS+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Graph HashGiven a weighted graph with up to 30 vertices, compute the LCM over all simple paths from vertex 1 to 2 of the GCD of edge weights on each path, with results up to 1000 digits. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Drive TourFind two vertex-disjoint (except endpoints) monotonic increasing and decreasing paths between city 1 and city N that together visit the maximum number of distinct cities, and output the combined route. | Hard8 | Dynamic programmingGraph+1 | No attempts yet | 2s | 128 MB | Judgeable |
| SticksGiven N triples of sticks, decide if removing at most one stick per triple can make all remaining sticks pairwise non-crossing, and output a valid removal set. | Hard8 | GraphDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bus RoutesGiven a tree with degree at most 10, partition all edges into leaf-to-leaf simple paths covering every vertex while minimizing the maximum path length, or report impossibility. | Hard8 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Histology Outline TracerTrace clockwise boundary contours of stained connected regions in a bitmap, ignoring small regions, using an 8-direction outline code. | Hard8 | DFSMatrix+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Roman Numeral WalkFind the longest path from the grid center through empty-separated cells that spells consecutive Roman numerals starting at 1, and print the last number reached. | Hard8 | DFSBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |