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 results505 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| LiesUsing union-find on party attendees, determine which parties can be exaggerated without conflicting with people who must always hear the truth. | Easy3 | Union-findGraph+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Disjoint Set OperationsImplement a union-find structure that merges sets and answers whether two elements share a set across a sequence of operations. | Easy3 | Union-find | No attempts yet | 2s | 128 MB | Judgeable |
| Avoiding Food WasteGiven a grid marked with food waste cells, find the size of the largest 4-directionally connected component using BFS/DFS or union-find. | Easy3 | BFSDFS+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Travel PlanGiven an adjacency matrix of cities, decide if consecutive cities in a given visit order all lie in the same connected component. | Easy3 | Union-findGraph+1 | No attempts yet | 2s | 128 MB | Judgeable |
| NetworkingGiven points and weighted candidate cable routes, compute the minimum total cable length needed to connect all points (minimum spanning tree). | Easy3 | Minimum spanning treeGraph+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Connected or Not ConnectedGiven a graph with n sites and k edges, decide whether every site can reach every other. | Easy3 | GraphDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Social Networking ApplicationGiven a friendship graph, answer queries asking whether two users lie in the same connected component. | Easy3 | Union-findGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rectangle ColoringCount the groups of overlapping rectangles where touching edges count as overlap and each group gets one color. | Easy3 | Union-findGeometry | No attempts yet | 1s | 128 MB | Judgeable |
| The SuspectsCount every student connected to student 0 through shared groups, since one suspect makes each joined group suspect. | Easy3 | Union-find | No attempts yet | 1s | 128 MB | Judgeable |
| Counting Communication GroupsCount the connected groups of camps whose circular communication areas touch or overlap. | Easy3 | Union-findGeometry | No attempts yet | 8s | 256 MB | Judgeable |
| Rings of SaturnFind every connected group of exactly seven people, sum the threat levels inside each group, and list them by total threat. | Easy3 | Union-findSorting | No attempts yet | 2s | 256 MB | Judgeable |
| Manhattan Power FailureCount the blocks linked by intact lines into regions and report how many regions hold no generator. | Easy3 | Union-findGraph | No attempts yet | 1s | 256 MB | Judgeable |
| Club Room Project (Small)Given N rooms in a row and M wall-breaking actions, count how many rooms remain after all actions merge neighboring rooms. | Easy3 | Union-findImplementation | No attempts yet | 1s | 512 MB | Judgeable |
| ExploraceGiven a weighted undirected graph of checkpoints, find the minimum total length of edges that keeps every checkpoint connected. | Easy3 | Minimum spanning treeGraph+2 | No attempts yet | 3s | 512 MB | Judgeable |
| TreehousesConnect all treehouse points plus the first e ground access points by cables of minimum total length, given some cables already exist; output the added length as a MST problem. | Easy3 | Minimum spanning treeUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Minimum Spanning TreeCompute the total edge weight of a minimum spanning tree for a weighted undirected graph with up to 10,000 vertices and 100,000 edges, allowing negative weights. | Medium4 | Minimum spanning treeUnion-find+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Different Religions on CampusGiven pairs of students sharing a religion, compute the maximum number of distinct religions possible using union-find over multiple test cases. | Medium4 | Union-findGraph | No attempts yet | 1s | 128 MB | Judgeable |
| Ripple EffectValidate a filled Ripple Effect puzzle grid by checking polyomino region digit ranges and minimum-distance spacing rules for repeated numbers in rows and columns. | Medium4 | Union-findSimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Network ConnectionGiven N computers and M weighted possible connections, compute the minimum total cost of edges to connect all computers into one network (minimum spanning tree). | Medium4 | Minimum spanning treeUnion-find+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Meeting PreparationFind connected components in a graph and for each pick the vertex minimizing the eccentricity (graph center). | Medium4 | GraphBFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Slim SpanGiven a weighted graph, find the spanning tree that minimizes the difference between its largest and smallest edge weight, or report -1 if disconnected. | Medium4 | Union-findSorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Jungle RoadsGiven a connected weighted graph of villages and roads, find the minimum total maintenance cost of a set of roads that keeps every village connected. | Medium4 | Minimum spanning treeGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Stock ChaseGiven share-purchase transactions between companies in order, count how many must be rejected because they would create a cycle. | Medium4 | Union-findGraph | No attempts yet | 1s | 128 MB | Judgeable |
| Money MattersGiven each person's balance and a friendship graph, decide whether all debts can be settled by moving money only within connected components. | Medium4 | Union-findGraph+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Army BuddiesAfter each loss report removes living soldiers L through R, print the nearest surviving neighbors on both sides, or * when none exists. | Medium4 | Union-findLinked list+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Is It a Tree?For each test case, read directed edges until a pair of zeros and decide whether the graph is a tree under the three given conditions, printing the case number and verdict. | Medium4 | GraphUnion-find+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ChochlikDecide for each department whether wheels linked by same-direction and opposite-direction belts can all spin without contradiction. | Medium4 | Union-findGraph+1 | No attempts yet | 1s | 512 MB | Judgeable |
| More Fun in BicolGiven unit compass offsets between named places, answer each query with the direction from one place to the other or report it as unknown. | Medium4 | Union-findGraph | No attempts yet | 5s | 128 MB | Judgeable |
| Watering the FieldsConnect all fields with pipes costing at least C while minimizing total squared distance, or report -1 when impossible. | Medium4 | Minimum spanning treeUnion-find+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pangaea 1After each added road, compute the cheapest total length connecting all cities and XOR the m totals per test case. | Medium4 | Minimum spanning treeUnion-find+1 | No attempts yet | 20s | 256 MB | Judgeable |
| AirportEach arriving plane takes the largest free gate up to its limit gi, and the count stops at the first plane with no free gate. | Medium4 | Union-findGreedy | No attempts yet | 1s | 256 MB | Judgeable |
| Troop MovementFind the route between two cities whose narrowest road is as wide as possible and report that width. | Medium4 | Minimum spanning treeUnion-find+1 | No attempts yet | 2s | 256 MB | Judgeable |
| One Stroke DrawingDecide whether given line segments form a shape drawable in one stroke without retracing any segment. | Medium4 | GraphUnion-find | No attempts yet | 2s | 256 MB | Judgeable |
| Number Sets (Small)Count how many disjoint sets remain after merging numbers in [A, B] that share a prime factor of at least P. | Medium4 | Union-findNumber theory | No attempts yet | 5s | 512 MB | Judgeable |
| Watersheds (Small)Given a height grid, follow each cell's outflow to its sink and label cells by shared sink, choosing basin letters to make the row-wise string smallest. | Medium4 | GraphDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| The Enemy of My EnemyDecide whether the N people can be split into two camps so that every given hostile pair lands on opposite sides, which is exactly bipartiteness. | Medium4 | GraphBFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TreeGiven up to 10 graphs, decide for each whether it is a tree, allowing self-loops and duplicate edges. | Medium4 | GraphUnion-find+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Balls and NeedlesGiven K segments in 3D defined by endpoint triples, decide whether they form a closed cycle in space and whether their projections onto the xy-plane form a closed cycle. | Medium4 | GraphUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Rebel Against The Empire (Small)Given stationary points in 3D, find the smallest jump radius that lets you reach asteroid 1 from asteroid 0, ignoring the time limit. | Medium4 | GraphUnion-find+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Club Room Project (Large)For each action, remove all walls between rooms x and y; print how many connected room blocks remain. | Medium4 | Union-findArray | No attempts yet | 1s | 512 MB | Judgeable |
| League of Overwatch at Moloco (Hard)Given n employees and m conflict pairs, decide whether the employees can be split into two non-empty groups so that no pair shares a group. | Medium4 | GraphDFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| I Will Be Your Bridge!A tree lost one edge, splitting it into two components. Print any pair of islands, one from each component, that reconnects the tree. | Medium4 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Toy AlliancesGiven N toys and M dislike pairs, decide whether the toys can be split into two alliances so no dislike pair shares a side, which is checking bipartiteness of the graph. | Medium4 | GraphBFS+2 | No attempts yet | 1.5s | 256 MB | Judgeable |
| Connecting a Road GraphGiven an adjacency matrix, find the minimum number of edge-swap operations needed to make the graph fully connected, or report -1 if impossible. | Medium5 | GraphUnion-find+1 | No attempts yet | 2s | 128 MB | Judgeable |
| City Division PlanSplit a connected weighted graph into two connected subvillages by removing edges so that the total remaining maintenance cost is minimized. | Medium5 | Minimum spanning treeUnion-find+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Communicating with the Space GodsGiven points with some already connected, find the minimum total length of new passages needed to connect all points into one network. | Medium5 | Minimum spanning treeUnion-find+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Designing a High-Speed Rail NetworkGiven a cost matrix where negative values mark already-built rail lines, compute the minimum spanning tree cost forcing existing lines and list the new lines to build. | Medium5 | Minimum spanning treeUnion-find+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Weight LimitGiven a weighted undirected graph, find the maximum possible minimum edge weight (bottleneck) along any path between two given nodes. | Medium5 | Union-findBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Stable GroupGiven a like/dislike matrix, decide if people can be partitioned into groups (size at least 2) where members like each other within groups and dislike each other across groups, and output that partition. | Medium5 | Union-findGraph+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Crane DeliveryGiven cranes with fixed positions and reach radii starting from a fixed entrance point, decide for each of K target points whether it lies in the union-reachability graph of overlapping crane discs starting from the entrance. | Medium5 | GraphUnion-find+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Play on WordsDetermine whether all given words can be chained into one sequence where each word's first letter matches the previous word's last letter, using Eulerian path conditions on a letter graph. | Medium5 | GraphUnion-find+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Network ConnectionSimulate weighted union operations that always merge into the second cluster's center, and answer path-length queries to the current cluster center. | Medium5 | Union-findImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bridges and TunnelsAfter each new edge between two named buildings, print the size of the connected component that the edge joins. | Medium5 | Union-findHash map+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Building the ConstellationGiven n points in the plane, connect all of them with straight segments of Euclidean length so the total cost is minimized. | Medium5 | Minimum spanning treeGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Crash and Go(relians)After each Gorelian lands in order, groups merge when one radio reaches another, meeting at the unweighted average of group positions and combining ranges by root sum of squares; report the final group count. | Medium5 | SimulationUnion-find+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tangled in CablesCompute the minimum spanning tree of a town map and compare its total length against the available spool of cable. | Medium5 | Minimum spanning treeGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TreesGiven an undirected graph, count its connected components that contain no cycle and report the count per test case. | Medium5 | GraphUnion-find+2 | No attempts yet | 1s | 256 MB | Judgeable |
| ConstellationsGiven up to 500 star coordinates, connect each star to its nearest neighbor(s) and count the connected components of the resulting graph. | Medium5 | GraphUnion-find+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tea TimeStarting from a graph of known meetings, two cows meet whenever they share a mutual friend, and after all rounds settle, answer queries about whether each pair has met. | Medium5 | GraphUnion-find+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Power ShortageGiven a connected weighted undirected graph, keep a subset of roads so every pair of houses stays connected while maximizing the total length of removed roads. | Medium5 | Minimum spanning treeGraph+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Railway ConnectionGiven existing rail links and city flows, find the minimum cost to connect all cities, where an edge costs the product of its endpoint flows. | Medium5 | Minimum spanning treeUnion-find+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| HighwaysConnect all towns with the cheapest new highways, where some links already exist, and report the summed squared lengths of the added edges. | Medium5 | Minimum spanning treeUnion-find | No attempts yet | 1s | 128 MB | Judgeable |
| A Bug's LifeGiven pairs of interacting bugs, decide whether a two-gender assignment exists so that no pair shares a gender. | Medium5 | Union-findGraph | No attempts yet | 3s | 256 MB | Judgeable |
| Heavy TransportationFind the maximum weight that can travel from crossing 1 to crossing n, defined as the path whose smallest street limit is as large as possible. | Medium5 | GraphMinimum spanning tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium5 | GraphDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| TilesGiven n, k, l, find the number of equivalence classes of positions 1..n under the equivalence generated by steps of ±k and ±l. | Medium5 | Number theoryUnion-find+1 | No attempts yet | 1s | 128 MB | Judgeable |
| HighwaysFind a spanning tree of a connected weighted graph that minimizes the maximum edge weight, and report that weight. | Medium5 | Minimum spanning treeGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Word Translation LookupGiven pairs of directly translated words, list every target-language word linked to each query word through translation chains. | Medium5 | Union-findHash map+1 | No attempts yet | 12s | 128 MB | Judgeable |
| Widest PathFind the path between two given nodes whose smallest edge weight is as large as possible. | Medium5 | Minimum spanning treeUnion-find+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CommunicationConnect all rooms in a 3D grid with the cheapest new links given some existing links and fixed horizontal and vertical costs. | Medium5 | Minimum spanning treeUnion-find+1 | No attempts yet | 1s | 128 MB | Judgeable |
| RoadDecide whether the road between p and q can belong to a cheapest network that connects all cities. | Medium5 | Minimum spanning treeUnion-find+1 | No attempts yet | 2s | 64 MB | Judgeable |
| SumoFind the earliest scheduled fight that forces two wrestlers on the same team to meet under the best two-team split. | Medium5 | Union-findGraph | No attempts yet | 1s | 128 MB | Judgeable |
| Global WarmingGiven column heights, find the greatest number of maximal above-water runs over all real sea levels. | Medium5 | Union-findSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Cross Country SkiingFind the smallest elevation gap D that keeps every waypoint mutually reachable through adjacent cells. | Medium5 | Minimum spanning treeUnion-find+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Rat TunnelPick the cheapest lanes for cameras so every closed running route holds one, and report the total cost and the longest chosen lane. | Medium5 | Minimum spanning treeUnion-find+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Not enough electricityConnect every city to exactly one of the given power plants with minimum total cable cost. | Medium5 | Minimum spanning treeUnion-find | No attempts yet | 1s | 256 MB | Judgeable |
| Travel between two islandsAfter each bridge joins two neighboring islands, report how many island pairs are mutually reachable and the total bridge crossings summed over those pairs. | Medium5 | Union-findMath | No attempts yet | 1s | 16 MB | Judgeable |
| Flipping CardsDecide whether each card can show one of its two pictures so that all n face-up pictures differ. | Medium5 | GraphUnion-find | No attempts yet | 3s | 256 MB | Judgeable |
| Closing the FarmBarns close one by one in a given order, and the task asks after each step whether all open barns remain connected. | Medium5 | Union-findGraph | No attempts yet | 2s | 512 MB | Judgeable |
| Havannah (Small)The program places the given stones in order on a hexagonal board and reports the first move that completes a ring, bridge, or fork. | Medium5 | Union-findBFS | No attempts yet | 5s | 512 MB | Judgeable |
| 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. | Medium5 | GraphDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| 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. | Medium5 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| MoocastGiven N cow coordinates, find the smallest integer X such that the graph connecting pairs whose squared distance is at most X is connected. | Medium5 | GraphUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Why Did the Cow Cross the Road 6Given an N x N grid of pastures, some adjacent pairs blocked by roads, and K cows on distinct cells, count the pairs of cows that cannot reach each other without crossing a road. | Medium5 | GraphBFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Love That Only Fails for MeFind the minimum spanning tree of a graph restricted to edges joining a men-majority school and a women-majority school, or report -1. | Medium5 | GraphMinimum spanning tree+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Xayahh-Rakann at Moloco (Hard)Given n jars with m inseparable pairs, decide whether exactly k jars can be placed in one building so that no inseparable pair is split across the two buildings. | Medium5 | GraphUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Warring StatesProcess alliance and war records between groups, merging by sum for alliances and subtracting troops for wars, then report surviving groups sorted by troop count. | Medium5 | Union-findImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Population MovementRepeat until stable: open borders whose population difference is L to R, compute each connected union's floored mean population, and count the days with any change. | Medium5 | SimulationBFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Friendship FeeFind the cheapest way to become friends with everyone by paying each student a friend fee and using the friend-of-a-friend rule; output the minimum cost or "Oh no" when it exceeds k. | Medium5 | Union-findGraph+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Structure of Balanced NetworksGiven a complete signed graph where every triad is balanced, answer queries about the sign of the edge between two nodes. | Medium5 | GraphMath+2 | No attempts yet | 5s | 16 MB | Judgeable |
| Japan SinksRaise the sea level through the section heights and track how maximal runs of above-level sections merge; report the largest island count seen. | Medium5 | SortingUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Segments and QueriesProcess up to 100 queries that add intervals of strictly increasing length and ask whether two added intervals are connected by the overlap-based move relation. | Medium5 | GraphUnion-find+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fence PlanningConnect cows into groups given moo pairs, then find the axis-aligned rectangle of smallest perimeter that fully contains one group. | Medium5 | Union-findGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ArchipelagoGenerate a pseudorandom sequence of edges, add each new bridge between distinct islands, and find the earliest day the whole archipelago becomes connected or report 0. | Medium5 | Union-findSimulation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Experimental ChargesParticles carry unknown plus or minus charges; process attract/repel observations online and answer whether a queried pair must attract, must repel, or is unconstrained. | Medium5 | Union-findGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cutting a Cake with a HoleGiven a square cake with a smaller square hole in its center, count how many pieces result from horizontal and vertical full-line cuts that only affect actual cake material. | Medium6 | GeometryUnion-find+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Colored SticksGiven colored-end sticks, decide if they can all be joined into one line where touching ends share the same color, which reduces to checking an Eulerian path exists. | Medium6 | Union-findGraph+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing Chicken-Fight TeamsGiven friend/enemy relations among students where friends of friends are friends and enemies of enemies are friends, find the maximum number of valid teams. | Medium6 | Union-findGraph | No attempts yet | 2s | 256 MB | Judgeable |
| Collecting JewelsFind the maximum jewels collectible from a graph and returned to island 1 without exceeding any bridge's jewel-carrying capacity on any crossing. | Medium6 | Binary searchGraph+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Line DrawingGiven up to 10,000 line segments, count connected groups formed by segments that touch, overlap, or intersect, using geometric intersection tests combined with union-find. | Medium6 | Union-findGeometry | No attempts yet | 2s | 128 MB | Judgeable |