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 results901 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
TruckingFor each graph case, find the largest cargo height allowing a route, then the shortest route length among routes that allow it.Medium5GraphShortest path+2No attempts yet3s128 MBJudgeable
EinbahnstrasseFor each case, sum the shortest round-trip garage-to-car distances over all cars in a directed weighted city graph.Medium5Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Horror ListEach movie gets a level: 0 if on the horror list, else one plus the best level among similar movies; output the movie with the highest finite level, breaking ties by smallest ID.Medium5GraphBFS+2No attempts yet1s128 MBJudgeable
Seymour the SealCount herring squares reachable from S when at most 3 goo squares may be crossed between visits to a cleaner.Medium5GraphBFS+1No attempts yet1s128 MBJudgeable
Battleground PreservationGiven past battle results with costs, find the cheapest chain of victories between two fighters and decide the winner, or output FIGHT! if neither dominates.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Pirates' PathFind the path from s to e in an undirected graph that uses the fewest guarded edges, where each edge has cost 0 or 1.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Olympic AvenuesGiven an undirected weighted graph with N up to 50, find the shortest path from S to F and, among ties, print the lexicographically smallest site sequence.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Milk RoutingPick a single path from node 1 to node N minimizing latency plus X divided by the path's bottleneck capacity, and floor the result.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Corn MazeGiven a grid with walkable cells, zero-cost paired teleporter slides, and one exit, find the minimum time from the start to the exit.Medium5GraphBFS+2No attempts yet1s128 MBJudgeable
Chocolate GivingFor each of B queries on a weighted undirected graph, output the shortest distance from pasture P to pasture Q that passes through the barn at pasture 1.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Best SpotGiven a weighted undirected graph and a set of favorite vertices, find the vertex whose average shortest-path distance to all favorites is smallest, breaking ties by smallest index.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Obstacle CourseOn an N by N grid with blocked tiles, find a walk from A to B that minimizes the number of 90-degree turns; start and end directions are free.Medium5BFSGraph+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
MunchingFind the length of a shortest grid path from the cow to the barn through grass, then report the number of grass squares munched along it.Medium5BFSGraph+2No attempts yet1s256 MBJudgeable
Cows on SkatesFind a shortest orthogonal path from (1,1) to (R,C) through open grid cells, breaking ties by the lexicographically smallest sequence of cells.Medium5BFSGraph+2No attempts yet1s128 MBJudgeable
Stockbroker GrapevineFor each directed weighted graph, find the vertex whose shortest paths reach every other vertex, minimizing the maximum distance; print it and that time, or disjoint.Medium5Shortest pathGraph+2No attempts yet1s128 MBJudgeable
106 Miles to ChicagoGiven a graph where each edge has a percent probability of staying uncaught, find the path from node 1 to node n that maximizes the product of these probabilities.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Journey of a KnightGiven an n by m board, find the minimum number of knight moves from cell (1,1) to cell (i,j), or report that it is unreachable.Medium5BFSGraph+2No attempts yet1s128 MBJudgeable
Making test data 5Print a fixed chain graph with self-loops and queries so that ModifiedDijkstra stays under the counter limit while OptimizedBellmanFord exceeds it.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Playground HideoutGiven a directed graph with weighted edges and direct ground costs per node, find the index of the node with the largest shortest-path distance from ground, breaking ties by smallest index.Medium5Shortest pathGraph+2No attempts yet1s128 MBJudgeable
Traffic EngineeringGiven a directed network of named hosts where nodes cost 0 or 1 depending on ownership, report the cheapest route cost between each source-destination pair.Medium5GraphShortest path+2No attempts yet1s256 MBJudgeable
BitocjaThe program accepts each proposed road in order only when it strictly shortens the shortest travel time from city 1 to city n.Medium5Shortest pathGraphNo attempts yet1s512 MBJudgeable
Traffic LanesFind the fewest lane changes needed to drive across an n by m grid of blocked and free cells, starting and ending in any lane.Medium5Shortest pathBFS+1No attempts yet1s128 MBJudgeable
BubuFind Bubu's fastest route to clearing 1 that reaches every clearing before any ranger does, or report -1.Medium5Shortest pathGraphNo attempts yet1s128 MBJudgeable
Servicing ClientsChoose clients whose distance-times-demand costs fit the budget to maximize total priority.Medium5Dynamic programmingShortest pathNo attempts yet1s128 MBJudgeable
Janggi HorseCompute the fewest Janggi horse moves from start to target on an infinite board where standing pieces block the orthogonal step of some moves.Medium5BFSShortest path+1No attempts yet1s128 MBJudgeable
EscapeFind the fewest steps from the start cell to any border cell in a grid while turning at each tile unless both sides are blocked.Medium5BFSShortest path+2No attempts yet1s128 MBJudgeable
No Left TurnsFind the shortest path from start to finish in a maze where each step goes straight ahead or turns right.Medium5BFSShortest path+1No attempts yet1s128 MBJudgeable
Public TransitWalk once from the start, then take timed one-way buses with waiting to arrive earliest, breaking ties by fewer stops then smaller stop numbers.Medium5Shortest pathGraphNo attempts yet1s128 MBJudgeable
Unidentified DestinationList the candidate destinations whose shortest route from s passes through the road between g and h.Medium5Shortest pathGraphNo attempts yet3s256 MBJudgeable
Outpost NavigationFind the lowest-encounter safe route to a supply outpost, optionally collecting ammo at the one cache without overspending.Medium5Shortest pathGraphNo attempts yet2s128 MBJudgeable
Bones's BatteryFind the smallest battery range so every pair of schools connects with at most K charges over roads within range.Medium5Binary searchGraph+1No attempts yet5s128 MBJudgeable
Shopping MallsFind the least-walking path between queried places in a mall graph with asymmetric costs and break cost ties by lexicographic order.Medium5Shortest pathGraphNo attempts yet1s128 MBJudgeable
SailingFind the quickest sailing route on a grid with six moves, tacking costs, and blocked waypoints.Medium5Shortest pathGraphNo attempts yet2s512 MBJudgeable
Super PhyllisFind every direct reporting edge that has an alternate route through at least one other person and print those edges in sorted order.Medium5GraphShortest path+1No attempts yet2s128 MBJudgeable
Electronic Road Pricing (ERP)Find the cheapest route on a grid of roads where going straight is free, left turns cost 1, right turns cost 5, and dead-end U-turns cost 10.Medium5Shortest pathGraph+1No attempts yet2s1024 MBJudgeable
Shortest Sailing TimeFind the cheapest route from the top-left to the bottom-right of a cost grid where each turn adds 3.Medium5Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Erratic AntsGiven a recorded walk on a grid, find the fewest steps from start to end using only walked edges or their reverses.Medium5BFSGraph+1No attempts yet2s256 MBJudgeable
Texas SummersFind the route from the dormitory to class through shady spots that minimizes the sum of squared leg lengths, with ties broken by lexicographic index order.Medium5Shortest pathGraph+1No attempts yet2s256 MBJudgeable
Piggy BackBessie from field 1 and Elsie from field 2 must both reach the barn at field N, walking alone or meeting in one field to share the rest of the trip.Medium5Shortest pathBFSNo attempts yet1s256 MBJudgeable
Cow RoutingFind the cheapest itinerary from city A to city B using ordered routes that charge full price per boarding, breaking ties by fewest flights.Medium5Shortest pathGraphNo attempts yet1s256 MBJudgeable
EmpireFind the fastest route from A to B whose total hull damage stays strictly below K.Medium5Shortest pathDynamic programmingNo attempts yet1s256 MBJudgeable
Change of SceneryDecide whether a second shortest route from junction 1 to N exists that differs from the given one by at least one street.Medium5Shortest pathGraphNo attempts yet3s256 MBJudgeable
MatrixCompute each agent's earliest arrival time, then find Neo's shortest safe route to a telephone that beats every agent there.Medium5Shortest pathGraphNo attempts yet2s256 MBJudgeable
Minimum Cost RouteFind the cheapest bus fare from city A to city B and print the fare, the city count, and the path, preferring fewer cities and then lexicographic order on ties.Medium5Shortest pathHeapNo attempts yet1s256 MBJudgeable
All Pairs Shortest RoutesFind the cheapest fare between every pair of cities and print each cheapest route, breaking ties by lexicographic order.Medium5Shortest pathGraphNo attempts yet1s256 MBJudgeable
ZombiesFind the cheapest route from city 1 to city N, where cities within S roads of a zombie city cost q per night and all other cities cost p.Medium5Shortest pathBFS+1No attempts yet2s512 MBJudgeable
gCampus (Large)Find every road that never appears on a shortest travel-time path between any pair of offices.Medium5Shortest pathGraphNo attempts yet5s512 MBJudgeable
Taking the Metro (Large)Find the fastest route between two metro stations where each boarding adds a line waiting time and transfers use walking tunnels.Medium5Shortest pathGraphNo attempts yet5s512 MBJudgeable
Dragon Maze (Small)Find the fewest-step walk from the entrance to the exit of a cell grid and report the most power gathered on such a route.Medium5BFSShortest path+1No attempts yet5s512 MBJudgeable
Spaceship Defence (Small)Soldiers cross rooms with free jumps between same-color rooms and timed one-way turbolifts, and each query asks for the fastest trip time.Medium5Shortest pathGraphNo attempts yet5s512 MBJudgeable
Choosing a meeting place (Large)Each friend moves at their own speed, so run Dijkstra once per friend and pick the city with the smallest worst arrival time.Medium5Shortest pathGraphNo attempts yet5s512 MBJudgeable
Crossing the Road (Small)On a tiny grid whose intersections have periodic pedestrian lights, find the minimum time to walk from the southwest corner of the grid to the northeast corner.Medium5Shortest pathGraph+1No attempts yet5s512 MBJudgeable
Branch AssignmentPartition b branches into s nonempty groups to minimize total round-trip courier distance, where a message from branch i to j costs dist(i,hq)+dist(hq,j).Medium5GraphShortest path+1No attempts yet5s512 MBJudgeable
Magic PotionGiven a complete graph with edge weights and K potions that halve one trip's time, find the shortest time from city 0 to city 1.Medium5Shortest pathGraph+1No attempts yet2s512 MBJudgeable
Train Line ConstructionOn an N by N grid with resident counts and blocked cells, find a 4-direction path between two stations minimizing the sum of cell weights along it.Medium5GraphShortest path+2No attempts yet1s64 MBJudgeable
Hide and Seek 3Given start N and target K, find the minimum number of one-step moves when moving X to X-1 or X+1 costs one second and moving X to 2X costs nothing.Medium5BFSGraph+1No attempts yet2s512 MBJudgeable
TaxFind the shortest path from S to D in a weighted undirected graph, then report it again after each tax rise adds p to every edge.Medium5Shortest pathGraph+2No attempts yet2s256 MBJudgeable
Connectivity PotentialGiven a directed graph as an adjacency matrix, compute the number of hops in the longest shortest path times the number of ordered pairs attaining it.Medium5GraphShortest path+2No attempts yet2s512 MBJudgeable
The Other WayCount the number of distinct shortest paths between two towns in a weighted undirected multigraph, modulo 10^9+9.Medium5GraphShortest path+1No attempts yet2s256 MBJudgeable
Pony Express (Small)Cities lie on a line with a horse in each; find the minimum time from city 1 to city N, switching horses at intermediate cities, subject to each horse's endurance limit.Medium5Dynamic programmingShortest path+1No attempts yet5s512 MBJudgeable
Amsterdam DistanceIn a half-disc street grid with M radial streets and N circular canals of radius R*y/N, find the shortest path length between two corners using only those streets and canals.Medium5GeometryGraph+1No attempts yet2s512 MBJudgeable
A Great WayFind the cheapest path from node 1 to node N, where an edge costs c + d*max(0,e-10), breaking ties by fewer waypoints.Medium5GraphShortest path+1No attempts yet1s128 MBJudgeable
American TourFind the shortest walk from node 1 to node N that passes through node 2, where no road may be repeated but nodes may be revisited.Medium5GraphShortest path+1No attempts yet1s256 MBJudgeable
Fine DiningFor each pasture, decide whether a cow can detour through one haybale on its way to the barn with extra time at most the hay's yumminess.Medium5Shortest pathGraph+1No attempts yet2s512 MBJudgeable
Bucket BrigadeOn a fixed 10x10 grid with one barn, one lake, and one blocked rock, find the fewest empty squares to occupy so a chain of cows links the lake to the barn.Medium5BFSGraph+2No attempts yet2s512 MBJudgeable
Being a Celebrity Is HardGiven a weighted undirected graph and two starting nodes, pick a meeting node minimizing the sum of both shortest distances and breaking ties by Jiheon's distance then index.Medium5Shortest pathGraph+1No attempts yet1s256 MBJudgeable
BackdoorFind the shortest travel time from junction 0 to junction N-1 in an undirected weighted graph, where every intermediate junction marked visible is blocked and only the Nexus may be entered.Medium5Shortest pathGraph+2No attempts yet2s512 MBJudgeable
Save the Princess!Given an N by M grid with walls and one sword cell, find the minimum steps from (1,1) to (N,M) within T, where the sword lets the hero pass through walls afterward.Medium5BFSGraph+2No attempts yet1s256 MBJudgeable
Minjun, Masan, and GunwooGiven an undirected weighted graph, check whether vertex P lies on some shortest path from vertex 1 to vertex V.Medium5GraphShortest path+2No attempts yet1s256 MBJudgeable
Teleport StationGiven N points in a line, edges between x-1 and x+1, plus M teleport connections, find the shortest time from S to E.Medium5GraphBFS+2No attempts yet2s512 MBJudgeable
Wise KnightGiven a knight's start square on an N by N board, find the minimum knight moves to reach each of M target squares.Medium5BFSGraph+2No attempts yet1s256 MBJudgeable
Iguana InstructionsGiven an n by n grid with blocked cells, find the minimum number of straight-line moves (direction plus distance) to walk from the top-left to the bottom-right.Medium5BFSGraph+2No attempts yet1s512 MBJudgeable
Road PavingFind the minimum travel time from city 1 to city N when up to K roads can be paved to cost zero, using layered shortest-path search over (node, paves used).Medium6Shortest pathGraph+1No attempts yet2s128 MBJudgeable
DeliveryFind the minimum moves in a grid from a start cell to visit two target cells, forbidding two consecutive moves in the same direction.Medium6BFSShortest path+2No attempts yet2s128 MBJudgeable
Installing Power Plant CablesFind the minimum total length of new cables needed to connect plant 1 to plant N, using free existing cables and new links capped at length M, via shortest path.Medium6Shortest pathGraph+1No attempts yet2s128 MBJudgeable
Minho's CuriosityGiven an all-pairs shortest-time matrix for N cities, reconstruct the minimum-edge road network with the same shortest times and output the total edge weight, or -1 if impossible.Medium6Shortest pathGraph+1No attempts yet2s128 MBJudgeable
Monkey Who Wants to Move Like a HorseFind the minimum number of moves for a monkey to reach the bottom-right cell of a grid using normal steps and at most K knight-like jumps over obstacles.Medium6BFSShortest path+2No attempts yet2s256 MBJudgeable
1 && 3 GraphAnswer many shortest-path queries on a special connected graph where fewer than 3 vertices have degree at least 3, exploiting its path/cycle-like structure for efficiency.Medium6GraphShortest path+1No attempts yet4s1024 MBJudgeable
Choosing Weight MassesAssign integer masses to N weights satisfying M difference inequality constraints, detecting infeasibility, using shortest-path style constraint graph construction.Medium6Shortest pathGraph+1No attempts yet2s128 MBJudgeable
Mirror InstallationFind the minimum number of 45-degree mirrors needed on a grid so light travels from one door to the other, treating direction changes as costs in a shortest-path search.Medium6BFSShortest path+1No attempts yet2s128 MBJudgeable
Reasonable PathsGiven a weighted undirected graph, count paths from vertex 1 to vertex 2 where each step moves to a vertex strictly closer to vertex 2 by shortest-path distance.Medium6Shortest pathGraph+1No attempts yet2s128 MBJudgeable
Network RecoveryGiven a weighted graph, find a minimum edge subset that preserves all shortest-path distances from node 1 while keeping the graph connected.Medium6Shortest pathGraph+1No attempts yet2s192 MBJudgeable
Security System InstallationBuild a minimum spanning tree from the given network, then find the vertex minimizing the sum of shortest distances to all other vertices within that tree.Medium6Minimum spanning treeGraph+1No attempts yet2s128 MBJudgeable
Camelot GatheringCompute BFS knight-move distances from every piece to every square, and find the meeting square and rendezvous strategy minimizing total moves to gather king and knights, where the king can ride a knight after meeting it.Medium6BFSShortest path+1No attempts yet2s128 MBJudgeable
Graph ReconstructionGiven all pairwise shortest distances of a connected weighted graph, reconstruct a graph with exactly M edges that reproduces those distances or report impossibility.Medium6GraphShortest path+1No attempts yet2s128 MBJudgeable
Roadblock InspectionGiven a weighted graph, find the maximum increase in shortest path from node 1 to node N caused by removing a single edge, outputting -1 if removal can disconnect them.Medium6Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Ant-Elephant WarGiven a weighted graph, find which single edge to delete so that the resulting shortest path from vertex 1 to vertex N is as long as possible.Medium6Shortest pathGraphNo attempts yet2s256 MBJudgeable
Turn On the LightGiven an N by M grid of diagonal tiles ('/' or '\'), find the minimum number of tile rotations needed to create a diagonal path from top-left to bottom-right corner, using shortest path on a corner graph with 0/1 edge weights.Medium6Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Chain Store LocationGiven a graph, compute shortest distances from every node to three fixed nodes and answer queries about whether a node is Pareto-dominated by another node on those three distances.Medium6Shortest pathGraph+1No attempts yet1s256 MBJudgeable
Bus TransfersGiven a grid and k horizontal or vertical bus segments, find the minimum number of bus transfers to get from a start point to a destination point.Medium6GraphBFS+1No attempts yet1s256 MBJudgeable
Roads of ManchesterGiven a directed graph with edge capacities, compute the ratio of max flow from A to B to the maximum bottleneck-capacity path from A to B.Medium6GraphShortest path+1No attempts yet1s128 MBJudgeable
Amusement ParkOn a grid where entering a cell costs 1/C and each minute-long interval allows a cumulative cost of at most 1, find the minimum number of minutes to travel from start to destination.Medium6BFSGraph+1No attempts yet2s128 MBJudgeable
Nikola's JumpsFind the minimum-cost path to square N where forward jumps grow by 1 each time and backward jumps match the last forward jump length.Medium6Dynamic programmingGraph+1No attempts yet1s128 MBJudgeable
Speed LimitsFind the fastest path in a directed road network where roads without a posted speed limit inherit the previously used speed limit, requiring state-dependent shortest path search.Medium6Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Invitation CardsGiven a directed weighted graph with up to a million nodes and edges, compute the sum of shortest paths from the CCS to all stops plus shortest paths from all stops back to the CCS.Medium6Shortest pathGraph+1No attempts yet1s128 MBJudgeable
WormholesGiven start, destination, and wormholes with entry-time constraints and time shifts, compute the earliest arrival time using a shortest-path style relaxation over travel distances and wormhole jumps.Medium6Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Halloween GraveyardFind the fastest time to travel from entrance to exit on a grid with walls and time-warping portals, detecting negative cycles and unreachability.Medium6Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Enjoyable CommunicationFind the k-th shortest simple path (by length then lexicographic node order) between two nodes in a directed graph with up to 50 nodes and k up to 200.Medium6Shortest pathGraph+1No attempts yet3s128 MBJudgeable
The AgencyFind the minimum landing-tax cost to travel from one N-bit planet to another, where flights flip exactly one bit.Medium6GraphShortest path+2No attempts yet1s128 MBJudgeable