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
Six Degrees of Kevin BaconGiven an unweighted friendship graph, find the vertex whose sum of shortest distances to all others is minimal, breaking ties by smallest index.Easy3BFSGraph+1No attempts yet2s128 MBJudgeable
Chairperson CandidatesGiven a friendship graph, compute each member's eccentricity via shortest paths and report the minimum eccentricity value with all members achieving it.Easy3GraphBFS+1No attempts yet1s128 MBJudgeable
RadioGiven a start and target frequency plus up to 5 preset shortcut buttons, find the minimum presses using +1, -1, or jump to a preset to reach the target.Easy3GraphShortest path+1No attempts yet1s128 MBJudgeable
Parcel DeliveryGiven a weighted undirected graph, find the minimum total edge weight along a path from barn 1 to barn N.Easy3Shortest pathGraphNo attempts yet1s128 MBJudgeable
Shipping RoutesGiven warehouses and bidirectional shipping legs, answer each request with the cheapest cost, which is shipment size times the minimum number of legs times 100, or report no route.Easy3GraphBFS+2No attempts yet1s128 MBJudgeable
Graph that exceeds Dijkstra's counterPrint the exact constructed directed weighted graph that makes Floyd-Warshall finish while the lazy-deletion Dijkstra times out on one query.Easy3GraphShortest path+1No attempts yet1s128 MBJudgeable
Hauling materialCompute the cheapest directed route from the start to the destination for each road network.Easy3Shortest pathGraphNo attempts yet1s128 MBJudgeable
The Prague LinkCompute the largest shortest-path distance over all pairs of posts, or report that the network is disconnected.Easy3Shortest pathGraphNo attempts yet1s128 MBJudgeable
Who you knowFind the cheapest chain of introductions from politician 0 to politician M-1 in an undirected graph with edge weights 1 to 4, printing -1 when unreachable.Easy3Shortest pathGraphNo attempts yet1s128 MBJudgeable
Your lifeFind the fewest directed moves from node 1 to node N in a graph where every edge goes forward, or report -1 when the goal is unreachable.Easy3BFSShortest path+1No attempts yet1s256 MBJudgeable
Array EscapeFind the cheapest right-and-down path through a square grid where stepping to a higher or equal neighbor costs the raises needed to exceed it.Easy3Dynamic programmingShortest path+1No attempts yet2s256 MBJudgeable
Snakes and Ladders GameOn a 10x10 board with ladders and snakes, find the fewest die rolls to move from square 1 to square 100, where each roll advances 1 to 6.Easy3BFSGraph+2No attempts yet1s512 MBJudgeable
Tower AttackGiven towers that can relay energy over short hops with 50% loss per hop, compute the maximum damage reachable towers can deal to an enemy using multi-source BFS.Medium4BFSGraph+2No attempts yet2s128 MBJudgeable
Highway ShortcutsCompute the minimum driving distance from position 0 to D on a highway with up to 12 one-way shortcuts that skip forward sections.Medium4Shortest pathGraph+2No attempts yet2s128 MBJudgeable
Parcel RoutingGiven a weighted graph, compute for every pair of hubs the next hub to visit on a shortest path using all-pairs shortest paths.Medium4Shortest pathGraph+2No attempts yet2s128 MBJudgeable
Shortest PathCompute single source shortest paths from a given vertex in a directed weighted graph with up to 20,000 vertices and 300,000 edges, printing INF for unreachable vertices.Medium4Shortest pathGraph+1No attempts yet1s256 MBJudgeable
WormholesGiven roads with positive weights and wormholes with negative weights, detect whether any negative cycle exists in the resulting directed graph using Bellman-Ford.Medium4Shortest pathGraph+1No attempts yet2s128 MBJudgeable
Minimum Cost PathGiven a directed weighted graph of cities and bus routes, compute the minimum cost path from a start city to a destination city.Medium4Shortest pathGraph+1No attempts yet0.5s128 MBJudgeable
Exercise RouteFind the minimum weight cycle in a directed graph with up to 400 vertices, essentially detecting the shortest cycle via all-pairs shortest paths.Medium4Shortest pathGraph+1No attempts yet2s192 MBJudgeable
Building a TreeFind a spanning tree rooted at R that minimizes the sum of parent degrees over all non-root vertices, using a BFS-like greedy shortest path with degree as edge weight.Medium4Shortest pathGraph+1No attempts yet2s128 MBJudgeable
Galaxy MeetingGiven weighted graphs and multiple starting galaxies, find the meeting galaxy that minimizes the sum of squared shortest distances from all participants.Medium4Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Wally WorldTwo points in a plane must meet while a single axis-parallel wall segment blocks the straight path; compute the minimum meeting time.Medium4GeometryMath+2No attempts yet1s128 MBJudgeable
SubwayFind the shortest travel time from home to school using walking and subway lines, rounding the answer to the nearest minute.Medium4Shortest pathGraph+2No attempts yet1s128 MBJudgeable
Is the Kid in Green Zelda?Find the minimum total cost path from the top-left to the bottom-right cell of an N x N grid where each cell's value is paid when visited.Medium4GraphShortest path+2No attempts yet1s256 MBJudgeable
Here We Go(relians) AgainFind the shortest travel time across a grid of streets with posted integer speeds, one-way rules, and closed roads.Medium4GraphShortest path+2No attempts yet1s128 MBJudgeable
ElevatorAn elevator with buttons that move up U or down D floors, staying within floors 1 to F, needs the minimum presses to go from floor S to floor G.Medium4BFSGraph+2No attempts yet1s256 MBJudgeable
Emergency ResponseGiven a directed weighted graph, answer multiple queries: the shortest travel time from any of several start nodes to one crime intersection.Medium4GraphShortest path+2No attempts yet1s128 MBJudgeable
Quick out of the HarbourFind the shortest time from S to outside the grid, where water cells cost 1 and drawbridges cost 1+d, on a grid up to 500x500.Medium4GraphShortest path+2No attempts yet1s128 MBJudgeable
CheeseIn a grid maze, find the total shortest walking time for a mouse to eat cheeses of hardness 1 through N in order, each raising its strength by one.Medium4BFSGraph+2No attempts yet1s256 MBJudgeable
Heat WaveGiven an undirected weighted graph, find the minimum total cost of a route from a source town to a destination town.Medium4GraphShortest path+2No attempts yet1s128 MBJudgeable
The Chivalrous CowFind the fewest knight-move jumps on an X by Y grid with obstacles to get from the start square to the hay bale.Medium4BFSGraph+2No attempts yet1s128 MBJudgeable
Hide and SeekIn a connected undirected graph, find the barn farthest from barn 1. Print the smallest such barn number, its distance, and how many barns tie at that distance.Medium4GraphBFS+2No attempts yet1s256 MBJudgeable
Going to Meet SinaGiven up to 10^4 blocked cells on a bounded grid, find the shortest 4-directional path from (0,0) to (X,Y) avoiding all puddles.Medium4BFSGraph+2No attempts yet1s128 MBJudgeable
Clear and Present DangerGiven a danger matrix and a required sequence of islands, find the minimum total danger of a walk that visits those islands in order, allowing detours through others.Medium4GraphShortest path+2No attempts yet1s128 MBJudgeable
Bronze Cow PartyGiven a connected undirected weighted graph, find twice the largest shortest-path distance from a fixed farm X, which is the longest round trip any cow makes.Medium4Shortest pathGraph+2No attempts yet1s128 MBJudgeable
RiskGiven a 20-country border graph, answer queries for the fewest countries to conquer when moving from one country to another, counting the destination.Medium4GraphBFS+2No attempts yet1s128 MBJudgeable
The Sangbeom BuildingGiven a 3D grid of blocked and open cells with a start and an exit, find the minimum number of moves (or report impossible).Medium4BFSGraph+2No attempts yet1s128 MBJudgeable
Knight MovesFor each pair of squares, find the minimum number of knight moves between them on a standard 8 by 8 chessboard.Medium4BFSGraph+1No attempts yet1s128 MBJudgeable
Gregory the GrasshopperFind the fewest knight moves from one square to another on a grid of up to 100 by 100, or report that it is impossible.Medium4BFSGraph+1No attempts yet1s128 MBJudgeable
Knight HopOn an 8 by 8 board, find the fewest knight moves from a start square to a target square.Medium4BFSGraph+2No attempts yet2s512 MBJudgeable
The Mysterious X NetworkGiven an undirected graph of N people, find the minimum number of intermediate people on a shortest path between two given people.Medium4GraphBFS+2No attempts yet1s128 MBJudgeable
Knight's MoveGiven an l by l board and two squares, find the minimum number of knight moves between them.Medium4BFSGraph+1No attempts yet1s256 MBJudgeable
SSSP (Shortest Path Queries)Run the given SPFA shortest-path algorithm for each query and also output a push counter that accumulates across all queries.Medium4Shortest pathGraph+2No attempts yet1s128 MBJudgeable
RestaurantsEvery city connects by weighted roads and some hold restaurants; report the largest distance from any city to its closest restaurant.Medium4Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Indiana Jones Among the ZombiesEvery turn each zombie steps toward chamber 1 along a shortest path, and you find the first turn with more than K arrivals or confirm Indiana survives.Medium4BFSShortest path+1No attempts yet6s128 MBJudgeable
Escape the Maze with a DrillDecide whether a robot can reach the target on a grid by drilling through at most k walls.Medium4Shortest pathBFS+2No attempts yet1s128 MBJudgeable
Hoo's Afraid of the Big Bad Wolf?Find the directed path from X to Y with the largest product of edge safety probabilities, printed rounded to six decimals.Medium4Shortest pathGraphNo attempts yet1s128 MBJudgeable
FenceFrom outside the grid, compute every empty cell's minimum fence breaks with 0-1 BFS, then report the largest value and how many cells attain it.Medium4Shortest pathBFS+2No attempts yet2s64 MBJudgeable
Enterprise EscapeStarting from E, move four-directionally across the grid paying each entered cell's class cost and escape through the cheapest border cell.Medium4Shortest pathMatrix+1No attempts yet10s256 MBJudgeable
Metro Manila DetourCompute the shortest driving distance between two intersections on concentric ring roads and radial roads with one ring and one spoke closed.Medium4Shortest pathGraphNo attempts yet5s128 MBJudgeable
Vacuum WorldTwo cleaners with different power and move costs roam a row of rooms and suck dirt, and the goal is the cheapest move-and-suck sequence that cleans every room.Medium4Shortest pathBrute force+1No attempts yet5s128 MBJudgeable
Vacation PlanningFor each query, find the cheapest directed flight route from start to end that visits at least one hub, then report the count and total cost.Medium4Shortest pathGraphNo attempts yet1s128 MBJudgeable
TourismVisit the given sights in order on a grid with extra northeast diagonals and minimize the total number of road segments traveled.Medium4Shortest pathMathNo attempts yet1s128 MBJudgeable
GatesFind the minimum travel time for each query pair of gates using walking and directed walkways.Medium4Shortest pathGraphNo attempts yet2s256 MBJudgeable
HackingStarting from the hacked computer, count reachable computers through dependency edges and report the longest infection time.Medium4Shortest pathGraph+1No attempts yet2s256 MBJudgeable
HikingFind the cheapest 8-direction path from the start to the highest cell of a height grid where flat steps cost 1 and a height change of d costs (d+1) squared.Medium4Shortest pathGraph+1No attempts yet3s256 MBJudgeable
Button BashingPress add and subtract buttons from 0, clamped between 0 and 3600, to reach a target time in the fewest presses or the nearest reachable longer time.Medium4BFSShortest path+1No attempts yet1s256 MBJudgeable
The Mountain of Gold?Decide whether portal hops from mountain 0 can return to mountain 0 at a strictly earlier time.Medium4Shortest pathGraphNo attempts yet1s256 MBJudgeable
Human CannonballFind the fastest route from start to target by running at 5 m/s and chaining optional 50-meter cannon shots that cost 2 seconds each.Medium4Shortest pathGraphNo attempts yet1s256 MBJudgeable
Trapezoid WalkwayFind the cheapest chain of trapezoid stones joining two given widths, where each stone links its two edge lengths at a cost tied to its area.Medium4Shortest pathGraphNo attempts yet2s256 MBJudgeable
Flowery TrailsAdd twice the length of every trail that lies on some shortest route from point 0 to point P-1.Medium4Shortest pathGraphNo attempts yet2s256 MBJudgeable
WormholesGiven planet coordinates and directed zero-cost wormholes, report the shortest travel distance for each queried planet pair.Medium4Shortest pathGraph+1No attempts yet5s256 MBJudgeable
ElevatorsFind the shortest total ride distance from the start floor to the target floor by switching between elevators that each serve only certain floors.Medium4Shortest pathGraphNo attempts yet2s256 MBJudgeable
Travelling TomFind the cheapest route that starts at the first listed city, visits every city in the given order using any connecting flights, then returns to the start.Medium4Shortest pathGraphNo attempts yet1s256 MBJudgeable
The Party That Never EndsFor each query, decide whether the shortest travel time from hall A to hall B fits within C using all-pairs shortest paths.Medium4Shortest pathGraphNo attempts yet2s256 MBJudgeable
FloydFor every pair of n cities, compute the cheapest directed bus fare from up to 100,000 routes and print 0 where no route connects them.Medium4Shortest pathGraph+1No attempts yet1s256 MBJudgeable
Baegyang Road BreakGiven a graph with one-way and two-way roads, answer many queries for the minimum number of one-way roads to reverse to reach each destination.Medium4Shortest pathGraphNo attempts yet1s256 MBJudgeable
Time MachineCompute the fastest times from city 1 over bus routes with possibly negative durations, or print -1 when a reachable negative cycle exists.Medium4Shortest pathGraphNo attempts yet1s256 MBJudgeable
gCampus (Small)For each road, decide whether it lies on a shortest path between some pair of offices and list the ones that never do.Medium4Shortest pathGraphNo attempts yet5s512 MBJudgeable
Taking Metro (Small)Find the fastest route between two metro stations, combining per-line boarding waits, ride times, and tunnel walks.Medium4Shortest pathGraphNo attempts yet5s512 MBJudgeable
Meeting Point (Small)Friends with different speeds start from given cities and must meet in one city, so minimize the worst arrival time over all cities.Medium4Shortest pathGraphNo attempts yet5s512 MBJudgeable
Weekly MeetingFor each member's house, add the shortest distances to two fixed nodes and sum all results, counting unreachable as -1.Medium4Shortest pathGraph+1No attempts yet1s512 MBJudgeable
Teleport 3Find the shortest travel time on a grid where you can walk one unit per second or take any of three two-way teleports costing 10 seconds each.Medium4GraphShortest path+1No attempts yet2s512 MBJudgeable
Nailro Rail Pass TripCompare the cheapest itinerary cost with and without a rail pass that discounts some fares, and decide if the pass is worth it.Medium4Shortest pathGraphNo attempts yet1s512 MBJudgeable
Secret MeetingGiven a weighted undirected graph and K friends' rooms, pick the room minimizing the sum of shortest-path distances from all friends; break ties by smallest room.Medium4Shortest pathGraph+1No attempts yet1s128 MBJudgeable
The nearest convenience storeGiven an undirected weighted graph with some vertices marked as homes and others as stores, pick the home whose shortest-path distance to the nearest store is smallest, breaking ties by vertex number.Medium4GraphShortest path+2No attempts yet2s512 MBJudgeable
When Geudae Becomes GeumeoGiven N characters and M replacement pairs, find the minimum number of substitutions needed to convert character a into character b.Medium4GraphBFS+1No attempts yet2s512 MBJudgeable
The fastest road to BanikoaraGiven towns joined by undirected weighted roads, find the shortest travel distance between a named departure town and destination town.Medium4GraphShortest path+2No attempts yet2s512 MBJudgeable
Chonggang ChonggangRun a single-source shortest path from Jinseo's house, find the nearest type A and type B house, and report the closer type (A wins ties).Medium4Shortest pathGraph+2No attempts yet1s256 MBJudgeable
Sogang GroundGiven a weighted undirected graph, find a region whose total item count within distance m is largest.Medium4GraphShortest path+1No attempts yet1s128 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
Death KnightFind the minimum number of moves for a knight-like piece with six fixed moves to travel between two squares on an N by N board, or -1 if unreachable.Medium4BFSGraph+2No attempts yet2s512 MBJudgeable
Why the Williamson's Sapsucker Came Up to Information IslandOn a grid with walls, find which of three food cells is nearest to the start cell 2, and print TAK with that distance, or NIE if none is reachable.Medium4BFSGraph+2No attempts yet1s256 MBJudgeable
Small World NetworkGiven a graph of N people and K friendships, check whether every pair of people is connected within 6 steps, printing Small World! or Big World! accordingly.Medium4GraphBFS+2No attempts yet1s512 MBJudgeable
Finding Cities at a Specific DistanceGiven a directed unweighted graph, print every city whose shortest distance from a start city equals K, in increasing order, or -1 if none exist.Medium4GraphBFS+1No attempts yet2s256 MBJudgeable
RUNGiven a directed weighted graph of N cells, one exit cell E, and a time limit T, count how many cells have a path to E within T time units.Medium4GraphShortest path+2No attempts yet2s512 MBJudgeable
Metro 2345Given three metro lines meeting at three transfer stations with per-line edge times and a transfer cost, find the shortest travel time between two given stations.Medium4Shortest pathGraph+2No attempts yet1s512 MBJudgeable
PartyGiven a directed weighted graph, compute for each village the round-trip shortest time to a fixed village X and return the maximum over all villages.Medium5Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Wall-Breaking MazeFind the minimum number of walls to break on a grid path from the top-left to the bottom-right room, moving through 4 directions.Medium5BFSShortest path+1No attempts yet1s128 MBJudgeable
Hopping FrogFind the minimum number of jumps for a frog moving between numbered stones, where each stone's value dictates allowed jump distances as multiples.Medium5BFSGraph+1No attempts yet2s128 MBJudgeable
Sunday Morning DateFind a grid path from S to F that first minimizes the number of trash cells stepped on, then minimizes clean cells adjacent to trash along that path.Medium5Shortest pathBFS+2No attempts yet2s128 MBJudgeable
Shortest Path Through Required VerticesGiven a weighted undirected graph, find the shortest path from vertex 1 to vertex N that must pass through two specified vertices.Medium5Shortest pathGraph+1No attempts yet1s256 MBJudgeable
Dog DaysGiven bunkers on a plane and a speed and survival-time limit, find the minimum number of intermediate bunkers a chicken must visit to reach a target bunker, or report it cannot escape.Medium5GraphBFS+1No attempts yet1s128 MBJudgeable
Maal GatheringGiven a grid with K-Maal pieces that jump up to K knight moves per turn, find the minimum total moves to gather all pieces on one square.Medium5BFSShortest path+2No attempts yet2s128 MBJudgeable
HighwayGiven a directed graph with edge lengths and tolls, find the minimum length path from city 1 to city N whose total toll does not exceed a budget K.Medium5Dynamic programmingGraph+1No attempts yet2s128 MBJudgeable
Mountain BikeFind the minimum travel time from top-left to bottom-right of a grid where each move's duration depends on cumulative speed changes from height differences, solvable via Dijkstra with speed encoded as exponent sums.Medium5Shortest pathGraph+1No attempts yet2s128 MBJudgeable
Move by Breaking One WallFind the shortest path in a grid from top-left to bottom-right where you may break at most one wall along the way.Medium5BFSGraph+1No attempts yet2s192 MBJudgeable
Circuit RoutingFind the minimum-cost grid path between two given cells where empty cells cost 1 and cells already occupied by given rectilinear circuits cost k, then output the path in compressed turn-point form.Medium5Shortest pathBFS+1No attempts yet1s128 MBJudgeable
Making a MazeFind the minimum number of black cells to convert to white so a path exists from top-left to bottom-right of an n x n grid, using 0-1 BFS or Dijkstra.Medium5BFSShortest path+1No attempts yet1s128 MBJudgeable
TramFind the minimum number of switch changes needed to travel from intersection A to B in a directed graph where each node's first listed edge is free and others cost 1, using shortest-path with 0/1 edge weights.Medium5Shortest pathGraph+1No attempts yet1s128 MBJudgeable