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
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| ExperienceGiven a rooted tree with values on nodes, partition nodes into vertex-disjoint downward paths to maximize the sum over paths of (max value minus min value). | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ANTSGiven a tree and a set of up to 50 marked nodes per query, find the node minimizing the sum of distances to all marked nodes, for up to 5000 queries. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CitationsOrder the reading of a citation tree rooted at book 1 so that the sum of all book return times is minimized. | Hard8 | TreeGreedy+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Love PolygonEach of N people loves exactly one person; rewrite the minimum number of love targets so that everyone ends up in a mutual pair. | Hard8 | GraphGreedy+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| PathsCount simple paths in a vertex-colored graph where every vertex on the path has a distinct color, counting both directions separately. | Hard8 | GraphDFS+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Pineapple FarmingOn a grid of heights with all outside cells treated as height 0, find the largest connected set of cells that forms a puddle bounded by strictly taller neighbors for some threshold h. | Hard8 | Union-findBFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Office RelocationGiven a weighted tree with marked query and leaf-coloured vertices, compute for every marked vertex the sum of squared weighted distances to coloured leaves (mod a prime). | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Ttururu TturuCount self-avoiding walks of length 10 on an R x C grid whose cell contents read exactly "ttururu tturu" (the 5-letter chorus "뚜루루뚜루" written row-wise twice). | Hard8 | DFSBrute force+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Kingpin EscapeAdd as few edges as possible to a tree with root h so that destroying any one edge still leaves every node connected to h; output the new edges. | Hard8 | TreeGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TreeChoose exactly m black vertices on a tree so that the maximum distance between any two chosen vertices is as small as possible. | Hard8 | TreeBinary search+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Tree in TreeFor each vertex subset, count the edges in its minimal connecting subtree using Euler tour order and LCA checks. | Hard8 | TreeDFS+2 | No attempts yet | 6s | 512 MB | Judgeable |
| Living SubgraphFind the smallest node set whose induced subgraph is connected and stays connected after deleting any one of its nodes. | Hard8 | GraphBFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Katty and WonkiAdd 2 edges to an N-vertex tree to maximize vertices lying on created cycles; return that maximum for the worst case for the tree owner. | Hard8 | TreeGraph+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Colorful TreeMaintain vertex colors on a tree under point updates and answer queries giving the number of edges in the minimal subtree spanning all vertices of one color. | Hard8 | TreeDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Cat DatingIn a rooted tree, each den holds female cats or male cats with a fall limit; count the maximum number of female-male pairs where a male can reach a female downward within the distance limit. | Hard8 | DFSGreedy+2 | No attempts yet | 4s | 1024 MB | Judgeable |
| Graph and QueriesMaintain an undirected graph under edge insertions and deletions, answering connectivity queries between two vertices after each update. | Hard8 | GraphUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree and Queries 12Maintain a forest under edge insertions and deletions, and answer connectivity queries between two vertices. | Hard8 | TreeUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 3-SAT 2Given a 3-CNF formula with N variables and M clauses, decide whether it is satisfiable and, if so, output a satisfying assignment. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cow LandOn a weighted tree, support point value updates and path XOR queries between any two nodes, returning the XOR of enjoyment values along the unique route. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Dynamic CentroidFor each prefix tree formed by vertices 1..k, output the smallest centroid (the vertex whose removal leaves components of size at most k/2). | Hard8 | TreeDFS+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| The Valley OverflowsGiven a tree of valleys with heights, decide whether water starting from any non-K valley can reach valley K under the splash-up movement rule. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Ali's TypewriterGiven a keypress sequence that builds strings in a buffer and prints them, answer queries counting how often printed string x occurs inside printed string y. | Hard8 | StringTrie+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Overflowing BanknotesFor each query, after updating one node, find the maximum banknotes that can be gathered at one safe when any node is chosen as root and the coins fall optimally. | Hard8 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| kdh9949Find the longest path in an undirected graph whose vertex labels spell repeated KDH blocks, or report -1 if such a path can be infinite. | Hard8 | GraphDynamic programming+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Tree Colors and QueriesA rooted tree where edges are deleted over time; after each deletion, count distinct colors among vertices still reachable from a queried vertex. | Hard8 | DFSTree+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Expression TreeGiven a binary expression tree with + and - operators, permute the operand values freely to maximize the evaluated result. | Hard8 | TreeGreedy+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Black StonesGiven a tree with some vertices marked black, count how many queries (i, j) admit a connected subtree with exactly i vertices and j black vertices. | Hard8 | TreeDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| SpyGiven a subordinate subtree for every leader in two rooted trees of N employees, count for each IOI employee how many of the M spy projects succeed, where spy b succeeds when the matching JOI employee lies in research project b's subtree. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| White Day Present ExchangeEach student gives treats to one other student; choose whether each makes cookies or cake to maximize total happiness from what they receive. | Hard8 | GraphDynamic programming+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Inquiry IIGiven a connected simple graph with at most n+15 edges, output the size of its maximum independent set. | Hard8 | TreeDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Grand Central StationGiven a tree, find the minimum number of distinct map designs (rooted drawings) such that every vertex can be the center of one design after relabeling. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| DžumbusGiven a forest of N friends with drink thresholds, and Q queries each supplying a total drink S, find the maximum number of people who exchange solutions. | Hard8 | Dynamic programmingTree+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Tree HuggingGiven 2(n-1) edges on n points, decide whether they can be split into a left-rooted increasing tree and a right-rooted decreasing tree, and output one such labeling. | Hard8 | GraphGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Game on a TreeAlice places a chip on a white node of a rooted tree, then players alternately move it to an unvisited ancestor or descendant, blackening that node; the player who cannot move loses. Determine the winner. | Hard8 | TreeGame theory+2 | No attempts yet | 1s | 256 MB | Judgeable |
| EquilibriumGiven a tree, order its vertices to minimize the sum over vertices of the absolute difference between neighbors placed after and before them. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Great GDPGiven a vertex-weighted tree and a value and weight per node, find the connected subtree containing the root that maximizes total value divided by total weight. | Hard8 | Binary searchGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Jumping PathGiven a rooted tree with labels, find the length of the longest ancestor chain with nondecreasing labels, and count how many such chains of that length exist modulo 11092019. | Hard8 | Dynamic programmingDFS+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Water Tanks of Seongdae CountryA tree of water tanks rooted at a capital. Adding water at city A adds 1,2,3,... along the root-to-A path. Answer queries about how much water a given city currently holds. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Bird WatchingGiven a digraph P known to contain the true edge set G plus some path-shortcut edges, list all in-neighbors a of T such that every path from a to T uses the edge (a, T). | Hard8 | GraphDFS+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Cave PaintingsCount modulo 1e9+7 the ways to fill empty cells of a bordered grid with water so that any lower-or-equal empty/water region reachable from a water cell is also water. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Free EdgesGiven an undirected graph, find the minimum number of edges to paint black so that repeatedly blackening a white edge incident to a vertex with exactly one white edge turns every edge black. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| The Older We Are, The Worse It HurtsRoot the tree anywhere and order each node's children so that the weighted sum of DFS discovery times is minimized; output that minimum. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Road NetworkGiven a tree, add one edge so that the number of bridges in the resulting graph is minimized, and report that minimum count. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Awesome ShawarmaGiven a tree, count the unordered pairs of nodes whose added edge leaves the number of bridges in [L, R]. | Hard8 | TreeDFS+2 | No attempts yet | 14s | 512 MB | Judgeable |
| Tree HullMaintain a set of tree vertices under insertions and deletions, and after each query report the total edge weight of the minimal subtree spanning the current set. | Hard8 | TreeDFS+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Matching In MultiplicationGiven a bipartite graph where each of the n vertices on one side has degree 2, sum the products of edge weights over all perfect matchings, modulo 998244353. | Hard8 | GraphMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Remove the TreeGiven a tree, repeatedly delete the vertices of any chosen path (and incident edges); find the minimum number of path-deletions needed to remove every edge. | Hard8 | TreeGreedy+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Hokusai ArtworksOn a directed graph, each city has a museum open only on even days; find the maximum total weight of distinct museums visitable starting at city 0 on an even day. | Hard8 | GraphDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| MonkeysChoose K vertices of a tree and delete edges so every chosen monkey can reach another, minimizing the number of surviving edges. | Hard8 | TreeDynamic programming+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Cleaning RobotsCount the ways to partition all vertices of a tree into vertex-disjoint paths such that no two paths can be merged into a longer path. | Hard8 | TreeDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Antennas On TreeFind the smallest set of tree vertices whose distance vectors distinguish every vertex from every other vertex. | Hard8 | TreeDFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Delivering FlyersOn a unit-weight tree, find the shortest closed walk from S that covers every node, given the rider can cover all nodes within distance D from any single stop. | Hard8 | TreeGreedy+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Second Diameter of a TreeGiven a weighted tree with up to 100,000 vertices, find the distance of the second farthest pair of vertices, allowing a tie with the diameter. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Internet ProblemGiven a directed graph, find all vertices lying on every walk from 1 to n, and only on walks from 1 to n, so a walk passes through each chosen vertex exactly once. | Hard8 | GraphDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Roadside AdvertisementsOn a weighted tree, for each of Q queries with five distinct nodes, find the total weight of every edge lying on some shortest path between a pair of the five. | Hard8 | TreeGraph+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Rock ClimbingFind the smallest K such that every K-subset of N rocks contains two rocks A, B with A reachable from B by a strictly upward chain of moves, each move bounded by the max slippery rate. | Hard8 | GraphGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Similar ArraysGiven pairs of positions, decide whether there is an array with all distinct values and an array with a repeated value that agree on every listed comparison, and output both arrays. | Hard8 | GraphDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Pandemic 2On a weighted tree where some vertices start infected and the infection spreads along edges at speed one, find the maximum number of uninfected connected components that ever exist at one moment. | Hard8 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| StationsLabel the stations of a tree so that a station holding a packet can pick the correct next hop knowing only its own label, the target label, and its neighbours' labels. | Hard8 | TreeDFS+2 | No attempts yet | 20s | 1024 MB | Judgeable |
| Cactus Graph AutomorphismsCount automorphisms modulo 1e9+3 of a given vertex cactus graph with up to 200 vertices. | Hard9 | TreeCombinatorics+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Diameter of a CactusGiven a cactus graph (each edge in at most one cycle), compute the maximum shortest-path distance between any two vertices. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| WoodpeckersCount ways to place N woodpeckers into two height-ordered trees so every visiting pair lands in different trees and their connecting segments never cross, modulo K. | Hard9 | TreeGraph+2 | No attempts yet | 10s | 128 MB | Judgeable |
| MoleGiven a tree, remove one edge and add one edge (keeping it connected) to minimize the tree's diameter, and output the resulting diameter with the edges swapped. | Hard9 | TreeGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Gates of LogicParse an ASCII-art diagram of logic gates and wires with grid tracing rules (junctions, crossings, negation, ports) and compute values propagated to every named output. | Hard9 | SimulationGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fool's GameSimulate the full two-player card game 'Fool' with optimal play from both sides and determine which player ultimately wins. | Hard9 | Game theoryDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Room AssignmentsGiven n-1 inventors' two-choice coins forming a graph, pick an edge for the organizer's own coin that maximizes his expected room rating while keeping a perfect assignment possible. | Hard9 | GraphUnion-find+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Moon of ValenciaGiven a map of places with satisfaction values and walking edges, decide for each query whether a simple path between two nodes exists that fits a time budget and yields a satisfaction sum within 0.1 of a target. | Hard9 | BacktrackingDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| OutsourcingGiven two directed labeled graphs (factories) with start and final nodes, decide whether the two sets of label sequences realizable as paths from start to final are identical. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| IdeasFor each directed tube, find the smallest set of ideas a packet must carry while traversing it so that every reachable person still receives all ideas they need. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Congruent Partition of ChocolateGiven a connected polyomino of at most 36 unit squares, decide whether it splits into two connected pieces that are congruent under rotation, reflection, and translation. | Hard9 | Brute forceDFS+2 | No attempts yet | 30s | 128 MB | Judgeable |
| Winmine (Minesweeper)Count the ways to place the remaining mines on the unrevealed squares so that every revealed number matches its adjacent mine count, modulo 1000003. | Hard9 | Dynamic programmingGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| The Herbalists' VillageGiven a friendship graph, decide whether it has a planar straight-line drawing where every vertex reaches infinity without crossing an edge. | Hard9 | GraphGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Paths in a TreeA rooted tree has weighted edges. Handle point updates to edge weights and queries that ask for the maximum-weight downward path from a vertex inside its subtree. | Hard9 | TreeSegment tree+2 | No attempts yet | 5s | 1024 MB | Judgeable |
| King's QuestFor each son, list every girl he likes such that a perfect matching still exists when he marries her. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Wandering Flea TrainersGiven two functional graphs on n labeled nodes, decide whether some vertex relabeling makes the graphs isomorphic, i.e. the fleas' dance is identical. | Hard9 | GraphDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| MessengersGiven a 2-connected graph, output the lexicographically smallest pair of search plans from city 1 so that for any single occupied non-capital city, both messengers together warn every city. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GarbageEach street needs its state flipped or not; a route is a simple cycle, and driving a street flips it. Find the minimum total length of cycles whose symmetric difference equals the set of streets needing a flip. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Milk MultidrinkDecide whether a tree with n nodes has a Hamiltonian path from 1 to n where consecutive vertices stay within distance two. | Hard9 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hard ChoiceAfter streets are closed one by one offline, answer for each query whether two edge-disjoint paths still connect the given pair of junctions. | Hard9 | GraphDFS+2 | No attempts yet | 5s | 128 MB | Judgeable |
| HighwaysGiven a tree plus extra highway edges, count for each query (x,y) the main tree path plus alternative single-highway paths that touch the main path only at x and y. | Hard9 | TreeDFS+2 | No attempts yet | 3s | 128 MB | Judgeable |
| It Takes a VillageProcess online trading-post additions that spread through biconnected blocks and capital dominators, and answer revenue queries for single villages. | Hard9 | GraphDFS+2 | No attempts yet | 20s | 128 MB | Judgeable |
| Bulb PuzzleYou rotate every elbow and straight wire so all wires form one path that joins the two bulbs, and print the smallest such layout. | Hard9 | GraphBacktracking+1 | No attempts yet | 1s | 256 MB | Judgeable |
| King GameOn a small board with burned squares, two players alternately move a king to an unvisited neighboring square; report who wins under optimal play. | Hard9 | Game theoryGraph+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Growing a Binary TreeFor each tree, pick a root and count the fewest vertices to add so that the result becomes a complete binary tree (every internal vertex has exactly two children, all leaves equidistant from the root), minimizing that count and then the vertex index; output the count mod 1e9+7. | Hard9 | TreeDFS+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Tree TransformationCount the minimum-size sets of edges whose removal splits the tree into components of power-of-two sizes, modulo 1e9+7. | Hard9 | TreeDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Trees and Queries 10Given a tree with vertex weights, answer path maximum-subarray-sum queries and path range-assign-weight updates. | Hard9 | Segment treeTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Lowest common ancestor in a dynamic forestMaintain a forest of rooted trees under link, cut, and lowest-common-ancestor queries, printing each LCA. | Hard9 | TreeLinked list+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cactus giftIn a cactus graph with up to 4000 vertices, count directed simple paths of each length 1 to N, modulo 1e9+7. | Hard9 | Dynamic programmingTree+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Bracket PathsGiven a tree with '(' or ')' on each node, count ordered pairs (a,b) whose path string w_{a,b} is a properly matched bracket expression. | Hard9 | TreeDivide and conquer+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Creating Fake NewsFind one story vector satisfying n linear equations, then the minimum number of starting people whose reach covers all n people. | Hard9 | MathGraph+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Good triples of pathsCount triples of simple paths in a tree that are either node-disjoint or pairwise intersecting, modulo 1e9+7. | Hard9 | CombinatoricsTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| One-Way StreetsGiven an undirected multigraph and required reachable pairs, decide for each edge whether every valid orientation matches the input direction (R), the reverse (L), or both are possible (B). | Hard9 | GraphDFS+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Laminar FamilyGiven an undirected tree and f vertex sets, each a simple path, decide whether the family of paths is laminar. | Hard9 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Secret AgentGiven a planar straight-line graph (castle walls) where crossing a wall costs its height, find the minimum cost to travel between successive query points, starting from infinity. | Hard9 | GraphGeometry+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Counting CyclesA connected undirected graph with n vertices and at most n+15 edges is given; count all simple cycles, where a simple cycle is a connected subgraph with every degree exactly two. | Hard9 | GraphDFS+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Revenge of the Broken DoorAn adversary hides one edge under construction; the traveler learns about an edge only upon reaching its endpoint and must minimize the worst-case distance from S to T. | Hard9 | GraphShortest path+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Tree EscapeOn a rooted tree where each leaf starts with one piece, players alternately move a piece to its parent and remove it at the root; decide if the first player wins. | Hard9 | Game theoryTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Octoppang CountryGiven a connected unweighted graph with K infected vertices and threshold T, compute for every vertex the number of uninfected vertices left when it is deleted and each component with at least T infected vertices spreads infection fully. | Hard9 | TreeDFS+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Prime Tree - 7Relabel the vertices of each given tree with 1..n so that the number of edges whose endpoints share a common divisor above 1 is minimized, and submit the answer file. | Hard9 | GreedyNumber theory+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Youngkwail Club RoomCover all '.' cells of a grid with 1x1 and 1x2 tiles, avoiding 'X' pillars, using the fewest tiles possible. | Hard9 | GraphDFS+2 | No attempts yet | 1s | 256 MB | Judgeable |