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,012 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| JuiceGiven a rooted tree with cord capacities and house demands, choose which houses to power so that flow through each cord stays within capacity and the count is maximized. | Medium6 | TreeDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Cuckoo HashingGiven each word's two hash slots, decide whether inserting all words in order avoids an infinite cuckoo eviction chain. | Medium6 | GraphDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| My Cousin ObamaGiven a forest of parent links, find the ancestor path from A0 to B0 that passes through as few mothers as possible. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Starry NightFind 8-connected star clusters in a grid and assign the same letter to clusters that match under rotation and reflection. | Medium6 | DFSMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ants ColonyBuild a weighted tree where each new node attaches to an earlier one, then answer distance queries between pairs of nodes. | Medium6 | TreeDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Another CrisisGiven a company tree and a threshold T percent, find the minimum number of leaf workers who must petition so that a petition reaches the root. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ICPC Strikes AgainGiven a DAG of task dependencies, basic significances, and which employees perform which tasks, compute each employee's salary as the sum of significances of tasks they perform that no other task they perform depends on. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| This Sentence is FalseEach sentence claims another sentence is true or false; decide whether a consistent assignment exists and, if so, maximize the number of true sentences. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| HorseshoesOn an N x N grid (N at most 5) of parentheses, find the longest walk from the top-left cell, visiting each cell at most once, whose collected characters form a run of '(' followed by an equally long run of ')'. | Medium6 | DFSBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Nearby CowsOn a tree of N fields with C(i) cows at each field, report for every field the total cows within distance K, where K is at most 20. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Visiting CowsGiven a tree with N vertices, choose the largest set of vertices with no two adjacent, which is the maximum independent set on a tree. | Medium6 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Chocolate MilkGiven a directed tree with N-1 edges where all flow reaches one sink, list every non-source node that lies on every root-to-sink path. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Great Cow GatheringPick a node of a weighted tree with node weights as the gathering point, and minimize the sum of cow count times distance to that node. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Time TravelProcess add, pop, and rewind-to-earlier-query operations on a recorded list, printing the last element after each query. | Medium6 | StackTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Trick or Treat on the FarmEach stall has one outgoing next pointer. For every starting stall, count how many distinct stalls the walk visits before it first revisits a stall. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Secret MessageGiven M binary messages and N binary codewords, count for each codeword how many messages share a prefix relation with it in either direction. | Medium6 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Watering Plan Check 3Given a grid land divided into fields and a proposed sprinkler plan drawn with letters and underscores, verify the plan and count holes drilled in fences. | Medium6 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cell Phone NetworkGiven a tree of N pastures, choose the fewest vertices so that every vertex is chosen or adjacent to a chosen one. | Medium6 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow TrafficIn a DAG where every edge goes from a lower to a higher numbered node, count how many source-to-barn paths cross each edge and output the maximum. | Medium6 | GraphDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Party at Hali-BulaGiven a company hierarchy tree, find the largest set of employees with no boss and employee both chosen, and report whether that maximum set is unique. | Medium6 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| NetworkGiven an undirected connected graph, count the articulation points whose removal disconnects some other pair of vertices. Input is line-oriented and ends with 0. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Synchronous DesignGiven a circuit of synchronous and asynchronous nodes with delays, report whether it has an asynchronous cycle, exceeds the clock period between synchronous nodes, or is a valid synchronous design. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SpreadsheetEach cell holds an integer or a sum formula referring to other cells; evaluate all formulas and print the resulting grid, with no reference cycles. | Medium6 | GraphTopological sort+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Alien SecurityGiven a directed graph with entry at room 0 and a target ET room, find the room closest to the target such that every path from 0 to the target passes through it, excluding the target itself. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fiber NetworkFor each query in a directed multigraph where every edge is labeled with a set of companies, list the companies that have a path from A to B using only their own edges. | Medium6 | GraphBFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ElectricityGiven an undirected graph, find the maximum number of connected components formed when any single vertex is removed. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A Model RailroadPlace a non-self-crossing path of straight and curved rails in a small grid from a bottom connection to a top connection, maximizing the number of cells used. | Medium6 | DFSBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree PruningGiven a rooted binary tree with colored nodes, prune subtrees to make the whites minus blacks equal exactly D, minimizing the number of prunes. | Medium6 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| HerdingPlace the fewest traps on a grid of arrows so that a cat starting anywhere and following arrows forever eventually enters a trapped cell. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FriendsEach student points to exactly one friend, forming directed cycles; for each query, report whether two students lie on the same cycle and the forward distance between them. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Game Show MathInsert +, -, *, / between the given numbers in order, left to right, so the running value hits the target; output the smallest expression or NO EXPRESSION. | Medium6 | DFSBacktracking+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Mountain PassageFind the minimum count of steps that touch an elevation above the start height, moving on an n by n grid with height changes limited to 2 per step. | Medium6 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tree IsomorphismGiven two rooted trees in pre-order with '#' closing each node's child list, decide whether the trees are isomorphic ignoring node labels. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| JourneyGiven a weighted tree, a start city k, and a set of target cities, find the length of the shortest walk from k that visits every target at least once. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Heating MainCount the ways to lay a single non-crossing path of four fixed pipe shapes from the top-left top side to the bottom-right right side, respecting fixed pipes and blocked garden cells on a grid of at most 10 by 10. | Medium6 | BacktrackingDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FireworksA firework splits into two 45-degree branches after each vertical stage; count the distinct grid squares colored across all stages. | Medium6 | SimulationDFS+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Turning a TreeReroot a given ordered tree at a specified leaf so the counter-clockwise order of neighbors at each node stays the same, then print the new tree. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| PoliticiansGiven ratio relations between politicians that form a connected comparison graph, find the most and least important and their importance ratio to two decimals. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| LiarsGiven claims that candidate a says candidate b lies or tells the truth, decide whether candidates can be split into liars and truth-tellers consistently. | Medium6 | GraphBFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Monthly Railway PassA graph has train and bus edges. Count cities from which every other city is reachable using any number of train edges and at most one bus edge. | Medium6 | GraphDFS+1 | No attempts yet | 2s | 1024 MB | Judgeable |
| UnfoldungFor each cube-built surface, decide whether its graph splits along cut edges, and if not, whether the surface can be unfolded flat. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dolphin PoolGiven up to 20 circles with disjoint centers, count the bounded regions outside all circles that the circles enclose. | Medium6 | GeometryGraph+1 | No attempts yet | 1s | 128 MB | Judgeable |
| A Knight's JourneyFind the lexicographically smallest knight's tour that visits every square of a rectangular board with at most 26 squares exactly once. | Medium6 | BacktrackingDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dory's PhonebookGiven a dictionary of words and a phone number, find every encoding of the number as a space-separated sequence of dictionary words, sorted lexicographically. | Medium6 | TrieBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BonsaiRoot a weighted tree and cut edges of minimum total weight so that no original leaf stays connected to the root. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hiring the CrewGiven a directed graph of sailor demands, find the smallest non-empty vertex set closed under outgoing edges. | Medium6 | GraphDFS | No attempts yet | 4s | 64 MB | Judgeable |
| Playing With DominoGiven up to 1000 dominoes with faces numbered 0 to 6, find the largest number of tiles that can be linked in a single chain where touching squares match. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Transitive ClosureCount off-diagonal pairs (X, Y) with a directed path from X to Y in a graph of up to 2500 vertices and 10000 edges. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SpreadsheetEvaluate a small 9x26 spreadsheet where each cell holds an integer expression with +, -, *, / and cell references, reporting 1000000 if cell A1 is part of a circular reference. | Medium6 | ImplementationDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Jack's SocksGiven an undirected graph of similar socks, decide whether a perfect matching exists and is unique, and print that matching if it is. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| SpeleologyGiven a DAG where chambers are numbered top to bottom, find the maximum number of downward paths from chamber 1 to chamber n that use distinct first corridors and distinct last corridors. | Medium6 | GraphDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Three-Coloring of Binary TreesGiven a binary tree as a digit specification, color each node red, green, or blue so adjacent nodes differ and siblings differ, then report the maximum and minimum number of green nodes. | Medium6 | TreeDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| MatchingsGiven a tree, compute the size of its maximum matching and count how many maximum matchings exist, modulo m. | Medium6 | Dynamic programmingTree+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Cube of a GraphCount vertices, adjacent pairs, and triangles whose incident edges are all nontrivial bridges in a connected graph. | Medium6 | GraphDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Conference TableDecide whether pairs of majors from each university can sit in a ring so paired researchers sit together and neighbors share a major. | Medium6 | GraphDFS | No attempts yet | 1s | 128 MB | Judgeable |
| Jill's Tour PathsList every simple route from the start village to the destination within the distance limit, ordered by length then village order. | Medium6 | BacktrackingDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BoggleFind all dictionary words on each 4x4 Boggle board with 8-direction steps without reuse, then report the total score, longest word, and word count. | Medium6 | TrieDFS+1 | No attempts yet | 10s | 512 MB | Judgeable |
| Welcome PartySplit interns into the fewest teams where each team shares one first-name or last-name initial. | Medium6 | GraphDFS | No attempts yet | 1s | 128 MB | Judgeable |
| Placing RooksPlace as many rooks as possible on an N by N board with pawns so no two share a row or column without a pawn between them. | Medium6 | GraphDFS | No attempts yet | 1s | 128 MB | Judgeable |
| Friendship GraphDecide up to 200000 reachability queries on a directed graph with 2000 vertices, printing 1 when Y is reachable from X. | Medium6 | GraphDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Mirror FieldCount the most reflections a border beam makes bouncing through a grid of diagonal mirrors, or report -1 if it loops forever. | Medium6 | GraphDFS | No attempts yet | 1s | 128 MB | Judgeable |
| Dropping DirectionsPlace the fewest directing signs at 4-way intersections so a walker who otherwise goes straight reaches the goal from any start. | Medium6 | GraphDFS | No attempts yet | 2s | 256 MB | Judgeable |
| Irrigation LinesOpen the fewest row and column lines so every planted cell shares a row or column with an open line. | Medium6 | GraphDFS+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Sky CitiesAdd the fewest bridges so the connected cities stay connected after any single bridge fails, and print the pairs fixed by the leaf-pairing rule. | Medium6 | DFSGraph+1 | No attempts yet | 1s | 256 MB | Judgeable |
| NAFTAFor each K from 1 to S, drill up to K whole columns to drain every touched oil pool and maximize the collected oil. | Medium6 | Dynamic programmingIntervals+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Chicken JoggersPlace the fewest extra lamps so every trail a jogger who starts at intersection 1 and returns after exactly S meters could use has a lamp on one end. | Medium6 | Dynamic programmingTree+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Absurdistan Roads IIIEach city picks one of its incident roads so every road is picked once and the resulting neighbor list is lexicographically smallest. | Medium6 | GraphGreedy+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Farthest node in a weighted treeFor every node of a weighted tree with up to 50000 nodes, print its distance to the farthest node. | Medium6 | TreeDFS | No attempts yet | 1s | 256 MB | Judgeable |
| Odd Cycle in a Directed GraphGiven a directed graph, decide whether it contains an odd directed cycle and output the smallest vertex of a strongly connected component that holds one. | Medium6 | GraphBFS+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Robots and the Oil Transportation SystemTwo robots start at given stations and cover opposite ends of one trunk pipe, minimizing the slower robot travel time. | Medium6 | Shortest pathDFS+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Max FlowCount how many of the K given tree paths pass through each stall and report the largest count. | Medium6 | TreePrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| The Bored Traveling Salesman (Small)Choose a start city and a depth-first ticket tour of the graph so the concatenated first-visit ZIP codes form the smallest number. | Medium6 | BacktrackingDFS+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Treasure Chests (Small)Open all N chests in the lexicographically smallest valid order using keys found inside chests, or report IMPOSSIBLE. | Medium6 | BacktrackingDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Mixing Bowls (Small)Given a recipe tree of mixtures, find the minimum number of bowls needed by choosing the order of preparation. | Medium6 | TreeDFS+1 | No attempts yet | 5s | 512 MB | Judgeable |
| King (Small)On a board of at most 16 squares with burned cells, a king moves to unvisited neighbors; decide who wins under optimal play. | Medium6 | Game theoryDFS+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Modern Art PlagiarismDecide whether the smaller tree is isomorphic to some subtree cut from the larger tree. | Medium6 | TreeDFS+1 | No attempts yet | 50s | 512 MB | Judgeable |
| Tree CountryCount the subsets of K vertices in a tree that form a connected subtree, modulo 1e9+7. | Medium6 | Dynamic programmingTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Happy TreeFind the minimum number of leaves to remove so that no remaining vertex has a descendant whose path distance exceeds that descendant's value. | Medium6 | TreeDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| A Dark Flame Dragon Sleeps in My Left HandFor each node in a weighted tree, find the distance to the farthest other node (the tree's eccentricity). | Medium6 | TreeDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Sum of subtree sizesCount all connected subgraphs of a tree and output the sum of their vertex counts modulo 1e9+7. | Medium6 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Domain clustersGiven a directed graph of domains, find the size of the largest set in which every domain can reach every other domain. | Medium6 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TreeGiven a rooted tree, process a mix of edge deletions and connectivity queries in order, answering YES or NO for each query. | Medium6 | Union-findTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Word Puzzle 2Given a 5x5 letter grid and up to 20000 dictionary words, count how many words can be traced through adjacent cells without reusing a cell. | Medium6 | DFSBacktracking+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Fighting cancerGiven two trees on atoms 1..N, decide whether they are isomorphic as unlabeled graphs and print S or N. | Medium6 | TreeDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Come and GoGiven a mixed graph of one-way and two-way streets, decide whether every pair of intersections is mutually reachable. | Medium6 | GraphDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Free FigurinesGiven two valid nesting configurations of n matryoshka dolls, find the minimum number of place and take-out moves to transform one into the other. | Medium6 | TreeGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Cactus ConstructionGiven a cactus as edge-disjoint paths, simulate the fixed recursive procedure that emits join, recolor, and connect operations assembling it with four colors. | Medium6 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| The Longest Travel RouteGiven a directed weighted graph with at most 18 cities, find the maximum total length of a simple path from city 0 to city n-1. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Phonomenal ReviewsGiven a tree and a set of M marked nodes, find the minimum number of edges Jo must walk to visit every marked node, starting anywhere. | Medium6 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CoggleGiven a 5x5 letter grid and a dictionary, count how many dictionary words can be traced through adjacent cells without reusing a cell. | Medium6 | BacktrackingTrie+1 | No attempts yet | 1s | 512 MB | Judgeable |
| RidgeCount grid cells where rain falling on that cell alone eventually drains to more than one local minimum. | Medium6 | GraphDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Where's Bessie?Given an N x N grid of colors (N up to 20), count the rectangular sub-grids where exactly two colors appear, one forming one connected region and the other forming two or more, and that are not contained in any other such rectangle. | Medium6 | ImplementationBrute force+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Marbles on the treeGiven a rooted ordered binary tree, find the leaf where the K-th marble stops, where each marble at a two-child node goes to the left if left subtree has at most the right subtree's resting marbles, else right. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| KUBC League (Small)Given a tournament on N players, find the longest simple path starting at player 1 and output the lexicographically smallest such path. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Defend the CTP!!!Given a directed graph and many queries C, decide for each C whether 1 can reach C and C can reach N. | Medium6 | GraphDFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Crush FeverOn an N by M grid of 5 piece kinds, choose 3 taps; each tap clears the connected same-kind group of the tapped cell and scores size squared, with pieces falling down after each tap. Maximize total points. | Medium6 | DFSBrute force+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Googlements (Large)Count how many googlement strings could have decayed, through zero or more steps, into a given observed googlement. | Medium6 | GraphDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Tae and Dotori split a chocolate barCount assignments of U cells to T or D so each person's region is connected, the sizes differ by at most K, and neither region contains a 2x2 block. | Medium6 | BacktrackingDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Game MapGiven an undirected connected graph, find the longest simple path where the degree of each successive vertex strictly increases. | Medium6 | GraphDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Go around the LabyrinthDecide whether a walk from the top-left corner can visit the other three corners and come back, where each non-entrance room collapses after one visit. | Medium6 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |