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 results1,013 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
DehuffGiven a sample string and its full binary encoding, reconstruct the unique prefix-code table for the alphabet, or report several possible tables.Medium7TreeDFS+2No attempts yet1s128 MBJudgeable
Follow My LogicParse ASCII circuit diagrams made of wires, junctions, AND/OR gates, and inversions, then evaluate the output for each given input assignment.Medium7SimulationImplementation+2No attempts yet1s128 MBJudgeable
Single Point of FailureFor each undirected connected graph, list every articulation point and the number of connected components its removal creates.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Peter's CalculatorParse assignment, PRINT, and RESET statements, evaluate expressions with variables, detect cycles or undefined references, and print values or UNDEF.Medium7ImplementationRecursion+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
Teams that can winGiven n teams and n-1 desired games, count the teams that can be champion under some valid single-elimination schedule that plays every listed game.Medium7GraphTree+2No attempts yet1s128 MBJudgeable
Safe Unlock CodeFor each n, print the lexicographically smallest de Bruijn sequence of order n over the digits 0 to 9, whose length is 10^n + n - 1.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Sinks of a GraphIn each directed graph, list every node v such that every node reachable from v can reach v back.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
The Settlers of CatanGiven an undirected graph where nodes have degree at most three, find the longest path that uses no edge more than once.Medium7GraphDFS+1No attempts yet1s128 MBJudgeable
Co-workers from HellPlace tricks in chambers so the watchman's walk, where each trick is used once to change dwell time and jump target, maximizes total time before he normally finishes chamber n.Medium7Dynamic programmingGraph+2No attempts yet1s128 MBJudgeable
LHCGiven a tree, find the maximum cycle length obtainable by adding one edge, and count the vertex pairs that achieve it.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
MobileDecide whether two mobiles, given as rooted binary structures with negated weight labels, can be rotated to look identical.Medium7TreeDFS+2No attempts yet1s128 MBJudgeable
Road ConstructionGiven a connected undirected graph, add the fewest edges so that deleting any single edge still leaves the graph connected.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Pyramid Message SchemeGiven a chronological list of message recipients from a sequential tree traversal, reconstruct the tree and compute the time saved by a parallel traversal.Medium7TreeStack+2No attempts yet1s128 MBJudgeable
Strategic BombingGiven an undirected graph of at most 26 points, find every edge whose removal disconnects A from B, listing them in input order.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Coke or Chocolate MilkAssign each person one of two drinks so that desire, hatred, sameness, difference, and conditional requests all hold, printing the alphabetically earliest Coke-preferring satisfying assignment or reporting failure.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Cycle DetectionGiven a graph on at most 20 vertices, for each edge that lies on a cycle, count how many distinct simple cycles contain it.Medium7GraphBrute force+2No attempts yet1s128 MBJudgeable
Uniform SubtreesGiven a parenthesis-encoded tree, list every distinct uniform subtree (same child count at each depth) in lexicographic order.Medium7TreeDFS+2No attempts yet3s128 MBJudgeable
PointsGiven up to 10000 directional rules between n points, decide whether real coordinates satisfy all of them at once.Medium7GraphDFS+1No attempts yet1s128 MBJudgeable
John's TripFind an Euler circuit in a connected multigraph that uses every street exactly once and is lexicographically smallest by street sequence, starting at the smaller endpoint of the first street.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Team Them UpSplit N people into two teams where teammates must mutually know each other, minimizing the size difference, and report the two team sizes.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Queen KingdomOn an n by n board with pillars blocking queens' attacks, find the maximum number of non-attacking queens and the number of placements attaining it.Medium7BacktrackingBrute force+2No attempts yet2s128 MBJudgeable
Tree GameOn a tree, players alternately move a token to an unchosen neighbor from Manco's start vertex; find all start vertices where Manco wins with optimal play.Medium7TreeGame theory+2No attempts yet1s64 MBJudgeable
Coloured LeavesGiven an unrooted tree whose leaves have fixed colors, choose an internal vertex as root and place the fewest labels so each leaf's color matches its last labeled vertex.Medium7TreeDFS+2No attempts yet1s128 MBJudgeable
Roman CorridorFind a left-to-right path through the grid whose symbol string is a valid Roman numeral and has the smallest decimal value.Medium7DFSGraph+2No attempts yet1s128 MBJudgeable
HospitalGiven substitution lists for special nurses, find those who can never take vacation and all pairs that can go individually but not simultaneously.Medium7GraphDFS+2No attempts yet2s128 MBJudgeable
Central TreeFor each weighted tree, find the vertex minimizing the sum of weighted distances to all other vertices and output that minimum sum.Medium7TreeDFS+2No attempts yet3s128 MBJudgeable
Lightning Energy ReportGiven a tree and many path updates that each add a value to every vertex on a path, report the final total at every vertex.Medium7TreePrefix sum+2No attempts yet1s256 MBJudgeable
Sightseeing TourDecide whether a mixed graph of one-way and two-way streets has a closed tour that uses every street exactly once starting and ending at the same junction.Medium7GraphUnion-find+2No attempts yet1s128 MBJudgeable
SignaturesGiven vouching edges among workers, commanders have no guarantors; list clerks whose reachability from some non-spy commander depends on a single commander.Medium7GraphDFS+2No attempts yet3s512 MBJudgeable
Gambling MachineGiven n generators, each mapping to a subset of generators, decide whether some choice of output order lets the machine halt at Gn with all sets exhausted (defeat) or must it halt elsewhere.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
AgentsGiven a directed graph of who unmasked whom and the bribe cost of some agents, find the minimum cost to bribe agents so arrests cascade to everyone, or the smallest unreachable, unbribable agent.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
Mudstock BisPlace a festival at a settlement on a star of railway lines to minimize the weighted sum of distances from all members, and report the cost and location.Medium7TreeDFS+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
Ridges and ValleysCount connected components of equal height in an n by n grid whose every boundary neighbor is strictly lower (ridge) or strictly higher (valley).Medium7GraphDFS+2No attempts yet3s128 MBJudgeable
The FloodGiven a grid of heights where city squares must be drained, find the minimum number of pumps so that water flows downhill from each city square to a pump.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
MegalopolisCount, for each query at a given moment, the number of still-country roads on the path from village 1 to a target village as edges are removed one by one.Medium7TreeDFS+1No attempts yet1s128 MBJudgeable
BlockadeFor each town, count planned visits ruined if it alone is removed, i.e. those crossing it plus visits to and from it.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
StationPick a tree vertex as the hub so that the average number of hub-to-vertex paths needed to travel between unordered pairs of vertices is minimized.Medium7TreeDFS+2No attempts yet1s128 MBJudgeable
GuildsSplit the towns into two sets so that each set is a dominating set and the sets are disjoint, or decide it is impossible.Medium7GraphDFS+2No attempts yet1s128 MBJudgeable
BridgesFind an Eulerian circuit from island 1 minimizing the maximum directed edge cost, or report that no such circuit exists.Medium7GraphBinary search+1No attempts yet3s512 MBJudgeable
Tour de ByteotiaBlock the fewest roads so no closed trail (no repeated road) passes through any of towns 1 to k.Medium7GraphDFS+2No attempts yet3s128 MBJudgeable
Winter Snow PlowingOn a tree, each edge must be traversed at least d_i times by one continuous walk; find the minimum total traversal count.Medium7TreeDFS+2No attempts yet1s128 MBJudgeable
Byton TreeGiven a tree in recursive notation, where each leaf has a time interval, find the minimum number of cuts (each cut picks every byton in the subtree at one moment) so that all intervals are covered.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
Planning the RoadworksGiven a directed graph, find a lexicographically smallest inclusion-maximal set of edges whose simultaneous removal leaves the reachability relation unchanged.Medium7GraphDFS+2No attempts yet2s512 MBJudgeable
RiddleDecide whether one town can be picked from each given group so that every edge of the graph has a chosen endpoint.Medium7GraphGreedy+1No attempts yet3s1024 MBJudgeable
BarricadesOn a tree, for each size k find the minimum number of edges to cut so that some connected component has exactly k vertices and no edges leave it.Medium7TreeDynamic programming+2No attempts yet1s128 MBJudgeable
RoadsGiven a directed graph, find the minimum number of edges to add so the whole graph becomes strongly connected.Medium7GraphDFS+1No attempts yet1s128 MBJudgeable
Critical Computers of the Byteland Information AgencyGiven a directed graph where every node is reachable from node 1, find all vertices whose removal makes some other vertex unreachable from node 1.Medium7GraphDFS+1No attempts yet1s128 MBJudgeable
Two PostmenSplit the edges of a tree rooted at node 1 between two postmen starting at the root so the later finishing time is minimized.Medium7TreeDynamic programming+2No attempts yet1s128 MBJudgeable
Rigged TournamentCount the players that can be made champion by scheduling matches against opponents they are certain to beat.Medium7GraphDFSNo attempts yet1s128 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
Non-Attacking KnightsPlace the most knights on a board with blocked squares so no two attack each other.Medium7GraphBFS+1No attempts yet1s128 MBJudgeable
ExpresswaysDecide whether some subset of the given roads touches every city an odd number of times.Medium7GraphMath+1No attempts yet1s128 MBJudgeable
TagA pursuer at K always steps toward an evader at J on a tree while the evader moves or waits to maximize the capture time.Medium7TreeGame theory+2No attempts yet5s128 MBJudgeable
Cactus GraphCount the simple cycles in an undirected graph, or print NIE when two cycles share more than one vertex.Medium7DFSGraphNo attempts yet5s128 MBJudgeable
MinesTrigger the fewest mines so chain reactions through overlapping blast squares detonate all N mines.Medium7GraphDFS+1No attempts yet1s128 MBJudgeable
TravelDecide whether a simple cycle exists that uses two required roads and avoids all toll roads.Medium7GraphDFSNo attempts yet1s128 MBJudgeable
Seminar RoomEach group submits two candidate time intervals, and the program picks one per group so that no two chosen intervals overlap.Medium7GraphDFS+1No attempts yet1s128 MBJudgeable
Electric NetworkGiven a connected network, compute the fewest new lines that keep every pair of facilities connected after any single line fails.Medium7DFSGraph+2No attempts yet1s128 MBJudgeable
Rabbits and SanggeunDecide whether deleting vertices and edges can leave a connected subgraph with exactly four degree-one vertices.Medium7GraphDFSNo attempts yet2s128 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
Magic GraphsPick one label from each of K pairs so that no two chosen labels are the positive and negative of the same number.Medium7GraphDFSNo attempts yet2s64 MBJudgeable
World Cup NominationsGiven every pairwise duel result, count the countries that can emerge last under some knockout pairing order.Medium7GraphDFSNo attempts yet1s128 MBJudgeable
ForensicChange at most one array entry so the pointer chain starting at index 0 visits as many distinct indices as possible before reaching -1.Medium7GraphDFSNo attempts yet2s512 MBJudgeable
Smallest LNR SequenceGiven n and a binary string s, find the position of s in the lexicographically smallest de Bruijn sequence of order n.Medium7GraphGreedy+1No attempts yet1s128 MBJudgeable
Bridge RemovalStarting from any island, a crew that spends a bridge length to cross or remove it must delete every bridge of a tree in the shortest total time.Medium7Dynamic programmingTree+1No attempts yet1s256 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
Jewelry ExhibitionYou choose the fewest unit-wide horizontal or vertical strips on integer lines to cover every exhibit point.Medium7GraphDFSNo attempts yet1s256 MBJudgeable
There is No AlternativeCount the bridges that appear in every minimum-cost set connecting all islands and report their total cost.Medium7Minimum spanning treeUnion-find+1No attempts yet3s256 MBJudgeable
Even distributionCount how many integers occur as the greatest common divisor of candy counts along some walk in the island graph.Medium7Number theoryGraph+1No attempts yet3s256 MBJudgeable
Palindromic PathsCount distinct palindromic strings spelled by right-down paths from the top-left to the bottom-right of an N by N letter grid.Medium7DFSHash map+1No attempts yet1s256 MBJudgeable
Cheating 2Place the most students on an N by M grid with broken seats so no two sit side by side or diagonally adjacent.Medium7GraphDFSNo attempts yet2s256 MBJudgeable
Deadlock DetectionGiven an instruction string of lock acquisitions and releases, decide whether any interleaving of ten threads running it can deadlock.Medium7GraphDFSNo attempts yet3s256 MBJudgeable
Shelob's LairDecide if a path from the south wall to the north wall can avoid all web segments except possibly one shared cut point.Medium7GraphGeometry+1No attempts yet5s256 MBJudgeable
2-SAT SatisfiabilityDecide whether N boolean variables admit values that satisfy all M two-literal clauses.Medium7GraphDFSNo attempts yet1s256 MBJudgeable
One-Way RoadsDecide whether undirected roads can be oriented into a strongly connected digraph and output the DFS-based orientation when possible.Medium7DFSGraphNo attempts yet1s256 MBJudgeable
AvoiderCount self-avoiding walks of each length from a to b in the first quadrant starting east from the origin and print the sum.Medium7BacktrackingDFS+1No attempts yet1s256 MBJudgeable
Exposing corruptionBribe members to switch parties within a budget while keeping rivals in different parties, and report the largest achievable DSP and PPP sizes.Medium7Dynamic programmingGraph+1No attempts yet3s256 MBJudgeable
Falling BlocksPlace a repeating sequence of pentomino pieces on a 3 by 10 board with Tetris drops and row clears to maximize the count, or report forever.Medium7GraphDFS+2No attempts yet4s256 MBJudgeable
Yonsei University Point GamePlayers paint tree nodes blue and queries ask for the sum of weighted distances from a node to all painted nodes.Medium7Divide and conquerTree+1No attempts yet5s128 MBJudgeable
Paradox Sort (Large)Given every pairwise candy preference, decide whether some hand-over order leaves Vlad holding candy A and output the lexicographically smallest such order.Medium7GraphDFS+1No attempts yet5s512 MBJudgeable
Full Binary Tree (Large)Delete as few vertices as possible from a given tree so the survivors form a full binary tree with a freely chosen root.Medium7Dynamic programmingTree+1No attempts yet5s512 MBJudgeable
Bacteria (Small)Pick the largest set of grid rooms with no two rooms on consecutive floors sharing a cell position.Medium7GraphBFS+1No attempts yet5s512 MBJudgeable
Bacteria (Large)Pick the most rooms so no two picked rooms share a cell position on consecutive floors.Medium7GraphBFS+1No attempts yet5s512 MBJudgeable
Wi-Fi Tower UpgradeChoose a set of towers to upgrade, where each upgraded tower forces every tower in its range to be upgraded, to maximize the total score.Medium7GraphGreedy+1No attempts yet5s512 MBJudgeable
Mixing Bowls (Large)Given a recipe where each mixture's ingredients are other mixtures, find the minimum number of bowls needed to prepare it.Medium7TreeDFS+2No attempts yet5s512 MBJudgeable
Busiest railway segment (large)Given a tree and Q paths, count how many paths use each edge and report the edge with the maximum count, breaking ties by lexicographic order of endpoints.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
Diamond InheritanceProcess class declarations in order, accepting each only if the name is fresh, all parents exist, and no diamond forms.Medium7GraphDFS+1No attempts yet2s512 MBJudgeable
Critical SubprojectsFind every vertex in a DAG that is comparable to all other vertices under reachability.Medium7GraphTopological sort+1No attempts yet0.6s32 MBJudgeable
Tree EditCut one weighted edge of a tree and reattach it elsewhere with the same weight; find the maximum possible diameter.Medium7TreeDFS+1No attempts yet2s512 MBJudgeable
Scrooge Minho 2Given a tree with N cities, place the fewest police stations so that every city and every road is covered, where a station covers its city, its neighbors, and all incident roads.Medium7TreeDynamic programming+2No attempts yet2s512 MBJudgeable
Hongjun and the Tree 2Count the ways to cut edges of a tree so every remaining component has exactly one black vertex, modulo 1e9+7.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
Holiday RoadsOn a tree, each of M families picks one of the other N-1 cities uniformly and independently; find the expected number of roads used by every family.Medium7TreeProbability+1No attempts yet2s512 MBJudgeable
Deciphering CharactersDecide whether two binary images represent the same character by comparing their connected components and the containment (surrounds) relations among them.Medium7GraphBFS+2No attempts yet2s512 MBJudgeable
Planar DrawingCheck a proposed certificate: verify an embedding's Euler formula or validate a subgraph as a subdivision of K5 or K3,3.Medium7GraphImplementation+2No attempts yet1s512 MBJudgeable
CodeCoder vs TopForcesEach citizen reaches another through a chain of pairwise wins on at least one of two rating sites; count reachable citizens from each node.Medium7GraphSorting+2No attempts yet2s256 MBJudgeable
Gangsters in Central CityOn a rooted tree, after each update marking a leaf as gangster-held, report the minimum pipes to clog and the fewest innocent houses left dry.Medium7TreeGreedy+1No attempts yet2s256 MBJudgeable
Path MagicFind the simple path in a tree minimizing (product of node values)/(path length), and output the reduced fraction.Medium7MathDFS+1No attempts yet4s256 MBJudgeable
First black vertex on a pathFlip vertex colors and, along the root-to-v path, report the first black vertex encountered from the root.Medium7TreeSegment tree+1No attempts yet2s512 MBJudgeable