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
DecisionCount connected dark regions on a grid where each cell is a diagonal half or a full square, connecting only through shared cell edges.Medium5GraphDFS+2No attempts yet1s512 MBJudgeable
Piggy BanksEach key i sits in some bank; opening a bank frees its keys. Find the minimum number of banks to smash to reach all N banks.Medium5GraphDFS+2No attempts yet3s128 MBJudgeable
Super-Fast Circular RacesGiven a directed graph where each vertex has out-degree and in-degree at most two, count the ways to cover every vertex with vertex-disjoint simple directed cycles, modulo 10000, or report NIE if impossible.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
WarehousesMove goods along tree roads so every warehouse holds the average amount at minimum transport cost.Medium5TreeGreedy+1No attempts yet1s512 MBJudgeable
Frozen SprinklersCut pipes with minimum total force so no water flows from the central node to any leaf sprinkler in the tree.Medium5Dynamic programmingTree+1No attempts yet3s128 MBJudgeable
Term ProjectEach student picks exactly one partner, only directed cycles form teams, so count the students outside all cycles.Medium5DFSGraphNo attempts yet3s256 MBJudgeable
CSS Selector MatchingGiven a nested div document and up to five CSS selectors with descendant and child combinators, print the matching element ids in document order.Medium5TreeDFS+1No attempts yet10s256 MBJudgeable
Senior PostmenThe program replays the given stack walk on the street graph and prints each cycle it extracts in order.Medium5SimulationGraph+2No attempts yet1s256 MBJudgeable
Jury JeopardyReconstruct the ASCII tree maze that yields each given right-hand-rule robot walk.Medium5SimulationDFS+1No attempts yet3s256 MBJudgeable
Intrepid climberStarting from the root of a weighted tree, visit all marked nodes with free descents and costly climbs at minimum total energy.Medium5TreeDFS+1No attempts yet3s256 MBJudgeable
Magneto MagnetsDecide whether all magnets can join into one closed chain with matching polarities at every joint.Medium5GraphDFSNo attempts yet1s256 MBJudgeable
Cactus or notDecide whether a connected undirected graph is a cactus where each vertex lies on at most one simple cycle.Medium5DFSGraphNo attempts yet1s32 MBJudgeable
PipesFind every pipe whose removal disconnects the spring network and print them sorted by endpoint numbers.Medium5DFSGraphNo attempts yet2s32 MBJudgeable
Cantina of BabelGiven each character's spoken and understood languages, remove as few characters as possible so every remaining pair can exchange messages through translators.Medium5GraphDFSNo attempts yet2s256 MBJudgeable
BoggleFind every dictionary word that can be spelled on each letter grid with adjacent cells and no cell reused, treating q as qu.Medium5BacktrackingTrie+1No attempts yet1s256 MBJudgeable
CheckersFind the Black piece that captures every White piece in one chained jump, or report Multiple or None.Medium5BacktrackingDFS+1No attempts yet2s256 MBJudgeable
CheckersCount the black kings that can capture all white kings in one chain of diagonal jumps.Medium5BacktrackingDFSNo attempts yet2s256 MBJudgeable
Fairland (Small)Marie keeps the largest manager-closed team containing herself whose salaries span at most D.Medium5TreeDFS+2No attempts yet5s512 MBJudgeable
Technology PlanningPlan the smallest set of technologies covering every goal plus its dependencies, then print the lexicographically smallest valid research order.Medium5Topological sortGraph+2No attempts yet5s512 MBJudgeable
Watersheds (Large)Each cell drains to its lowest neighbor, sinks define basins, and each basin gets the letter that makes the row-major label string smallest.Medium5GraphDFS+2No attempts yet5s512 MBJudgeable
Cheating a Boolean Tree (Large)Given a complete binary tree of AND/OR gates with fixed leaf values, find the fewest changeable gates to flip so the root equals V, or report IMPOSSIBLE.Medium5Dynamic programmingTree+2No attempts yet5s512 MBJudgeable
Traffic (Small)Given a tree and Q tickets, count how many tickets use each edge along the unique path, then report the edge with the largest count (smallest station pair on ties).Medium5TreePrefix sum+2No attempts yet2s512 MBJudgeable
Bus RoutesOn a tree with N stops, every ordered pair sends a bus along the unique path; for each stop count how many of the N(N-1) buses halt there, including endpoints.Medium5TreeMath+1No attempts yet3s1024 MBJudgeable
ABCDEGiven an undirected friendship graph, decide whether it contains a simple path of five distinct vertices, that is, a path with four edges.Medium5GraphDFS+2No attempts yet2s512 MBJudgeable
Aurora PrincessGiven each person's parents and a list of people who die or leave the country, count how many remain alive with both parents alive in Korea.Medium5GraphDFS+1No attempts yet1s32 MBJudgeable
DwarvesGiven strict size comparisons between named dwarves, decide whether the statements are mutually consistent.Medium5GraphTopological sort+2No attempts yet2s512 MBJudgeable
PercolationGiven an M by N grid of conducting (0) and blocking (1) cells, decide whether any conducting cell in the top row connects to a conducting cell in the bottom row through edge-adjacent conducting cells.Medium5GraphDFS+2No attempts yet1s512 MBJudgeable
Youngest BossGiven a directed acyclic chain of command, process swaps of two employees and report the age of the youngest superior of a queried employee, or * if none exists.Medium5GraphDFS+1No attempts yet1s512 MBJudgeable
Minimum number of islandsGiven a grid of land, water, and cloud cells, find the minimum possible number of 4-connected land islands if every cloud can be either land or water.Medium5GraphDFS+2No attempts yet2s512 MBJudgeable
It's Raining, ManGiven a set of distinct cards, decide whether they can be ordered in a row so that each neighbouring pair shares a rank or a suit.Medium5GraphDFSNo attempts yet2s512 MBJudgeable
Spreadsheet CalculatorCompute the value of every cell in a spreadsheet where cells hold either a non-negative number or a sum formula referring to other cell addresses, with no circular references.Medium5GraphDFS+1No attempts yet1s512 MBJudgeable
Company Culture 2Given a tree of boss relations, apply subtree-wide praise additions in real time and answer point total queries.Medium5TreeDFS+2No attempts yet5s512 MBJudgeable
Company Culture 3Employees sit in a rooted tree. A praise of w given to employee i from a subordinate adds w to i and every ancestor up to the president; type 2 queries ask an employee's running total.Medium5TreeDFS+2No attempts yet2s512 MBJudgeable
Project SchedulingGiven each task's duration and its prerequisite tasks, find the minimum total time to finish the whole project.Medium5Topological sortDynamic programming+2No attempts yet2s512 MBJudgeable
Sweet, sour, bitter, saltyCut edges of a rooted binary tree so that at least X resulting components each contain at least K nodes, minimizing total cut cost.Medium5TreeDynamic programming+2No attempts yet2s512 MBJudgeable
Roasting Emma is a barista tooGiven a weighted tree, compute for every vertex the sum of shortest distances to all other vertices.Medium5TreeDFS+2No attempts yet1.5s128 MBJudgeable
Family TreeGiven a set of mother-child pairs, classify the relationship between two cows as siblings, direct ancestor, aunt, cousins, or unrelated, following a fixed rule order.Medium5GraphDFS+2No attempts yet2s512 MBJudgeable
Pants On FireGiven n true statements of the form "a are worse than b" that form a partial order, classify each of m queries as Fact, Alternative Fact, or Pants on Fire by transitive reachability.Medium5GraphDFS+2No attempts yet2s512 MBJudgeable
Jumping King Jelly (Small)Given an N by N board with jump numbers, move only right or down from the top-left and reach the bottom-right, or report failure.Medium5DFSBacktracking+2No attempts yet1s128 MBJudgeable
Sheba's AmoebasCount closed loops of # pixels in an m by n image, where loops may be nested but never touch or overlap.Medium5DFSGraph+2No attempts yet2s512 MBJudgeable
Seungbeom CorporationMaintain balances on a company mentor tree while updates add a value to one employee and every employee below them.Medium5TreeDFS+1No attempts yet1s256 MBJudgeable
Two DotsGiven a grid of colored dots, decide whether any cycle of four or more same-colored dots exists, where consecutive dots touch by an edge.Medium5DFSGraph+2No attempts yet2s512 MBJudgeable
Divide by 3, Multiply by 2Given a shuffled copy B of the sequence produced by a divide-by-3, multiply-by-2 game, reconstruct the original order A.Medium5GraphDFS+2No attempts yet2s512 MBJudgeable
Icy PerimeterFind the connected component of '#' cells with the largest area, breaking ties by smallest perimeter, where perimeter counts all edges touching non-component cells including holes.Medium5GraphDFS+2No attempts yet2s512 MBJudgeable
Escape the MazeEach cell holds a direction to the next cell; count how many starting cells eventually leave the N by M grid.Medium5GraphDFS+2No attempts yet1s512 MBJudgeable
Drug Investigation UnitGiven a directed supply graph and a set of arrested suppliers, count how many remaining suppliers still receive drugs from some origin.Medium5GraphDFS+2No attempts yet1s256 MBJudgeable
Promoting a ClubGiven a forest, choose the fewest vertices so that every vertex is either chosen or adjacent to a chosen one (minimum dominating set on a forest).Medium5TreeDynamic programming+2No attempts yet2s256 MBJudgeable
Unstable SubstancesEach substance conflicts with exactly one other; choose a subset with no conflicting pair to maximize total weight.Medium5GraphDynamic programming+2No attempts yet1.2s256 MBJudgeable
Search EngineGiven directed links between websites, compute one website's trust score by summing scores of linking sites only when no cycle would result.Medium6GraphDFS+2No attempts yet2s128 MBJudgeable
News BroadcastGiven a rooted tree, each informed employee calls one subordinate at a time, each call lasting one minute; find the minimum time until every employee knows the news.Medium6TreeDFS+2No attempts yet2s128 MBJudgeable
Word PuzzleCount how many words from a fixed dictionary can be spelled by paths of adjacent, non-repeating cells in a 5x5 letter grid.Medium6TrieBacktracking+2No attempts yet2s128 MBJudgeable
Euler CircuitGiven an adjacency matrix with possible multi-edges, output a valid Euler circuit or -1 if none exists.Medium6GraphDFS+1No attempts yet3s512 MBJudgeable
Sum of Tree Path WeightsGiven a weighted tree, compute the sum over all vertex pairs of the product of edge weights along their connecting path, modulo 1e9+7.Medium6TreeDFS+2No attempts yet2s128 MBJudgeable
Making Roads One-WayDecide if every two-way road between N cities can be made one-way so that no directed cycle remains in the whole road network.Medium6GraphDFS+1No attempts yet2s128 MBJudgeable
Number Connection PuzzleFind a Hamiltonian path on an m by n grid (both even, up to 8) connecting two given endpoints, moving only to adjacent cells without crossing itself, or report -1.Medium6BacktrackingGraph+1No attempts yet5s128 MBJudgeable
Garden PruningFind the minimum number of edge cuts needed to prune a tree down to exactly m vertices while keeping it connected.Medium6Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
Painting RoofsGiven a tree of houses and M paint costs, assign a color to every house minimizing total cost so that adjacent houses have different colors.Medium6Dynamic programmingTree+2No attempts yet2s128 MBJudgeable
Finding the Maximum Score PathFind the maximum-score simple path from the top-left to bottom-right cell of an N x N grid moving only in four directions without revisiting cells.Medium6BacktrackingDFS+2No attempts yet2s128 MBJudgeable
Greedy PandaFind the longest strictly increasing path through adjacent cells in an n x n grid using memoized DFS.Medium6DFSDynamic programming+1No attempts yet2s256 MBJudgeable
Finding SnakesCount connected 1-shapes in a grid that form a simple path (snake) with no possible one-cell extension at either end.Medium6GraphDFS+1No attempts yet2s128 MBJudgeable
Cactus GraphGiven a graph described by edge-paths, verify it is a cactus and count connected spanning subgraphs that remain cactus graphs.Medium6GraphDFS+1No attempts yet2s128 MBJudgeable
Strongly Connected ComponentsCompute all strongly connected components of a directed graph with up to 10,000 vertices and 100,000 edges, printing each component sorted, ordered by its smallest vertex.Medium6GraphDFSNo attempts yet2s128 MBJudgeable
Molecule DecompositionFind the minimum number of edge cuts on a tree needed to isolate a connected subtree of exactly M nodes.Medium6TreeDynamic programming+1No attempts yet2s128 MBJudgeable
Rock Paper ScissorsGiven N students each with two literal-style predictions (turn, gesture) among only rock/scissors, decide if a gesture sequence exists satisfying at least one prediction per student, essentially 2-SAT.Medium6GraphUnion-find+1No attempts yet2s128 MBJudgeable
Work ProcessGiven a tree of supervisors, compute the tree height and the maximum number of nodes removable while keeping tasks completable within that same height using limited workers per time slot.Medium6TreeGreedy+1No attempts yet2s128 MBJudgeable
Apple TreeGiven a DFS 0/1 traversal string of a tree and two marked positions, find the smallest subtree (by matching visit/return indices) that contains both marked vertices.Medium6TreeStack+1No attempts yet2s128 MBJudgeable
Adventure GameGiven a maze of rooms with gold-boosting or gold-costing conditions, decide if room n is reachable from room 1 following graph edges under gold constraints.Medium6GraphBFS+1No attempts yet1s128 MBJudgeable
Unknown PolygonReconstruct the boundary cycle of a triangulated (or diagonal-split) convex N-gon from its unordered edge and diagonal list, starting at label 1 with the smaller second label chosen.Medium6GraphDFS+1No attempts yet2s128 MBJudgeable
Mirror-Symmetric Tree GraphDecide whether a given connected graph can be formed by gluing a rooted tree to its mirrored copy at every non-root leaf.Medium6GraphTree+1No attempts yet1s128 MBJudgeable
Salary Management at a Car FactoryGiven a company tree with salary updates that add a value to all subordinates of a node and queries for a single employee's current salary, answer efficiently using an Euler tour and a range-update point-query structure.Medium6TreePrefix sum+1No attempts yet1s256 MBJudgeable
No U-TurnsGiven a grid with roads and buildings, decide if every road cell is free of dead ends by checking whether from each road cell you can return without an immediate U-turn.Medium6GraphDFS+1No attempts yet1s128 MBJudgeable
Debt Settlement in Wonseop CityGiven a functional graph where each citizen owes money to exactly one creditor, find the minimum total money injected so all debts can be paid via chains of repayments.Medium6GraphGreedy+1No attempts yet1s128 MBJudgeable
Detective HongzGiven a DAG of causal relations and a set of known events, determine every additional event forced to have occurred by forward implication and the backward rule that a caused event needs at least one occurring predecessor.Medium6Topological sortGraph+1No attempts yet1s128 MBJudgeable
Tournament Rank RangeGiven a single-elimination bracket's match winners, determine each queried player's best possible and worst possible final ranking consistent with the known beat relations.Medium6TreeDFS+1No attempts yet1s128 MBJudgeable
Fair DistributionGiven a tree of farmers with equal initial money and required amounts, find the minimum number of edge transactions, in valid order, to make everyone reach their requirement.Medium6TreeGreedy+1No attempts yet1s128 MBJudgeable
Coin StatementsGiven L positions and N clauses of the form (position i is X) OR (position j is Y), reconstruct any assignment satisfying all clauses, or report impossibility (2-SAT).Medium6GraphDFS+1No attempts yet1s128 MBJudgeable
ONEFind the minimum fuel a plough starting at a fixed node needs to traverse every edge of a weighted tree at least once, ending anywhere.Medium6TreeDFS+2No attempts yet1s128 MBJudgeable
MessengersGiven a tree with per-city messenger costs, compute for every city the minimum time to relay a message to the root via edge lengths and messenger switching costs.Medium6TreeDynamic programming+1No attempts yet1s128 MBJudgeable
TriangulationGiven a triangulated colored convex polygon, find the maximum number of triangulation diagonals that can be cut without separating same-colored triangles.Medium6Union-findGraph+1No attempts yet3s128 MBJudgeable
Galaxy InterconnectionGiven a low-degree graph with a proper k-coloring, output -1 if any edge shares a color, otherwise count vertices that start a simple path of k vertices visiting all k colors.Medium6GraphDFS+1No attempts yet3s256 MBJudgeable
IdolGiven judges' two-literal votes as a 2-SAT instance, decide if there's a valid advance/eliminate assignment where contestant 1 advances and no judge's clause is fully violated.Medium6GraphDFS+1No attempts yet1s128 MBJudgeable
Common Subexpression EliminationCompress a labeled binary expression tree into a minimal DAG by merging identical subexpressions and print it with backreference numbers to earlier nodes.Medium6Hash mapTree+2No attempts yet1s128 MBJudgeable
Moving to NurembergGiven a weighted tree and visit frequencies at some nodes, find the node minimizing total weighted round-trip distance and list all optimal nodes.Medium6TreeDFS+1No attempts yet1s128 MBJudgeable
System EngineerGiven jobs each with a set of eligible servers, compute the maximum bipartite matching size assigning jobs to distinct servers.Medium6GraphBFS+1No attempts yet1s128 MBJudgeable
Cycles of LanesGiven a connected graph where every edge lies in at most one simple cycle, find the length of the longest simple cycle across all test cases.Medium6GraphDFS+1No attempts yet1s128 MBJudgeable
The Computer GameGiven a diamond-shaped lattice grid with some cells blocked, count all nonempty subsets of free cells that form a single connected (4-adjacency) region.Medium6Brute forceGraph+2No attempts yet1s128 MBJudgeable
Perfect Election!Given boolean 2-SAT style clauses over candidates being elected or not, determine if a satisfying election outcome exists.Medium6GraphDFS+1No attempts yet3s256 MBJudgeable
Monster TrapGiven up to 100 line segments around the origin, decide whether they form a closed barrier that completely encloses the origin with no gap for the monster to escape through.Medium6GeometryGraph+1No attempts yet1s128 MBJudgeable
Soccer TacticsGiven a directed graph, find every vertex from which all other vertices are reachable, or report that none exists.Medium6GraphDFS+2No attempts yet1s256 MBJudgeable
Show Me the MoneyGiven consistent exchange rates among at most 8 currencies and a requested amount, find the substitute currency giving the smallest value that is at least the request, using at most 100000 units.Medium6GraphDFS+2No attempts yet3s128 MBJudgeable
MobileGiven a mobile's arm structure and pivot distances, find the smallest integer weights, with a named weight at least w, that keep every arm balanced.Medium6TreeMath+2No attempts yet1s128 MBJudgeable
Jack of All TradesGiven directed trades between items, find the minimum exchange ratio from one item to another using at most 9 trades, and count the chains achieving it.Medium6GraphDFS+1No attempts yet1s128 MBJudgeable
Knockout TournamentGiven knockout tournament results, find the best and worst possible rank each queried player could hold under a transitive beat relation.Medium6TreeDFS+2No attempts yet1s128 MBJudgeable
A Walk Through the ForestCount the number of routes from intersection 1 to 2 in an undirected weighted graph where each step strictly decreases the shortest distance to intersection 2.Medium6GraphShortest path+2No attempts yet1s128 MBJudgeable
Marbles on a TreeGiven a rooted tree where each vertex has a box and the total marbles equal the number of vertices, find the minimum number of moves (along edges) so every box holds exactly one marble.Medium6TreeDFS+2No attempts yet1s128 MBJudgeable
BounceFind the shortest non-self-intersecting path on a hex grid from the top row to the bottom and back to the top row on the right, whose letters form a repeated pattern of given length. ExampleMedium6DFSBacktracking+2No attempts yet1s128 MBJudgeable
The Writers' ClubFor each writer, recommend every writer reachable through the favorites graph to readers who favor a writer that reaches this one, excluding self and existing favorites.Medium6GraphDFS+1No attempts yet5s128 MBJudgeable
Newton's AppleParse two binary trees from post-order tokens with nil markers, then decide whether one can be turned into the other by swapping left and right children at any nodes.Medium6TreeRecursion+2No attempts yet1s128 MBJudgeable
Off BalanceGiven a 2D grid of digit-labeled blocks, group 4-block pieces, build the support tree, and check each piece's accumulated center of mass against its bottom-column span.Medium6DFSTree+2No attempts yet1s128 MBJudgeable
Curling 2.0On a grid with destructible blocks, find the fewest throws to slide a curling stone from start to goal, where each slide continues until it hits a block or leaves the board.Medium6DFSBacktracking+2No attempts yet3s128 MBJudgeable