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
TitleLevelTopicsSolvedTime limitMemory limitJudge
The Maze MakersValidate hex-encoded grid mazes by checking that the two openings connect, every cell is reachable, and no cycles create multiple paths.Medium4GraphDFSNo attempts yet1s256 MBJudgeable
QuentoFind a no-revisit path using exactly M digits on the fixed 3x3 board whose left-to-right value equals N and print the lexicographically smallest one.Medium4BacktrackingDFSNo attempts yet1s256 MBJudgeable
Book ClubDecide whether each of N members can receive a distinct liked book, given M like declarations.Medium4GraphBFS+1No attempts yet2s256 MBJudgeable
Binary Mobile WidthCompute the horizontal width of a balanced binary mobile from rod lengths and bead weights using torque balance.Medium4TreeDFSNo attempts yet1s256 MBJudgeable
NetworkAdd the fewest edges to a tree so it stays connected after any single edge breaks, pairing leaves in the prescribed DFS order.Medium4TreeDFS+1No attempts yet1s256 MBJudgeable
C.S.I.: P15Count ground-connected 8-connected flower components and isolated /\/\ bird patterns in each ASCII picture.Medium4DFSString matchingNo attempts yet1s256 MBJudgeable
Articulation pointsFind and list in increasing order every vertex whose removal increases the number of connected components in an undirected graph.Medium4DFSGraphNo attempts yet1s256 MBJudgeable
SV FiltersCompute the max flow between nodes 0 and 1, then remove the size-P edges reachable from node 0 and compute the max flow again.Medium4GraphBFS+1No attempts yet1s256 MBJudgeable
Job AssignmentAssign each of N employees at most one job they can do so the number of finished jobs is as large as possible.Medium4GraphDFSNo attempts yet2s256 MBJudgeable
Job Assignment 2Assign each of M jobs to one of N employees who can do it with at most two jobs per employee to handle as many jobs as possible.Medium4GraphBFS+1No attempts yet4s256 MBJudgeable
Graph bridgesFind every bridge in a connected undirected graph and print them sorted by endpoint.Medium4DFSGraphNo attempts yet1s256 MBJudgeable
Candy BombersAssign each pilot to at most one plane they can fly to maximize the number of planes sent.Medium4GraphDFSNo attempts yet1s256 MBJudgeable
Lowest Common AncestorGiven a rooted tree, answer each query with the number of the deepest vertex that is an ancestor of both given vertices.Medium4TreeDFSNo attempts yet3s256 MBJudgeable
Lowest Common Ancestor 2Given a rooted tree with up to 100,000 nodes, answer up to 100,000 lowest common ancestor queries.Medium4TreeDFSNo attempts yet1.5s256 MBJudgeable
Cube IV (Small)Given a square grid holding 1 to S squared, find the smallest start of the longest chain that steps to an orthogonal neighbor one higher and report its length.Medium4DFSDynamic programming+1No attempts yet5s512 MBJudgeable
Minimum Clicks in MinesweeperFind the fewest clicks that reveal every safe cell, since one click opens each zero region and each remaining safe cell costs one click.Medium4DFSGraph+1No attempts yet5s512 MBJudgeable
Diamond Inheritance (Small)Decide whether any pair of classes in each inheritance diagram has two distinct inheritance paths between them.Medium4GraphDFSNo attempts yet5s512 MBJudgeable
Twibet (Large)In a graph where each monk follows exactly one other, count for every starter how many monks hear the whisper passed down through followers.Medium4GraphDFSNo attempts yet5s512 MBJudgeable
Watersheds (Small)Given a height grid, follow each cell's outflow to its sink and label cells by shared sink, choosing basin letters to make the row-wise string smallest.Medium4GraphDFS+2No attempts yet5s512 MBJudgeable
The Enemy of My EnemyDecide whether the N people can be split into two camps so that every given hostile pair lands on opposite sides, which is exactly bipartiteness.Medium4GraphBFS+2No attempts yet2s512 MBJudgeable
Scrooge MinhoGiven a tree, place one fire station at the vertex minimizing the maximum distance to any other vertex, and output that distance.Medium4TreeGraph+2No attempts yet2s512 MBJudgeable
TreeGiven up to 10 graphs, decide for each whether it is a tree, allowing self-loops and duplicate edges.Medium4GraphUnion-find+1No attempts yet2s512 MBJudgeable
Far Far AwayGiven a directed tree rooted at city 1 with weighted edges, find the maximum root-to-node path weight, or -1 if it stays below M.Medium4TreeDFS+2No attempts yet2s512 MBJudgeable
A Series of TubesGiven a connected undirected graph, decide whether its edges can be oriented so that the result stays strongly connected.Medium4GraphDFSNo attempts yet1s512 MBJudgeable
DragsterGiven pairwise win probabilities and a binary elimination bracket, compute the probability that driver 1 wins the tournament.Medium4ProbabilityTree+1No attempts yet2s512 MBJudgeable
CoordinatesGiven differences in x and y between pairs of bases, reconstruct each base's coordinate, fixing base 1 at (0,0).Medium4GraphBFS+2No attempts yet3s512 MBJudgeable
Wheat HarvestFind each connected block of 1s, order blocks by area, and label every cell with its block's rank.Medium4GraphDFS+1No attempts yet1s128 MBJudgeable
MoocastEach cow has a point and a broadcast radius; find the starting cow whose one-way reachable set is largest.Medium4GraphDFS+1No attempts yet2s512 MBJudgeable
Company culture 1Given each employee's manager and a list of praises, propagate every praise value down the whole subtree and print the total each employee receives.Medium4TreeDFS+2No attempts yet2s512 MBJudgeable
Evaluation Order of Assignments (Small)Given assignment statements where each expression is a function call, decide whether some order evaluates every variable, which fails exactly when a dependency cycle exists.Medium4GraphTopological sort+2No attempts yet5s1024 MBJudgeable
EvaluationGiven assignment statements where each value depends on argument variables, decide whether some evaluation order resolves every dependency.Medium4GraphTopological sort+1No attempts yet5s512 MBJudgeable
Prerequisite CoursesGiven prerequisite pairs between courses, find the earliest semester each course can be completed when unlimited courses may be taken per semester.Medium4GraphTopological sort+2No attempts yet5s256 MBJudgeable
Secret Chamber at Mount RushmoreGiven directed letter translations, decide for each pair of words whether every letter of the first can reach the matching letter of the second.Medium4GraphDFS+2No attempts yet1s512 MBJudgeable
Cut Vertices and BridgesGiven a tree with N vertices and queries, report for each query whether a specified vertex is a cut vertex or a specified edge is a bridge.Medium4TreeDFS+2No attempts yet1s512 MBJudgeable
Sheba's AmoebasCount the number of disjoint closed loops formed by black pixels on a grid, where each black pixel has exactly two black neighbors among its eight surrounding cells.Medium4GraphDFSNo attempts yet2s512 MBJudgeable
Police StationIn a directed graph, list every vertex from which all other vertices are reachable by following arrows forward.Medium4GraphDFS+1No attempts yet2s1024 MBJudgeable
League of Overwatch at Moloco (Hard)Given n employees and m conflict pairs, decide whether the employees can be split into two non-empty groups so that no pair shares a group.Medium4GraphDFS+1No attempts yet2s512 MBJudgeable
N-Step SyllogismEach premise says all a are b; for each conclusion x is y, decide whether following the implication chain from x reaches y.Medium4GraphDFS+2No attempts yet2s128 MBJudgeable
Choose your own pathGiven a directed graph of story pages starting at page 1, check whether every page is reachable, then report the shortest distance to any ending page.Medium4GraphBFS+2No attempts yet2s512 MBJudgeable
Coolest Ski RouteGiven a DAG of slopes with condition values, find the maximum total condition along any downhill path.Medium4GraphDynamic programming+2No attempts yet2s512 MBJudgeable
Mooyo MooyoRepeatedly find connected groups of at least K equal nonzero cells on a 10-wide grid, erase them all at once, apply gravity, and print the final board.Medium4DFSSimulation+2No attempts yet2s512 MBJudgeable
Grass PlantingGiven a tree with N fields, plant grass so that no two fields at distance one or two share a type, and output the minimum number of types needed.Medium4TreeGreedy+1No attempts yet2s512 MBJudgeable
Milk FactoryGiven a directed tree on N nodes, find the smallest node reachable from every other node, or output -1 if none exists.Medium4GraphDFS+2No attempts yet2s512 MBJudgeable
Road ConstructionGiven a tree with n countries and weighted edges, sum over all edges of weight times the absolute difference in size of the two components the edge splits the tree into.Medium4TreeDFS+2No attempts yet2s512 MBJudgeable
I Will Be Your Bridge!A tree lost one edge, splitting it into two components. Print any pair of islands, one from each component, that reconnects the tree.Medium4GraphDFS+2No attempts yet1s512 MBJudgeable
Baba is RabbitGiven commands of the form p is q, find all objects reachable from Baba by applying one or more commands, printed in lexicographic order.Medium4GraphDFS+2No attempts yet1s512 MBJudgeable
Gugu the RaccoonGiven a weighted tree rooted at node 1, find the maximum distance from node 1 to any other node.Medium4TreeDFS+2No attempts yet1s1024 MBJudgeable
EmacsCount the non-overlapping, non-touching rectangles of '*' characters in an N by M grid.Medium4ImplementationArray+2No attempts yet1s512 MBJudgeable
Toy AlliancesGiven N toys and M dislike pairs, decide whether the toys can be split into two alliances so no dislike pair shares a side, which is checking bipartiteness of the graph.Medium4GraphBFS+2No attempts yet1.5s256 MBJudgeable
CocktailGiven a tree of N ingredients linked by N-1 known mass ratios, compute the smallest positive integer masses that satisfy every ratio.Medium5TreeDFS+2No attempts yet2s128 MBJudgeable
Tree DiameterGiven a weighted tree with up to 100,000 vertices, compute the diameter as the maximum distance between any two vertices.Medium5TreeDFS+2No attempts yet2s256 MBJudgeable
Survivable Diagnostic RulesGiven up to 200,000 two-literal rules over 20,000 boolean symptoms, decide via 2-SAT whether an assignment exists that avoids triggering any rule.Medium5GraphDFS+1No attempts yet5s128 MBJudgeable
Farm ManagementCount 8-directionally connected groups of equal-height cells in a grid where every outside neighbor is strictly lower.Medium5BFSDFS+2No attempts yet2s128 MBJudgeable
Finding Notebook OwnersGiven student-laptop candidate pairs, compute the maximum bipartite matching to maximize the number of students who get a laptop they listed.Medium5GraphDFS+1No attempts yet2s128 MBJudgeable
Solving ProblemsGiven N interest values and a rule to move forward by 1 or 2 steps starting at problem 1, find the minimum number of problems solved before the range of solved values reaches at least V.Medium5Dynamic programmingGraph+2No attempts yet2s128 MBJudgeable
Minsik-First SearchImplement a DFS variant that picks the middle unvisited neighbor when their count is odd and the smallest when even, then print the first-visit order from vertex 1.Medium5DFSImplementation+1No attempts yet1s128 MBJudgeable
Broken CalculatorStarting from 1 on a calculator limited to D digits, find the largest value reachable after exactly P multiplications by digits 2-9, or report -1 if impossible.Medium5BacktrackingBrute force+2No attempts yet2s128 MBJudgeable
Roads of the Northern CountryGiven the edges of a weighted tree of up to 10,000 cities, compute the length of the tree's diameter (the longest path between two nodes).Medium5TreeGraph+2No attempts yet1s128 MBJudgeable
HistoryGiven directed precedence edges among up to 400 events, determine for each query pair whether one event's order relative to the other is fixed by transitivity.Medium5GraphBFS+2No attempts yet1s128 MBJudgeable
New Year PartyPick a maximum-score guest list from a company tree so no employee and their direct manager both attend, computed with and without the root.Medium5Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
Distance Between VerticesGiven a weighted tree with up to 40,000 nodes, answer up to 10,000 queries about the path distance between two vertices, requiring an LCA-based approach for efficiency.Medium5TreeBinary search+2No attempts yet2s128 MBJudgeable
The Famous Seven PrincessesCount connected 7-cell shapes on a 5x5 grid of S/Y students where at least 4 cells are S.Medium5BacktrackingDFS+1No attempts yet2s256 MBJudgeable
Alphabet PathFind the longest path from the top-left cell of a grid moving to adjacent cells while never revisiting a letter already used, maximizing visited cells.Medium5BacktrackingDFS+1No attempts yet2s256 MBJudgeable
Bug on a TreeGiven a tree with fruit values on vertices, find the maximum sum path (simple path) and its smallest-numbered starting endpoint.Medium5TreeDynamic programming+1No attempts yet2s128 MBJudgeable
Checking CausalityGiven send/receive events across computers with local clocks, detect whether the induced ordering constraints form a cycle indicating a causality violation.Medium5GraphTopological sort+1No attempts yet1s128 MBJudgeable
Tree CuttingGiven a tree with n vertices, find the minimum number of edges to cut so some resulting piece has exactly m vertices, or report impossibility.Medium5TreeDynamic programming+1No attempts yet2s128 MBJudgeable
Height OrderGiven pairwise shorter-than relations between students, count how many students have their exact height rank fully determined by transitivity.Medium5GraphDFS+1No attempts yet1s128 MBJudgeable
Finding the Middle MarbleGiven pairwise heavier-than relations among N odd marbles, count marbles that must be eliminated as the possible median using transitive closure of the order.Medium5GraphDFS+1No attempts yet1s128 MBJudgeable
RestaurantsGiven a graph with up to 100000 nodes and edges, decide if edges can be 2-colored so every vertex of degree at least 2 sees both colors among its incident edges.Medium5GraphDFS+1No attempts yet1s128 MBJudgeable
Handong Does Not Want to Study!Given a functional graph where each node points to exactly one other node, find the starting node whose path visits the most distinct nodes before repeating, breaking ties by smallest index.Medium5GraphDFS+1No attempts yet1s128 MBJudgeable
GemsGiven a tree, assign positive integer prices to vertices so adjacent vertices differ, minimizing total sum, essentially a greedy coloring based on tree structure.Medium5TreeGreedy+1No attempts yet1s128 MBJudgeable
GodfatherGiven an undirected tree, find all vertices that minimize the largest connected component size after removal (the tree centroid(s)).Medium5TreeDFS+1No attempts yet2s64 MBJudgeable
Router Placement to Minimize Maximum TTLGiven a tree, pick the vertex that minimizes the largest distance to any other vertex, and output that minimum maximum distance (the tree's radius).Medium5TreeGraph+2No attempts yet1s128 MBJudgeable
CaterpillarGiven up to 100 nodes, decide whether the graph is a connected tree whose every node lies on or adjacent to some single path.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Ancient HieroglyphsDecode a hex bitmap, count enclosed white regions (holes) inside each connected black shape, and map each shape's hole count to a hieroglyph code.Medium5GraphDFS+2No attempts yet1s192 MBJudgeable
FrenemiesFor each dataset, sum the signed scores of all simple paths without neutral links between a given person and every other person.Medium5DFSGraph+2No attempts yet1s128 MBJudgeable
The Sidewinder Sleeps ToniteGiven a drawn grid of segments and cell numbers, decide whether the drawing is a single closed loop matching every numbered cell.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Signal StrengthFind the maximum signal strength reaching switch N-1 from switch 0 through a switch network with gain or loss multipliers on nodes and edges.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Mobiles AlabamaParse a nested mobile description and compute, for each bar, the tie point that balances the weights hanging from its two sides.Medium5TreeDFS+2No attempts yet1s128 MBJudgeable
TreesGiven an undirected graph, count its connected components that contain no cycle and report the count per test case.Medium5GraphUnion-find+2No attempts yet1s256 MBJudgeable
Robots on a GridCount monotone right/down paths from the top-left to the bottom-right of an n by n grid with blocked cells, modulo 2^31-1, and report whether the goal is reachable at all, or reachable only with up and left moves allowed.Medium5Dynamic programmingDFS+2No attempts yet1s128 MBJudgeable
Royal SuccessionGiven parent pairs for N people, compute each claimant's inherited fraction of the founder's blood and print the claimant with the largest fraction.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Image SegmentationGiven an H by W color image, band each RGB value by dividing by S, then count 8-connected regions of equal band triples whose pixel size is at least L.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Manito ChainsGiven a permutation of N people, count the number of cycles in its functional graph. The input ends when N is 0.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Road TripGiven a weighted tree rooted at city 1, remove exactly one non-root vertex so the round trip from city 1 covering all remaining cities is shortest, and report that length.Medium5TreeDFS+2No attempts yet1s128 MBJudgeable
Milk SchedulingGiven task durations and precedence constraints that form a DAG, find the minimum makespan when unlimited workers milk cows in parallel.Medium5GraphTopological sort+2No attempts yet1s128 MBJudgeable
Tea TimeStarting from a graph of known meetings, two cows meet whenever they share a mutual friend, and after all rounds settle, answer queries about whether each pair has met.Medium5GraphUnion-find+2No attempts yet1s128 MBJudgeable
Pasture WalkingGiven a weighted tree with N vertices and Q queries, find the path length between each queried pair of vertices.Medium5TreeDFS+2No attempts yet1s128 MBJudgeable
Treasure CaveGiven a binary branching from passage 1, find the list of passages on the unique path from the entrance to passage T and its length.Medium5TreeDFS+2No attempts yet1s128 MBJudgeable
Cow ContestGiven the winners of head-to-head matches, count how many cows have a skill rank that is fully forced by the results.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
The Loathesome Hay BalerRollers touch when center distance equals the sum of radii; find the path from the drive roller to the take-off roller and sum the absolute speeds, truncated.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
The Die Is CastRead a pixel image, split non-background pixels into dice connected by shared edges, count the dot regions inside each die, and print the counts sorted.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Traffic PlanningGiven a directed graph and a start node, list the nodes not reachable from the start by a path of one or more edges; print OK if none.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Median Weight BeadGiven weighted comparisons between beads, count how many beads cannot be the median because at least (N+1)/2 beads are known heavier or lighter.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
SpreadsheetEvaluate each spreadsheet cell, treating formula cells as sums of other cells, and mark any cell involved in a dependency cycle as undefined.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
SubsetsGiven inequalities where a set name contains either an element or another set name, find each named set's minimal required elements.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
All Roads Lead Where?Given a tree of cities rooted at Rome and query pairs, print the unique shortest path between each pair as the first letters of the cities on the route.Medium5TreeDFS+2No attempts yet1s128 MBJudgeable
Tree CuttingOn a tree of N nodes, print every node whose removal leaves each connected piece with at most floor(N/2) nodes, or NONE.Medium5TreeDFS+2No attempts yet1s128 MBJudgeable
TähekabeOn an N x N letter grid, decide for each of up to 10 query words whether a simple path from the start cell spells it, without reusing a cell.Medium5BacktrackingDFS+2No attempts yet1s1024 MBJudgeable
RailwayGiven a weighted tree, compute the total weight of the unique path between each queried pair of cities.Medium5TreePrefix sum+1No attempts yet1s32 MBJudgeable