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 results837 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Wealthy FamilyGiven a rooted tree with a weight on each node, pick exactly k nodes with no ancestor relation between any two, maximizing the total weight, over multiple test cases. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Let's Go to the MoviesEach family is a parent with children, and tickets are either singles or family tickets (one parent plus any subset of their own children). Find the arrangement minimizing cost, breaking ties by fewest tickets. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Type PrinterFind the minimum number of add, remove, and print operations to type N distinct words on a printer that keeps a single editable string, with any print order allowed. | Medium7 | TrieDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Lightest MobileGiven a tree of balanced rods with integer lever ratios, assign positive integer masses to all weights so every rod balances and the total mass is minimized. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AcquapiaMultiple test cases give several river trees; for each city pair, report whether a route exists and, if so, the unique city where the ship must switch from upstream to downstream. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Running Away From the BarnFor every node in a weighted tree rooted at node 1, count the descendants within total distance L along the downward path, including the node itself. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow CalisthenicsRemove exactly S edges from a tree so that the largest diameter among the resulting components is as small as possible, and output that minimum diameter. | Medium7 | TreeBinary search+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tree DecorationPlace a minimum-cost number of ornaments on each node of a rooted tree so every subtree holds at least its required count, given per-node unit costs. | Medium7 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SolderingGiven a tree, cover its edges with paths (wires) that may meet at soldered points, minimizing the sum of squared path lengths. | Medium7 | TreeDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Slowing downFor each cow in order, count how many pastures already occupied by earlier cows lie on the tree path from node 1 to that cow's pasture. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow PoliticsGiven a tree with each node belonging to one of K parties, find the diameter (greatest distance between any two nodes) of the nodes in each party. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Corrupted BSTGiven a binary tree with distinct integer keys, find the minimum number of node keys to change so the tree satisfies the BST ordering, keeping its shape fixed. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DehuffGiven a sample string and its full binary encoding, reconstruct the unique prefix-code table for the alphabet, or report several possible tables. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ExpressionsGiven a postfix expression, produce another postfix expression that the same algorithm evaluates to the same value when a queue replaces the stack. | Medium7 | StackQueue+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Teams that can winGiven n teams and n-1 desired games, count the teams that can be champion under some valid single-elimination schedule that plays every listed game. | Medium7 | GraphTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Huffman's GreedWe build the optimal binary search tree for weighted key and gap frequencies, minimizing weighted comparison counts. | Medium7 | Dynamic programmingTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Binary Search Heap ConstructionGiven label/priority pairs, build the unique treap (a binary search tree on labels and a max-heap on priorities) and print it in nested parenthesized form. | Medium7 | TreeStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Phylogenetic Trees InheritedGiven leaf sequences of a complete binary tree, label internal nodes to minimize the sum of Hamming distances along edges, and output the lexicographically smallest optimal root sequence with its cost. | Medium7 | Dynamic programmingTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TourneyMaintain a single-elimination bracket of 2^N players under point updates, and answer queries about the winner's position and how many rounds a given player wins. | Medium7 | TreeSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| LHCGiven a tree, find the maximum cycle length obtainable by adding one edge, and count the vertex pairs that achieve it. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| MobileDecide whether two mobiles, given as rooted binary structures with negated weight labels, can be rotated to look identical. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pyramid Message SchemeGiven a chronological list of message recipients from a sequential tree traversal, reconstruct the tree and compute the time saved by a parallel traversal. | Medium7 | TreeStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Great Spamway StrikeChoose a rooted tree over zombies with allowed bidirectional links, minimizing the round-trip time for a gather broadcast that includes each node's per-message read lag. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| S and KGiven binary trees written with S and K, repeatedly apply the two rewrite rules until no rule fires, then print the final tree string. | Medium7 | ImplementationSimulation+2 | No attempts yet | 3s | 128 MB | Judgeable |
| BSP TreesBuild a BSP tree by inserting p slanted planes into the xz-plane, assign n polygons to leaf regions, then print objects in the drawing order the tree induces. | Medium7 | GeometryTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| QuadTreesGiven pre-order strings of two quadtrees for N x N binary images, count the nodes in the quadtree of their pixelwise AND intersection, collapsing uniform quadrants. | Medium7 | TreeDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Uniform SubtreesGiven a parenthesis-encoded tree, list every distinct uniform subtree (same child count at each depth) in lexicographic order. | Medium7 | TreeDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Restore the Expense IndentationGiven pre-order amounts where each parent equals the sum of its immediate children, recover the lexicographically smallest 0-based indentation depth for every line. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Multi-Element Binary Search TreeGiven sorted search probabilities and level-dependent node capacities, find the minimum expected number of comparisons for a multi-element BST. | Medium7 | Dynamic programmingTree+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| An Old Stone GameFor each of up to 10 general trees, compute the minimum number of stones needed so that starting from the bucket you can place a stone on the root by combining stones at fully occupied siblings. | Medium7 | TreeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree GameOn a tree, players alternately move a token to an unchosen neighbor from Manco's start vertex; find all start vertices where Manco wins with optimal play. | Medium7 | TreeGame theory+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Coloured LeavesGiven an unrooted tree whose leaves have fixed colors, choose an internal vertex as root and place the fewest labels so each leaf's color matches its last labeled vertex. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Central TreeFor each weighted tree, find the vertex minimizing the sum of weighted distances to all other vertices and output that minimum sum. | Medium7 | TreeDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Lightning Energy ReportGiven a tree and many path updates that each add a value to every vertex on a path, report the final total at every vertex. | Medium7 | TreePrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Printed-Circuit BoardsGiven a series-parallel circuit described recursively, find the minimum number of connections that must be routed on the top side so every unit is reached from the top. | Medium7 | TreeDynamic programming+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Binary Search Tree CodeGiven n and k, output the n-th preorder string among all BSTs built from the first k letters, listed in alphabetical order. | Medium7 | TreeRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TreesGiven a sequence of leaf levels, decide whether it is a valid complete binary tree; if so, output the genealogical and bracket representations. | Medium7 | TreeRecursion+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Mudstock BisPlace a festival at a settlement on a star of railway lines to minimize the weighted sum of distances from all members, and report the cost and location. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MegalopolisCount, for each query at a given moment, the number of still-country roads on the path from village 1 to a target village as edges are removed one by one. | Medium7 | TreeDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| StationPick a tree vertex as the hub so that the average number of hub-to-vertex paths needed to travel between unordered pairs of vertices is minimized. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree RotationsGiven a binary tree with distinct leaf labels, find the minimum number of inversions in the left-to-right leaf sequence reachable by swapping children at branchings. | Medium7 | Divide and conquerDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Winter Snow PlowingOn a tree, each edge must be traversed at least d_i times by one continuous walk; find the minimum total traversal count. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Byton TreeGiven a tree in recursive notation, where each leaf has a time interval, find the minimum number of cuts (each cut picks every byton in the subtree at one moment) so that all intervals are covered. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| BarricadesOn a tree, for each size k find the minimum number of edges to cut so that some connected component has exactly k vertices and no edges leave it. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TramsGiven a weighted tree, pair up the leaf nodes choosing disjoint simple paths to minimize or maximize the total length. | Medium7 | TreeDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Two PostmenSplit the edges of a tree rooted at node 1 between two postmen starting at the root so the later finishing time is minimized. | Medium7 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fiber Optic NetworkReserve bandwidth on tree paths for connect requests when capacity allows and release per-pair reservations on disconnect. | Medium7 | Segment treeTree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| OfficialsIn a rooted tree of officials, match each denouncer with a distinct descendant subordinate to maximize the number of executed officials. | Medium7 | GreedyTree+1 | No attempts yet | 1s | 512 MB | Judgeable |
| TagA pursuer at K always steps toward an evader at J on a tree while the evader moves or waits to maximize the capture time. | Medium7 | TreeGame theory+2 | No attempts yet | 5s | 128 MB | Judgeable |
| TournamentCompute the chance that two named entrants meet in a knockout bracket with random seeding and even match odds. | Medium7 | ProbabilityTree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| BillabongsConnect the weighted forest into one network with fixed-cost links so the longest travel time between any two ponds is as small as possible. | Medium7 | TreeGreedy+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Up a TreeGiven three garbled preorder, inorder and postorder outputs from mixed-up recursive calls, list every call assignment and the smallest tree that fits each one. | Medium7 | TreeBacktracking+2 | No attempts yet | 6s | 128 MB | Judgeable |
| Slicing TreePlace the rotated rectangles under the slicing-tree constraints so the enclosing rectangle has minimum area. | Medium7 | Dynamic programmingTree | No attempts yet | 1s | 128 MB | Judgeable |
| NetworkPlace the fewest additional servers on internal nodes so every leaf is within distance k of the nearest server. | Medium7 | GreedyTree | No attempts yet | 1s | 128 MB | Judgeable |
| TreeDraw a crossing-free straight-line tree through n given points so each point has its required degree. | Medium7 | GeometryTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ChonSuGiven the distances between consecutive leaves of an unknown full binary tree, compute the distance between two specified leaves. | Medium7 | TreeDivide and conquer+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ParentsPick from 1 to K nodes of a valued tree with no parent-child pair so the sum of picked values is as large as possible. | Medium7 | Dynamic programmingTree | No attempts yet | 5s | 128 MB | Judgeable |
| Electric NetworkGiven a connected network, compute the fewest new lines that keep every pair of facilities connected after any single line fails. | Medium7 | DFSGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Digital Content ProtectionGiven the hacked leaves of a complete binary key tree, print the identifiers of the smallest set of unexposed node keys covering every intact player. | Medium7 | GreedyTree+1 | No attempts yet | 2s | 128 MB | Judgeable |
| You Shall Not Pass!!Choose up to C coaching subtrees in a forest to maximize the number of teams covered by at least one chosen subtree. | Medium7 | Dynamic programmingTree | No attempts yet | 1s | 128 MB | Judgeable |
| The Mayo EmpireEach new city joins the tree by one road with possible capital moves, and the task sums the farthest road count from the capital after every addition. | Medium7 | TreeGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| ACM RevengeCompute the number of deaths before the first hunter reaches a treasure room in a binary tree with traps and toggling exits. | Medium7 | TreeDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Delta QuadrantStarting anywhere on a weighted tree, find the shortest closed tour that visits all but k planets and returns to the start. | Medium7 | Dynamic programmingTree | No attempts yet | 5s | 128 MB | Judgeable |
| Join two kingdomsTwo trees with up to 40000 nodes each are joined by one uniformly random cross edge, and you must output the expected diameter of the combined tree. | Medium7 | TreeSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Jingle BallsMove as few balls as possible so the two sides of every split differ by at most one ball, or report impossible. | Medium7 | Dynamic programmingTree | No attempts yet | 1s | 128 MB | Judgeable |
| TraitorCover as many marked nodes of a forest as possible by assigning each a distinct neighboring watcher with no two marked nodes watching each other. | Medium7 | Dynamic programmingTree | No attempts yet | 1s | 128 MB | Judgeable |
| Speed CamerasPlace the most cameras on the intersections of a tree so no simple route passes more than k cameras. | Medium7 | GreedyTree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Traveling SagaPrint the order in which an apple from vertex 1 visits every tree vertex by always moving to the farthest unvisited vertex, breaking ties by largest index. | Medium7 | TreeSegment tree+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Code BreakingCount digit assignments to a rooted tree that place at least one of M forbidden 5-digit strings on its specified upward path, modulo 1234567. | Medium7 | Dynamic programmingTree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| HotelsCount triplets of distinct towns in a tree whose three pairwise distances are all equal. | Medium7 | TreeDynamic programming+1 | No attempts yet | 3s | 256 MB | Judgeable |
| FarmCraftChoose a tour of the tree from the root that visits every house and returns, so the latest moment of arrival plus install time is as early as possible. | Medium7 | GreedyTree+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Ant colonyAnt groups enter from every leaf, split evenly at each chamber with the rest eaten, and you count groups crossing one corridor with exactly k ants. | Medium7 | TreeMath+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Safe Emergency Contact NetworkFor each road, report the cheapest total cost of a network connecting all villages without that road, or -1 when impossible. | Medium7 | Minimum spanning treeTree+1 | No attempts yet | 1s | 64 MB | Judgeable |
| Bridge RemovalStarting from any island, a crew that spends a bridge length to cross or remove it must delete every bridge of a tree in the shortest total time. | Medium7 | Dynamic programmingTree+1 | No attempts yet | 1s | 256 MB | Judgeable |
| The Club TripEach of n classmates rides only if one named classmate also rides; fill up to k bus seats with the largest group that respects every such condition. | Medium7 | GraphDynamic programming+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Floating FormationPlace up to k spare boats on pieces linked pairwise by boats to minimize pieces lost in the cascade where a piece with fewer than two boats sinks. | Medium7 | GraphTree+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Circle and MarbleEach move shifts one marble along an arrow to the next circle, and you decide if the first or second player wins under best play. | Medium7 | Game theoryTree+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Stack Copying GameMaintain up to 300,000 persistent stack versions built by push, pop, or copy, and answer popped values and common-element counts for pairs of versions. | Medium7 | TreeStack | No attempts yet | 1s | 64 MB | Judgeable |
| Minimum spanning tree after deleting one edgeFor each edge, report the MST weight of the graph with that edge removed, or -1 when it disconnects. | Medium7 | Minimum spanning treeTree+1 | No attempts yet | 3s | 256 MB | Judgeable |
| The festival must go onPick M roads of a weighted tree so the longest path using only picked roads is as short as possible. | Medium7 | Binary searchTree+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Bond TourEach parade route is the tree path between two towns, and you report the best contiguous stretch of road weights on it, or zero. | Medium7 | Segment treeTree | No attempts yet | 5s | 256 MB | Judgeable |
| Tree of Almost Clean MoneyEach operation adds generated values to up to 1000 vertices and asks for the sum on the path between two vertices. | Medium7 | TreeSegment tree | No attempts yet | 4s | 256 MB | Judgeable |
| Slant DrillingChoose a ground point over nested contour polygons so the straight-line distance from the surface to the pocket at the origin is shortest. | Medium7 | GeometryTree+1 | No attempts yet | 1s | 256 MB | Judgeable |
| AYBABTUYou cut k tree edges so each of the resulting k+1 regions holds a base and the total cut cost is smallest. | Medium7 | Dynamic programmingTree | No attempts yet | 10s | 512 MB | Judgeable |
| TerroristsGiven a connected graph with at most 50 extra edges past a tree, answer the shortest distance for each query pair. | Medium7 | Shortest pathTree | No attempts yet | 5s | 256 MB | Judgeable |
| Mario and the Evil ToadPick K distinct non-root nodes of a weighted tree and order them to maximize the round trip from the root through them in order. | Medium7 | Dynamic programmingTree+1 | No attempts yet | 3s | 256 MB | Judgeable |
| BiochipsPick exactly M nodes from a rooted tree with given values so no picked node is an ancestor of another and the sum is maximal. | Medium7 | Dynamic programmingTree | No attempts yet | 2s | 512 MB | Judgeable |
| Yonsei University Point GamePlayers paint tree nodes blue and queries ask for the sum of weighted distances from a node to all painted nodes. | Medium7 | Divide and conquerTree+1 | No attempts yet | 5s | 128 MB | Judgeable |
| Costly Binary Search (Small)Find the comparison order that minimizes the worst-case total cost of locating the insertion position when each array slot has its own comparison cost. | Medium7 | Dynamic programmingTree+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Symmetric Trees (Large)Decide whether a color-painted tree can be drawn in the plane with a vertical line of symmetry. | Medium7 | TreeRecursion+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Full Binary Tree (Large)Delete as few vertices as possible from a given tree so the survivors form a full binary tree with a freely chosen root. | Medium7 | Dynamic programmingTree+1 | No attempts yet | 5s | 512 MB | Judgeable |
| World Cup 2010 (Large)Pick the cheapest tickets in a knockout bracket so each team misses at most M[i] of the matches it plays, no matter who wins. | Medium7 | Dynamic programmingTree | No attempts yet | 5s | 512 MB | Judgeable |
| Rainbow TreesCount rainbow edge colorings of a tree where any two adjacent edges differ and any three consecutive edges all differ, modulo 1e9+9. | Medium7 | TreeGreedy+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Mixing Bowls (Large)Given a recipe where each mixture's ingredients are other mixtures, find the minimum number of bowls needed to prepare it. | Medium7 | TreeDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Busiest railway segment (large)Given a tree and Q paths, count how many paths use each edge and report the edge with the maximum count, breaking ties by lexicographic order of endpoints. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TorrentTwo computers start with a file in a tree; each minute, adjacent computers can copy in parallel subject to one copy per computer. Find the minimum minutes until all nodes have the file. | Medium7 | TreeBFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree EditCut one weighted edge of a tree and reattach it elsewhere with the same weight; find the maximum possible diameter. | Medium7 | TreeDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Scrooge Minho 2Given a tree with N cities, place the fewest police stations so that every city and every road is covered, where a station covers its city, its neighbors, and all incident roads. | Medium7 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hongjun and the Tree 2Count the ways to cut edges of a tree so every remaining component has exactly one black vertex, modulo 1e9+7. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Holiday RoadsOn a tree, each of M families picks one of the other N-1 cities uniformly and independently; find the expected number of roads used by every family. | Medium7 | TreeProbability+1 | No attempts yet | 2s | 512 MB | Judgeable |