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 results151 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Strahler orderGiven a river DAG, compute its Strahler order at node M by processing nodes in topological order.Easy3Topological sortGraphNo attempts yet1s128 MBJudgeable
Building Completion TimesGiven N buildings with construction times and prerequisite dependencies, compute for each building the earliest possible completion time assuming unlimited parallel construction.Medium4Topological sortDynamic programming+1No attempts yet2s128 MBJudgeable
Problem Solving OrderGiven N tasks and M precedence constraints, output a topological order that always picks the smallest available problem number next.Medium4Topological sortHeap+1No attempts yet2s128 MBJudgeable
Minimum Time to Complete TasksGiven tasks with durations and prerequisites forming a DAG (prerequisites always have smaller index), compute the minimum total time to finish all tasks using longest path via DP.Medium4Dynamic programmingTopological sort+1No attempts yet2s256 MBJudgeable
Student LineupGiven precedence constraints between N students, output any ordering consistent with all constraints, i.e. a topological sort.Medium4Topological sortGraph+1No attempts yet2s128 MBJudgeable
Music ProgramMerge several partial orderings of singers into one total order using topological sort, or report impossibility if a cycle exists.Medium4Topological sortGraph+1No attempts yet1s128 MBJudgeable
Indiana Jones and the Lost Soccer CupGiven precedence constraints between levers, decide whether the order is unique; print the unique order, or report no order or multiple orders.Medium4Topological sortGraph+2No attempts yet1s256 MBJudgeable
It’s tough being a teen!Given a fixed list of seven tasks with precedence rules plus up to ten extra constraints, output a valid order using the smallest available task first, or report that no order exists.Medium4GraphTopological sort+2No attempts yet1s128 MBJudgeable
ExperimentOrient each undecided corridor so the whole maze stays acyclic, following the smallest-numbered topological order of the fixed corridors.Medium4Topological sortGraph+1No attempts yet3s128 MBJudgeable
Triball RankingOrder all k players to satisfy every match result and return the lexicographically smallest lineup, or 0 when no lineup fits.Medium4Topological sortGraph+1No 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
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
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
Dueling PhilosophersGiven m precedence edges among n essays, decide whether the es-says have zero, exactly one, or more than one valid topological ordering.Medium5GraphTopological sort+2No attempts yet2s128 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
Tournament RankingGiven game results between teams, produce the lexicographically smallest topological order, or report that no valid ranking exists due to a cycle.Medium5GraphTopological sort+2No attempts yet1s128 MBJudgeable
Moving DayGiven n people each moving from one address to another on a single street, find the lexicographically smallest order of moves so every destination is vacant in time.Medium5GraphTopological sort+1No 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
Ancient Dictionary OrderDecide whether some alphabet order makes each given word list sorted lexicographically.Medium5Topological sortGraph+1No attempts yet8s256 MBJudgeable
Insider's InformationFollow the given removal order, then insert each university at the front or back to satisfy at least half the betweenness triples.Medium5SimulationGreedy+2No attempts yet2s256 MBJudgeable
Diamond Inheritance (Large)Decide whether any pair of classes in each inheritance DAG has two different inheritance paths between them.Medium5GraphTopological sort+1No attempts yet5s512 MBJudgeable
Technology PlanningFind every goal technology plus its prerequisites and print the smallest valid research order, breaking ties lexicographically.Medium5Topological sortGraphNo 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
DwarvesGiven strict size comparisons between named dwarves, decide whether the statements are mutually consistent.Medium5GraphTopological sort+2No attempts yet2s512 MBJudgeable
University CourseSimulate course selection each semester: from courses whose prerequisites are done, take up to M with highest priority, and report the schedule.Medium5Topological sortGreedy+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
Milking OrderGiven a partial order between some cows and fixed positions for others, find the earliest position cow 1 can occupy.Medium5Topological sortGreedy+2No attempts yet2s512 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
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
Graph RelabelingGiven a directed graph as an adjacency matrix, assign each vertex a distinct label from 1 to N respecting all edge order constraints, and output the lexicographically smallest label sequence or -1 if impossible.Medium6Topological sortGreedy+2No attempts yet2s128 MBJudgeable
Critical PathOn a DAG, find the longest path length from source to target, then count edges that lie on at least one such longest path.Medium6Dynamic programmingTopological sort+1No attempts yet2s512 MBJudgeable
New Language Alphabet OrderGiven a sorted list of words in an unknown alphabet, reconstruct the unique letter order or report impossibility or ambiguity.Medium6Topological sortGraph+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
Counting Bicycle Race RoutesCount directed paths from village 1 to village 2 in a graph, printing the last 9 digits or 'inf' if a reachable cycle makes the count infinite.Medium6Topological sortDynamic programming+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
Pick up sticksGiven a set of on-top-of relations between sticks, output the lexicographically smallest removal order, or IMPOSSIBLE if a cycle exists.Medium6Topological sortGraph+2No attempts yet1s128 MBJudgeable
Time to GraduateGiven up to 12 courses with prerequisites, fall or spring offerings, and a per-semester course cap, find the minimum number of semesters to finish all courses.Medium6GraphDynamic programming+2No attempts yet1s128 MBJudgeable
The Worst ReporterGiven some match results of a round-robin where higher-ranked teams always win, find the lexicographically smallest ranking and say whether it is unique.Medium6GraphTopological sort+2No attempts yet1s128 MBJudgeable
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.Medium6GraphDFS+2No attempts yet1s128 MBJudgeable
Dizzy CowsDirect each two-way edge using the lexicographically smallest topological order of the given acyclic one-way edges, or report -1 if a cycle exists.Medium6GraphTopological sort+2No attempts yet1s128 MBJudgeable
Ranking the CowsGiven partial comparison results between N cows with distinct milk rates, find the minimum number of additional pairwise comparisons needed to determine the full ranking.Medium6GraphTopological sort+2No attempts yet1s128 MBJudgeable
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.Medium6GraphDynamic programming+2No attempts yet1s128 MBJudgeable
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.Medium6GraphDFS+2No attempts yet1s128 MBJudgeable
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.Medium6GraphTopological sort+2No attempts yet1s128 MBJudgeable
Fire drillOrder N buildings to minimize how many times a building is evacuated before one of its listed predecessors. Output the permutation.Medium6Topological sortGraph+1No attempts yet1s1024 MBJudgeable
Sorting It All OutGiven up to n letter ordering constraints added one at a time, report the first point where a unique sorted order emerges or where the constraints contradict each other.Medium6GraphTopological sort+2No attempts yet1s128 MBJudgeable
CaveGiven a transitive reachability matrix of a DAG, find the minimum number of downward paths needed to cover every node.Medium6GraphGreedy+2No attempts yet1s128 MBJudgeable
GenomesFind the length of the longest common subsequence of up to 20 permutations of size up to 500.Medium6GraphTopological sort+1No attempts yet1s128 MBJudgeable
BridgesAssign each pair a distinct height so the number of vertical-horizontal crossings is minimal and output the bridges from lowest to highest.Medium6IntervalsTopological sort+1No attempts yet2s128 MBJudgeable
People like peopleFrom each voter list of up to three liked students, find the largest group where everyone voted, likes only members, and is liked by a member.Medium6GraphQueue+1No attempts yet1s128 MBJudgeable
InfluenceFrom the candidate set X, pick the person who reaches the most people through transitive influence, breaking ties by smallest id.Medium6Topological sortGraph+1No attempts yet3s128 MBJudgeable
PaintingRecover the lexicographically smallest order in which whole rows or columns were painted to produce each board.Medium6Topological sortGraph+1No attempts yet1s128 MBJudgeable
Friendship GraphDecide up to 200000 reachability queries on a directed graph with 2000 vertices, printing 1 when Y is reachable from X.Medium6GraphDFS+2No attempts yet2s128 MBJudgeable
Scout OutingScouts split along every DAG trail and regroup at each station; report the last arrival time, the total waiting spread, and the stations with departure slack.Medium6Topological sortDynamic programming+1No attempts yet1s128 MBJudgeable
Ancient Cave ExpeditionFrom cave 1, choose a route that only moves deeper to maximize treasure values minus tunnel costs, breaking profit ties by lexicographic order.Medium6Dynamic programmingTopological sort+1No attempts yet1s256 MBJudgeable
Digi Comp IIBalls fall through a DAG of toggle switches that flip after each visit, and the task is to report the final state of every switch.Medium6Topological sortDynamic programmingNo attempts yet7s256 MBJudgeable
Web Service DependenciesCount the launch orders that place each container after all of its dependencies for each configuration.Medium6Dynamic programmingTopological sort+1No attempts yet1s256 MBJudgeable
Everlasting ZeroDecide if every special command can be learned by raising skills that never decrease while respecting each upper and lower bound.Medium6Topological sortGraphNo attempts yet5s128 MBJudgeable
Chess TournamentGiven reported chess results, decide whether some assignment of skill levels makes all results true, where equal skills draw and higher skill always wins.Medium6Union-findGraph+1No attempts yet5s512 MBJudgeable
Recover the Alphabet OrderGiven words claimed to be lexicographically sorted, decide whether the letter order is unique, impossible, or ambiguous.Medium6Topological sortGraph+1No attempts yet2s512 MBJudgeable
Halting MachineParse N goto statements, build a directed graph, and print the longest path length from line 0 to line N, or infinity if a cycle is reachable on some path to N.Medium6GraphDynamic programming+2No attempts yet2s512 MBJudgeable
Dueling PhilosophersGiven directed edges meaning essay d must precede essay u, decide whether the ordering is impossible, unique, or has multiple solutions.Medium6GraphTopological sort+2No attempts yet2s512 MBJudgeable
Finding the RankGiven a set of pairwise comparisons among N students, find the best and worst possible rank of student X over all total orders consistent with the comparisons.Medium6GraphDFS+2No attempts yet1s512 MBJudgeable
Improve SPAMGiven nested mailing lists, count how many messages reach client emails before deduplication and how many distinct emails are reached, both modulo 1e9+7.Medium6GraphDFS+2No attempts yet0.3s512 MBJudgeable
BiomagnificationGiven a DAG of predator-prey species where each consumer picks prey via an unbounded knapsack to meet its calorie need while minimizing heavy metal, determine if the human species survives and find its minimum accumulated metal.Medium7Dynamic programmingGraph+2No attempts yet5s128 MBJudgeable
Candy Stair ClimbFind the maximum candies collectible by jumping between horizontal stair segments within distance K, never decreasing height, starting from the ground.Medium7Topological sortGraph+2No attempts yet2s128 MBJudgeable
Racing ResultsCount how many full car rankings are consistent with given pairwise 'beat' results, essentially counting linear extensions of a partial order mod 1,000,003.Medium7Dynamic programmingCombinatorics+2No attempts yet2s128 MBJudgeable
Line UpGiven N students and M precedence constraints, compute the minimum and maximum possible position each student can occupy in any valid linear order, or report impossibility if a cycle exists.Medium7Topological sortGraph+1No attempts yet2s128 MBJudgeable
ConservationGiven a DAG of tasks each labeled with one of two labs, find a topological order minimizing the number of switches between labs.Medium7Topological sortGraph+1No attempts yet2s128 MBJudgeable
GunfightGiven listener based constraints on when gunshot sounds arrive, determine the unique firing order of shooters, or report impossibility or ambiguity.Medium7GraphTopological sort+1No attempts yet1s128 MBJudgeable
ClassifiedGiven a partial order with listed A -> B rules and guaranteed pairwise greatest lower bounds, simulate read and write actions that lower a user or document level to the glb of two current levels, printing each result.Medium7GraphTopological sort+2No attempts yet1s128 MBJudgeable
Crazy CircuitsGiven a directed acyclic circuit with current demands on edges, find the minimum supply current at the + terminal so every component gets its required current, or report impossible.Medium7GraphDynamic programming+2No attempts yet1s128 MBJudgeable
Sub-dictionaryGiven a dictionary where each word's definition uses only other words, find the smallest self-contained subset of words to teach first so all words become learnable.Medium7GraphGreedy+2No attempts yet1s128 MBJudgeable
Frame StackingGiven a picture of several stacked lettered frames on a grid, recover the bottom-to-top stacking order, printing all valid orders alphabetically.Medium7GraphTopological sort+2No attempts yet1s128 MBJudgeable
All Discs ConsideredGiven a DAG of package dependencies split across exactly two DVDs, find the minimum number of disc changes to install all packages with a single drive.Medium7GraphTopological sort+2No attempts yet1s256 MBJudgeable
Task ExecutionGiven a DAG of N unit-time tasks, find the minimum completion time with unlimited processors, then the fewest processors that still achieve it.Medium7GraphTopological sort+2No attempts yet1s128 MBJudgeable
CompanyKeep the fewest boss relations from a DAG so that reachability between all pairs of employees is unchanged, and output them sorted.Medium7GraphTopological sort+1No attempts yet1s128 MBJudgeable
Tetris AlphabetGiven the final well of a Tetris game with lettered pieces, find the lexicographically smallest order in which the pieces could have landed.Medium7GraphTopological sort+2No attempts yet1s128 MBJudgeable
Professor SzuCount walks in a directed multigraph from each cottage to the main building, cap at 36500, and report which cottages have the most routes (or are unbounded).Medium7GraphDynamic programming+2No attempts yet3s128 MBJudgeable
Group ExcursionDecide whether each tourist's two visit wishes can be satisfied together and output the lexicographically smallest visit list.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
DivisibilityDecide whether a directed graph matches the divisibility relation of some set of distinct natural numbers.Medium7GraphTopological sortNo attempts yet1s128 MBJudgeable
The GameTwo tokens sit on two directed acyclic boards and players alternate moving one token along an edge, and each query asks whether the first player wins.Medium7Game theoryTopological sort+1No attempts yet1s128 MBJudgeable
Self-AssemblyDecide whether unlimited rotatable square tiles with signed edge labels can form an arbitrarily large compatible assembly.Medium7GraphTopological sortNo attempts yet3s128 MBJudgeable
MinesTrigger the fewest mines so chain reactions through overlapping blast squares detonate all N mines.Medium7GraphDFS+1No attempts yet1s128 MBJudgeable
Dreaded Alternating GamePick the side, even or odd, that wins a token-moving game on a directed board when both players play perfectly.Medium7Game theoryGraph+2No attempts yet1s128 MBJudgeable
Seven KingdomsDecide whether the cities split into three cliques holding city 1, city 2, and the rest, and print the lexicographically smallest assignment or impossible.Medium7GraphDFS+2No attempts yet9s128 MBJudgeable
Jeju Island TourPick two vertex-disjoint directed paths in a DAG so the total number of vertices on both paths is as large as possible.Medium7Dynamic programmingGraph+1No attempts yet1s128 MBJudgeable
Catch the BombGiven forbidden left and upper neighbor pairs over 26 letters, find the largest fillable square grid, capped at 20.Medium7GraphTopological sort+1No attempts yet2s128 MBJudgeable
Possible First TilesGiven a top view of 5x5 letter tiles on a grid, print NO when the view is impossible and otherwise list the tiles that could have been laid first.Medium7Topological sortBrute force+1No attempts yet1s128 MBJudgeable
Beam me out!Decide whether a random walk from room 1 reaches room n with certainty and whether every possible walk ends within a bounded number of steps.Medium7GraphDFS+1No attempts yet1s256 MBJudgeable
Spy NetworkValues spread along directed edges by repeated gcd updates until stable, and you count how many employees end at L.Medium7GraphTopological sort+1No attempts yet2s256 MBJudgeable
Grass CownoisseurStarting from field 1 and returning to it, visit the most distinct fields while traveling at most one directed path backwards.Medium7GraphTopological sort+1No attempts yet1s256 MBJudgeable
Coin type identificationDetermine each coin fixed type from the pairwise weighing results, printing ? when it is not unique.Medium7Union-findTopological sort+2No attempts yet2s512 MBJudgeable
InterceptFind every station that lies on all shortest routes from s to t in a directed weighted graph.Medium7Shortest pathGraph+1No attempts yet1s256 MBJudgeable
ARTUROrder the sticks so each one slides straight down off the table without touching the sticks still on it, choosing the lexicographically smallest such order.Medium7Topological sortGeometry+1No attempts yet1s64 MBJudgeable
PromotionsGiven precedence rules and promotion counts A and B, count employees in every valid promotion set of each size and those in none of size B.Medium7Topological sortGraphNo attempts yet2s256 MBJudgeable
Critical SubprojectsFind every vertex in a DAG that is comparable to all other vertices under reachability.Medium7GraphTopological sort+1No attempts yet0.6s32 MBJudgeable