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 results3,014 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
A graph that times out coloring backtrackingPrint one fixed graph: a 55-vertex clique joined by a path, chosen to make a backtracking coloring solver time out.Easy1GraphImplementation+1No attempts yet1s128 MBJudgeable
Friend countsCount the friends of each of N students from M mutual friendship pairs and print the N totals in order.Easy1GraphImplementationNo attempts yet1s256 MBJudgeable
Hands are faster than computersPrint a fixed 4-vertex, 5-edge graph and a fixed proper 4-coloring, with no input to read.Easy1ImplementationGraphNo attempts yet2s512 MBJudgeable
Is Dinic quartic?Print a fixed 4-vertex, 5-edge flow network with the exact edges and capacities given in the statement.Easy1GraphImplementation+1No attempts yet2s512 MBJudgeable
Find the VerticesAn interactive-style task where a hidden edge between two vertices must be identified by querying the grader; input is fixed by the grader, not read.Easy1GraphImplementationNo attempts yet2s512 MBJudgeable
VirusCount how many computers other than computer 1 lie in computer 1's connected component of a small undirected graph.Easy2GraphBFS+1No attempts yet1s128 MBJudgeable
K-Graph OddityCompute the maximum vertex degree in a graph and output the smallest odd integer greater than or equal to it.Easy2GraphImplementation+1No attempts yet1s128 MBJudgeable
Making test data 8Print a specific fixed graph: 98 vertices, 1501 edges forming a complete bipartite graph, using the exact listed edge order.Easy2GraphImplementation+2No attempts yet1s128 MBJudgeable
The Friend of My Enemy Is My EnemyPrint the direct friends of suspect s in increasing order for each network.Easy2GraphSortingNo attempts yet1s128 MBJudgeable
Sanggeun's travelsGiven a connected graph of N countries and M flights, find the fewest flights that visit every country.Easy2GraphNo attempts yet1s256 MBJudgeable
Toroidal gridPrint the given snake sweep of columns 0 to n-2 plus the climb up column n-1 to list a Hamiltonian cycle of the m by n toroidal grid.Easy2ImplementationGraphNo attempts yet1s256 MBJudgeable
Counting FriendsCount the friends of each of N students from M mutual friendship pairs and print the N totals.Easy2GraphArrayNo attempts yet1s256 MBJudgeable
ITAI VirusCount the initially infected cities plus every city directly joined to one by a single road.Easy2GraphImplementationNo attempts yet1s256 MBJudgeable
Graph Maximum MatchingGiven a small graph, decide whether some edges can be kept so every vertex has degree exactly 1.Easy2GraphBacktracking+1No attempts yet2s512 MBJudgeable
László BabaiFor each of up to 100 test cases, decide whether two simple graphs on 3 vertices given by their edge lists are isomorphic.Easy2GraphBrute force+1No attempts yet1s256 MBJudgeable
LiesUsing union-find on party attendees, determine which parties can be exaggerated without conflicting with people who must always hear the truth.Easy3Union-findGraph+1No attempts yet2s128 MBJudgeable
FriendsGiven an N x N friendship matrix (N ≤ 50), find the maximum count of people reachable within two friendship links from any single person.Easy3GraphMatrix+1No attempts yet2s128 MBJudgeable
DFS and BFSGiven an undirected graph, output the vertex visit order for DFS then BFS starting from a given vertex, always preferring the smallest-numbered neighbor.Easy3DFSBFS+1No attempts yet2s128 MBJudgeable
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
Hide and SeekCompute the minimum number of moves to reach position K from N on the number line using BFS with steps +1, -1, or doubling.Easy3BFSGraphNo attempts yet2s128 MBJudgeable
Travel PlanGiven an adjacency matrix of cities, decide if consecutive cities in a given visit order all lie in the same connected component.Easy3Union-findGraph+1No attempts yet2s128 MBJudgeable
Maze SearchFind the minimum number of cells traversed on a grid path from top-left to bottom-right using BFS shortest path.Easy3BFSGraph+1No attempts yet1s192 MBJudgeable
Kinship DistanceGiven a family forest of parent-child edges, find the shortest kinship distance between two given people or output -1 if unconnected.Easy3GraphBFS+1No attempts yet1s128 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
Housing Complex NumberingGiven a binary grid, count connected groups of adjacent 1-cells and print the number of groups plus each group's size in ascending order.Easy3BFSGraph+1No attempts yet1s128 MBJudgeable
Keypad PasswordsCount length-N digit sequences on a phone keypad where consecutive digits must be adjacent keys, modulo 1,234,567, for up to N=1000.Easy3Dynamic programmingGraph+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
Unreachable FunctionsGiven a control flow graph built from three instruction types with fall-through or jump edges, count how many functions are unreachable from the first one.Easy3GraphBFS+1No attempts yet1s128 MBJudgeable
GatesGiven an acyclic NAND-gate circuit whose inputs are all tied to one variable x, decide whether the overall output depends on x (answer 1) or is constant (answer 0).Easy3SimulationGraph+1No attempts yet1s128 MBJudgeable
NetworkingGiven points and weighted candidate cable routes, compute the minimum total cable length needed to connect all points (minimum spanning tree).Easy3Minimum spanning treeGraph+1No attempts yet1s128 MBJudgeable
Modulo SolitaireGiven a modulus m, up to 10 affine maps, and a start s0, find the fewest moves to reach 0.Easy3BFSGraphNo attempts yet1s128 MBJudgeable
Choose Your Own AdventureEach page is a node with two outgoing choices or a terminal ending; print the unique path from page 1 to the single HAPPY ending.Easy3GraphDFS+2No attempts yet1s128 MBJudgeable
The Great SaharaOn a fixed 54-triangle hex board, decide whether player one can move one pyramid to trap an opponent's pyramid immediately.Easy3SimulationImplementation+2No attempts yet1s128 MBJudgeable
Number of IslandsGiven a grid of land and sea cells with 8-directional adjacency, count the connected land components.Easy3GraphDFS+2No attempts yet1s128 MBJudgeable
Red and BlackCount how many black tiles are reachable from a start tile in a small grid by moving up, down, left, and right.Easy3DFSGraph+1No attempts yet1s128 MBJudgeable
Car TroubleGiven a directed graph of street ids with ring road 0, report streets that cannot reach 0 and streets that 0 cannot reach, preserving input order.Easy3GraphDFS+2No attempts yet1s128 MBJudgeable
Connected or Not ConnectedGiven a graph with n sites and k edges, decide whether every site can reach every other.Easy3GraphDFS+1No attempts yet1s128 MBJudgeable
Mining MapsParse each graph block, count distinct node names, and count distinct undirected tunnels including self-loops.Easy3Hash mapGraph+2No attempts yet1s128 MBJudgeable
Asteroid FieldFind the minimum number of moves from the top-left cell to the bottom-right cell in a grid, avoiding asteroid cells.Easy3BFSGraph+1No attempts yet1s128 MBJudgeable
Breed AssignmentCount the breed assignments for N cows under same/different constraints, or report 0 if they conflict.Easy3GraphBacktracking+2No attempts yet1s128 MBJudgeable
Daisy Chains in the FieldGiven an undirected graph of cows joined by ropes, list in ascending order every cow that cannot reach cow 1, or print 0 if all cows are connected to it.Easy3GraphDFS+2No 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
3D Space ExplorationCount connected groups of '*' blocks in an N x N x N grid, where blocks connect only across shared faces.Easy3GraphDFS+2No attempts yet1s128 MBJudgeable
Invasion of the MilkweedSpread milkweed from a start cell to all eight neighbors each week and report the week it covers the last non-boulder cell.Easy3BFSGraph+2No attempts yet1s128 MBJudgeable
Feeding TimeGiven a W by H grid of grass and rock, find the size of the largest connected grass region using 8-directional adjacency.Easy3DFSBFS+2No attempts yet1s128 MBJudgeable
Wheel RotationGiven N-1 belts that chain N pulleys from pulley 1, with each belt either straight (same direction) or crossed (reversed), find the rotation direction of pulley N.Easy3GraphDFS+2No attempts yet1s128 MBJudgeable
Bad GrassCount connected components of nonzero cells in a grid, where two cells connect if they touch horizontally, vertically, or diagonally.Easy3GraphDFS+2No attempts yet1s128 MBJudgeable
Best GrassCount clumps of # cells in a grid, where each clump is one cell or two orthogonally adjacent cells and different clumps never touch.Easy3ArraySimulation+2No 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
SurfingParse links out of HTML pages, print each link, then answer reachability queries between pages.Easy3GraphDFS+1No attempts yet1s128 MBJudgeable
Making shortest-path test dataPrint the prescribed shortest-path test graph: a chain with a computed number of self-loops at vertex 0, plus Q queries from V-1 to 0.Easy3ImplementationGraph+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
Attendance CheckGiven a permutation forming one cycle, find the student who responds last when the calling chain starts at student k.Easy3ImplementationSimulation+2No attempts yet1s1024 MBJudgeable
Social Networking ApplicationGiven a friendship graph, answer queries asking whether two users lie in the same connected component.Easy3Union-findGraph+2No attempts yet1s128 MBJudgeable
Subdivision of KingdomSplit n towns (n even, n <= 26) into two halves of equal size so that the number of roads crossing between the halves is minimized.Easy3Brute forceBit manipulation+1No attempts yet1s128 MBJudgeable
The DanceFind the largest number of boy-girl pairs that can dance at once when each boy may only invite a girl he knows.Easy3GraphDFSNo attempts yet1s128 MBJudgeable
The HareFind the fewest knight jumps from the start cell to the burrow on a grid with blocked cells, or output NIE when unreachable.Easy3BFSGraph+1No attempts yet1s512 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
CrankCount the boundary rooftops that can reach the boss by moving only to equal or lower adjacent buildings.Easy3BFSGraph+1No attempts yet1s128 MBJudgeable
Strahler orderGiven a river DAG, compute its Strahler order at node M by processing nodes in topological order.Easy3Topological sortGraphNo 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
Rainforest CanopyCount the groups of 1s connected through all eight neighbours in each square binary image.Easy3DFSGraph+1No attempts yet1s128 MBJudgeable
Bi-coloringCount the two-colorings where every edge joins different colors, or report -1 when the graph is not bipartite.Easy3BFSGraphNo attempts yet1s128 MBJudgeable
Mystery Graph ColoringColor vertices 0 to V-1 with the smallest color unused by colored neighbors, then print the color count, the colors, and the loop counter.Easy3GraphGreedy+1No attempts yet1s128 MBJudgeable
Balance ScaleGiven pairwise heavier-than results, count for each object how many others have no implied comparison.Easy3GraphDFSNo attempts yet1s256 MBJudgeable
Neighborhoods in GraphsCount the distinct vertices at distance 1 or 2 from a query vertex in an undirected graph, excluding the vertex itself.Easy3BFSGraphNo attempts yet1s256 MBJudgeable
Algorist ClubThe program gives each unfamiliar pair in input order the lowest free of max-degree-plus-one slots and prints zeros when a pair fits nowhere.Easy3SimulationGraphNo attempts yet1s256 MBJudgeable
Permutation CyclesCount the disjoint directed cycles in the permutation given in each test case.Easy3GraphDFSNo attempts yet1s256 MBJudgeable
DOM TV ChannelsPensioners switch the TV from each hated channel to the youngest hater's favorite, and you count switches until the channel stabilizes or repeats.Easy3GraphSimulationNo attempts yet1s256 MBJudgeable
Cable CleanupFor each test case, keep N minus 1 of the M cables that join N computers into one network and print how many cables go.Easy3GraphMathNo attempts yet1s256 MBJudgeable
Legacy CodeCount methods unreachable from any PROGRAM method given each method and its direct callers.Easy3GraphBFSNo attempts yet1s256 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
One sheep... two sheep...Count the groups of # cells connected up, down, left, or right in each test grid.Easy3DFSGraph+1No attempts yet1s256 MBJudgeable
Pub-lic GoodColor each site pub or house with the specified ordered depth-first search so every site neighbors an opposite color, or print Impossible.Easy3DFSGraph+1No attempts yet1s256 MBJudgeable
Spawn of UngoliantSpiders spread to every tree connected by four-directional adjacency to an infested tree, and isolated trees and open floor stay unchanged.Easy3BFSGraph+1No attempts yet1s256 MBJudgeable
Path FindingDecide for every ordered pair of vertices in a directed graph with up to 100 vertices whether a path of at least one edge connects them.Easy3GraphDynamic programmingNo attempts yet1s256 MBJudgeable
Manhattan Power FailureCount the blocks linked by intact lines into regions and report how many regions hold no generator.Easy3Union-findGraphNo attempts yet1s256 MBJudgeable
The Game of DeathStarting from player 1, follow the pointed-to players and report the first step that reaches player N, or 0 when it never does.Easy3GraphSimulationNo attempts yet1s256 MBJudgeable
Relief SuppliesDecide whether any walk starting at intersection 1 in a directed graph can revisit an intersection.Easy3DFSGraphNo attempts yet2s256 MBJudgeable
Number of connected componentsCount the connected components of an undirected graph given its vertices and edges.Easy3GraphDFSNo attempts yet3s512 MBJudgeable
Squawk VirusStarting from user s, propagate squawk counts along links for t minutes and report how many squawks are sent at time t.Easy3Dynamic programmingGraphNo attempts yet1s256 MBJudgeable
Dynamic Grid (Small)Count the edge-connected groups of 1s in a binary grid after each point update by flood fill.Easy3BFSGraph+1No attempts yet5s512 MBJudgeable
Bad Horse (Small 1)Decide for each test case whether members joined by troublesome pairs split into two groups with no pair in one group.Easy3GraphBFSNo attempts yet5s512 MBJudgeable
Bad Horse (Small2)Decide whether members linked by troublesome pairs split into two groups with no pair inside one group.Easy3GraphBFSNo attempts yet5s512 MBJudgeable
Sort a scrambled itinerary (Small)Rebuild each shuffled set of flight tickets into the single chain where each arrival matches the next departure.Easy3Hash mapGraphNo attempts yet5s512 MBJudgeable
Twibet (Small)Starting from each monk in turn, count how many monks hear a whisper that spreads from a monk to all direct and indirect followers.Easy3GraphDFSNo attempts yet5s512 MBJudgeable
Router 1Print either a star-shaped router with one internal hub or a fully connected bipartite router, depending on whether N*N exceeds P_lim.Easy3GraphImplementation+1No attempts yet2s512 MBJudgeable
Router 3Build a router with g groups per layer by printing 2Ng directed edges from inputs to internal nodes and from internal nodes to outputs.Easy3GraphImplementation+2No attempts yet2s512 MBJudgeable
Two-color coloringGiven an undirected multigraph, decide whether it is bipartite so its vertices can be colored with two colors.Easy3GraphBFS+1No attempts yet2s256 MBJudgeable
Misimplemented DinicPrint a fixed 4-vertex, 5-edge flow network; there is no input and the output is a single constant graph.Easy3GraphBrute force+1No attempts yet2s512 MBJudgeable
Election of EvilGiven directed persuasion edges and a set of already-controlled representatives, list the reachable members of target set V in alphabetical order.Easy3GraphBFS+2No attempts yet2s512 MBJudgeable
Prison BreakGiven a grid of '+' and '*' huts where movement is allowed only between huts of the same symbol, decide whether the entry hut can reach the exit hut.Easy3GraphBFS+1No attempts yet2s512 MBJudgeable
Vera and Trail BuildingGiven K, follow a fixed greedy decomposition into complete blocks and print the resulting connected trail network with exactly K two-edge-disjoint paths.Easy3GreedyGraph+2No attempts yet1s512 MBJudgeable
BannerCount connected groups of 1s in an M by N grid where cells touching in any of the eight directions belong to the same group.Easy3GraphDFS+2No attempts yet2s512 MBJudgeable
Tracking Fake NewsModel a story spreading through a social network where each person reposts only if a weighted sum of the story's categories equals their target.Easy3GraphBFS+1No attempts yet2s512 MBJudgeable
Easy Shortest DistanceGiven a grid with one target cell and blocked cells, find the shortest distance from each open cell to the target using 4-directional moves.Easy3BFSGraph+1No attempts yet1s128 MBJudgeable
Paint bucketFlood fill a grid from one pixel, repainting all side-connected pixels sharing the clicked color with a new color, then print the grid.Easy3GraphBFS+2No attempts yet2s512 MBJudgeable
Knight minimum movesGiven two squares on an 8x8 chessboard, output the fewest knight moves needed to get from the first to the second.Easy3BFSGraph+1No attempts yet2s512 MBJudgeable
Xayahh-Rakann at Moloco (Easy)Given n jars and inseparable pairs, decide if exactly k jars can be kept so that no inseparable pair is split across the two groups.Easy3Brute forceGraph+1No attempts yet2s512 MBJudgeable