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 |
|---|---|---|---|---|---|---|
| String PhoneDecide whether each building can post its officer on one of its four corners so that every string length equals the street distance between the pair it joins. | Hard8 | GraphDFS | No attempts yet | 1s | 128 MB | Judgeable |
| Disjoint water supplyCount the pairs of cities with paths from city 1 that meet only at city 1 in a pipe network ordered by decreasing altitude. | Hard8 | GraphTopological sort+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The kingdomFollow the fixed DFS, vertex-split, and Euler-circuit steps to output edge-disjoint even-length trails pairing every odd-degree vertex. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Recovering the PopulationsGiven a tree and the distance-weighted sums at each node, recover the node weights that produce them. | Hard8 | TreeDFS+1 | No attempts yet | 4s | 256 MB | Judgeable |
| Volunteer CampStarting from each house in a weighted tree, find the shortest truck route that visits K marked houses without driving back. | Hard8 | TreeDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Magical SwitchesChoose which of the 26 color switches to push so a token can walk from the left edge to the right edge of a 3-row board. | Hard8 | GraphDFS+1 | No attempts yet | 8s | 512 MB | Judgeable |
| ToursFind every k for which roads can go to k companies so each cycle contains the same number of roads of each company. | Hard8 | GraphDFS+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Which intersections did I pass?Given a connected undirected graph, each query asks how many vertices lie on some walk from a to b that never revisits the endpoints in the middle. | Hard8 | GraphDFS+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Tree of PainDecide for each small pattern tree whether it embeds into the organization tree with matching labels and ancestry preserved both ways. | Hard8 | TreeDynamic programming+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 2-SAT smallest assignmentDecide whether a 2-CNF formula over up to 10000 variables is satisfiable and output the lexicographically smallest satisfying assignment. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Seonjin's Frozen KingdomDecide whether a walk on a grid that breaks each cell it leaves can visit the hatch cell, leave it, and step back onto it. | Hard8 | DFSGraph | No attempts yet | 2s | 256 MB | Judgeable |
| Juice JunctionsAdd up the maximum unit-capacity flow between every pair of junctions in a graph where each junction joins at most three pipes. | Hard8 | GraphTree+2 | No attempts yet | 7s | 512 MB | Judgeable |
| King's InspectionFind the lexicographically smallest directed tour that starts and ends at city 1 and visits every other city exactly once. | Hard8 | GraphBacktracking+1 | No attempts yet | 10s | 512 MB | Judgeable |
| Routing a Marathon RaceFind a simple path from junction 1 to junction n that minimizes the total personnel cost of the junctions on the path and their direct neighbors. | Hard8 | BacktrackingGraph+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Connect the CellsConnect each color pair with disjoint grid paths that cover every cell and print the lexicographically smallest direction map. | Hard8 | BacktrackingGraph+1 | No attempts yet | 3s | 256 MB | Judgeable |
| SubstringsOrder all given strings as the consecutive length-L windows of one string of length L+N-1 and print the lexicographically smallest such string. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Connecting the wiresPlace each equal-number pair above or below a row so same-side joining arcs never cross, and print the lexicographically smallest side string. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 64 MB | Judgeable |
| The Bored Traveling Salesman (Large)Visit every city in a connected graph using paired outbound and return flights so the ZIP codes in order of first visit form the smallest possible number. | Hard8 | DFSGraph+1 | No attempts yet | 5s | 512 MB | Judgeable |
| PoklonGiven a tree of scales, add positive real weights so every scale balances with minimum total added mass, then print the final total mass in binary. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Longest RiversGiven a river network tree and source names, find for each name the best rank it can achieve over all valid downstream naming choices. | Hard8 | TreePrefix sum+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Similar SubwaysGiven two trees with up to 50 nodes each, find the largest k such that some connected k-node subtree of the first is isomorphic to some connected k-node subtree of the second. | Hard8 | TreeDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| HyperwaysAfter each edge is added to a multigraph, report how many edges became safe, where an edge is safe when it lies on a cycle. | Hard8 | Union-findGraph+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| A Lot of GamesGiven a trie of strings, play the prefix-building game k times with the loser starting next; report who wins the last game. | Hard8 | TrieGame theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hongjun and the Possible SetsCount the nonempty connected vertex subsets of a weighted tree whose maximum minus minimum weight is at most d. | Hard8 | TreeDFS+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Hongjun and the TreeProcess subtree updates that add a distance-dependent value to each vertex, answering point-weight queries modulo 1e9+7. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Easily Happy TreeDelete the fewest leaves from a rooted tree so that no remaining vertex has a descendant farther away than that descendant's own limit a_u. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TreeMaintain a rooted tree under vertex deletions (children reparent to grandparent) and answer distance queries between two live vertices. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TouristsGiven a tree on n nodes, sum the number of nodes on the path from x to y over all pairs where y is a larger multiple of x. | Hard8 | TreeMath+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Cube DividingCount the face-connected components of unit cubes left in an A x B x C box after removing N given cubes, where the box is huge but N is at most 20000. | Hard8 | GraphBFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Checkpoint candidatesGiven an undirected graph, a set of source vertices, and a set of airport vertices, count the vertices that every source-to-airport path must pass through. | Hard8 | GraphDFS | No attempts yet | 2s | 128 MB | Judgeable |
| Quarantine StationsPlace K quarantine barriers on the edges of a weighted tree so that the largest connected component's total population is minimized. | Hard8 | TreeBinary search+1 | No attempts yet | 3s | 256 MB | Judgeable |
| TreeAfter each query asks whether two vertices are still connected, the tree may lose one edge based on the answer, so connectivity must be tracked under online deletions. | Hard8 | TreeUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Two TreesPick a vertex subset connected in both of two trees to maximize the total score, with the empty set allowed. | Hard8 | TreeDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Counting Similar TreesGroup labeled trees that are isomorphic under a bijection preserving edge label differences, and report each group size. | Hard8 | TreeHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Inversions of a simple path sequenceGiven a connected unimodal (unicyclic) graph, find a minimum inversion count over simple paths visiting at least K vertices, or -1 if none exist. | Hard8 | GraphDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Blue vertex distance sums on a treeProcess paint and distance-sum queries on a weighted tree, reporting for each query 2 the total distance from x to all blue vertices. | Hard8 | TreePrefix sum+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Edsger DijkstraGiven a program of labeled print statements and if-goto statements with counters that are true for a bounded number of times, decide whether transforming every if-goto into a do-while loop keeps the program's output and compiles. | Hard8 | SimulationImplementation+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Vertices connected by the same colorProcess color flip and reachability queries on a tree where two vertices are connected if every vertex on their path has the same color. | Hard8 | TreeUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| VirusGiven a binary tree, find the minimum number of nodes that end up infected when one node may be protected each round. | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Dona MinhocaOn a cactus graph, for each query (entry chamber, worm length) decide whether a closed non-backtracking walk of length at most M exists and give the shortest such distance. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Ecology PreserveGiven an N by N grid of tree counts, pick a connected set of exactly M cells (M at most 10) maximizing the total tree count. | Hard8 | Dynamic programmingDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Street DetourFor each test, after removing street 1, decide whether the graph stays strongly connected, or becomes so by reversing one-way streets or by making streets two-way. | Hard8 | GraphBFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| BurzaGiven a tree and a blind pre-committed node-marking order, decide whether the coin can be forced to move fewer than K times regardless of the adversary's play. | Hard8 | Game theoryTree+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Calculating TaxesOn a tree where each house picks a divisor of its income, maximize the total sum of chosen values so that every pair of adjacent houses picks coprime values. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Dictionary GameWords are destroyed by prefix cuts; after each insertion into the dictionary, report which player wins the impartial game under optimal play. | Hard8 | Game theoryTrie+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Sky TaxOn a tree with a moving capital, each vertex answers for all vertices whose path to the capital passes through it; move the capital or query a vertex's count. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Invisible IntegersGiven up to 10 hints, each a walk order of distinct digits 1 to 9, find the shortest hidden integer sequence that can produce every hint. | Hard8 | BacktrackingDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Binary CodeEach of n binary words has at most one unreadable bit; decide whether the ?s can be filled so no word is a prefix of another. | Hard8 | TrieGreedy+2 | No attempts yet | 2s | 2048 MB | Judgeable |
| Beautiful PathsOn a tree with capitals 1 and 2, sum over all pairs of cities of the minimum distance-to-nearest-capital along their path. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Scout GatheringsOn a tree, support adding a member at a city and querying the sum of weighted distances from all members to the current gathering city, which moves along edges. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RhymeGiven N distinct words, find the longest sequence using each word at most once where consecutive words rhyme: their longest common suffix has length at least the longer word's length minus one. | Hard8 | StringTrie+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Company Culture 4On a rooted tree, praise spreads downward from an employee to all descendants or upward to all ancestors, the direction flips over time, and queries ask for an employee's accumulated praise. | Hard8 | TreePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WellsOn a tree where placing wells at a vertex counts for it and its direct neighbors, find the minimum number of wells so every village's demand is met. | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Ski ResortFor each query, count the size-k sets of areas such that every favorite area has exactly one stocked area lying on every path from the top, and all chosen areas lie on paths to favorite areas. | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Yeongseon takes the baitOn a tree, count alternating left/right paths from a fixed start where each vertex is used once; report the maximum over all starting vertices. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Good News and Bad News (Large)Assign a nonzero integer to each directed edge so every vertex's outgoing sum equals its incoming sum, exactly as built by a prescribed DFS cycle-circulation procedure. | Hard8 | GraphDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| The Restless CatIn a connected, planar, simple graph with a guaranteed cycle, find rooms whose single-vertex deletion leaves the graph acyclic (a forest), summing their indices. | Hard8 | GraphDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| City AttractionsOn a weighted tree, Gigel repeatedly jumps from his current city to the city maximizing a_y - dist(x, y), breaking ties by smallest index, and we must report his position after K days. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 64 MB | Judgeable |
| Tree path decompositionCount the ways to partition all nodes of an unrooted tree into vertex-disjoint paths, where each path's node sum is nonnegative, modulo 1e9+7. | Hard8 | TreeDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Who made the Christmas soundRoot the tree at socket 1 and count colorings with R, G, B bulbs, respecting the green and blue adjacency rules, whose total cost is divisible by K. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Broadcast StationsGiven a tree, assign non-negative integer powers to vertices so every zero-power vertex lies within reach of some positive-power vertex, minimizing the total power. Report that minimum sum. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Sheets and PaintballsGiven axis-aligned rectangles and colored points, count the distinct color labels that reach each rectangle along the vertical stacking order. | Hard8 | SortingSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Crowd ControlFind the unique maximum-capacity simple path from node 0 to node n-1 and list every other edge incident to a vertex on that path that must be closed. | Hard8 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hoarse HorsesGiven line segments in the plane, count the maximum number of faces enclosed by them, i.e. bounded regions of their arrangement. | Hard8 | GeometryGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Royal TaxGiven a tree of cities, each with tax gold and a carriage of capacity C, find the minimum total distance to collect all gold into the capital vault. | Hard8 | TreeDynamic programming+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Keep it coveredDecide whether a grid of dots and empty cells can be tiled by four line-piece types so that lines match across shared sides and never touch the border. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Rainbow RoadsGiven a tree whose edges are colored, find every node v such that all simple paths starting at v have no two consecutive edges of the same color. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hidden SupervisorsGiven a partial parent array, fill in the missing supervisors to complete a rooted tree and maximize the number of disjoint parent-child pairs. | Hard8 | TreeDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Extra Judicial OperationGiven a connected undirected graph, find the minimum number of vertices beyond one that must hold servers so every vertex still reaches a server after any single edge is removed. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Balloon WarehouseSimulate repeated insertions into an infinite balloon line, then report the colors at positions l to r-1 after all instructions. | Hard8 | TreeDFS+2 | No attempts yet | 7s | 512 MB | Judgeable |
| Infinite TreesGiven two possibly infinite trees defined by node-to-children mappings, decide whether their roots have the same ordered structure, where recursive nodes make the unfolding infinite and require comparing regular trees. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CounterspellsAfter each of n leaf insertions into a rooted tree, find the minimum number of vertex recolorings needed to restore the unique well coloring. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Corporate life after a hostile takeoverGiven two rooted trees on the same n employees, count for each employee how many others are descendants in both trees. | Hard8 | TreeDFS+2 | No attempts yet | 0.5s | 1024 MB | Judgeable |
| MousetrapOn a tree, Dumbo blocks or cleans edges while an edge-averse mouse moves; find the minimum moves to force it into the trap. | Hard8 | TreeDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| ChaseJerry walks a simple path in a tree, dropping up to v breadcrumbs that zero out neighbor pigeon counts; maximize the pigeons Tom later meets minus the pigeons Jerry met. | Hard8 | TreeDynamic programming+1 | No attempts yet | 4s | 512 MB | Judgeable |
| Embedding EnumerationCount the ways to place a labeled tree's nodes into a 2 by n grid so node 1 sits at the top-left, edges touch, and no cell repeats, modulo 1e9+7. | Hard8 | TreeDFS+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Hyunsoo CityGiven a connected cactus graph with toggleable edges, answer connectivity queries under edge updates, where each edge lies on at most one cycle. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Directing the TreeCount the orientations of a tree's edges such that every given vertex pair has a directed path one way or the other, modulo 1e9+7. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Getting Back HomeOn a tree with home at node 1 and office at node n, find the smallest flashlight range d so that a random walk governed by visibility rules always reaches home within 10^9 steps. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| BureaucracySimulate repeatedly sending a task down the smallest-numbered child on each root-to-leaf path, paying 1,2,3,... coins up the chain, and deleting the leaf. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Christmas TreeGiven the final colours on a tree after M path-painting updates with distinct colours, reconstruct the unique valid update order and the endpoints of each colour's shortest covering path. | Hard8 | TreeDFS+2 | No attempts yet | 0.7s | 512 MB | Judgeable |
| Cat and MouseOn a tree with distinct edge weights, the mouse always moves to its heaviest incident edge (or second heaviest if the cat blocks it); find the minimum number of mouse moves for the cat to trap it. | Hard8 | TreeDFS+2 | No attempts yet | 10s | 512 MB | Judgeable |
| HH CountryFor each query set of tree vertices, output twice the sum of pairwise tree distances. | Hard8 | TreeDFS+1 | No attempts yet | 10s | 512 MB | Judgeable |
| 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. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Graph and Minimum Spanning TreeFor each edge of a connected weighted undirected graph, print the weight of a minimum spanning tree that is forced to include that edge. | Hard8 | Minimum spanning treeUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Arranging game levelsCount rooted tree arrangements of N levels where each level's clear score S_i and the cumulative score K_i along the root-to-level path are given, and children must have larger S than parents. | Hard8 | TreeCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Tree SeparatorGiven a tree, delete all vertices on some simple path between two chosen vertices; maximize the number of remaining components of size at least K. | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Non-redundant DriveIn a tree where each node gives g fuel and each edge costs d, find the longest simple path from any start such that the running fuel never drops below zero, refueling once per node. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Äventyr 2On a tree, timelines get marked over time, and after each mark you must report the distance from a queried vertex to the nearest marked vertex. | Hard8 | TreeBFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Frogs 2Assign one frog to each pad so that every frog sits on a preferred pad and each log joins two frogs with equal interest in the log's topic. | Hard8 | GraphBacktracking+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Cow at Large (Platinum)In a tree, for each barn find the minimum number of farmers placed at exits needed to catch Bessie, who starts there and runs for the nearest exit at equal speed. | Hard8 | TreeDFS+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Cow at LargeOn a tree of N barns, find the minimum number of farmers placed at exits so they catch Bessie, who starts at node K and runs to any exit. | Hard8 | TreeBFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Broken GearboxAssign each of n gear radii to a vertex of a connected graph so that every edge's distance equals the sum of its assigned radii, returning the lexicographically smallest assignment or impossible. | Hard8 | GraphMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| The CaveOn a tree, decide whether one chamber lies on some walk from a_i to b_i using at most d_i edges, for every speleologist, and output the smallest such chamber. | Hard8 | TreeGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Conquer the WorldArmies sit on the nodes of a weighted tree; move them along edges to satisfy each node's demand while minimizing total transport cost. | Hard8 | TreeDFS+1 | No attempts yet | 8s | 1024 MB | Judgeable |
| DisruptionGiven a tree and extra weighted edges, for each tree edge report the minimum weight of a non-tree edge whose endpoints lie in different components after removing it. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | DFSGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| DuathlonCount ordered triples (s, c, f) of distinct vertices such that some simple path visits s, then c, then f, in an undirected graph with n up to 1e5. | Hard8 | GraphBFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |