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,012 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
ValleysGiven an N x N grid of distinct heights, sum the sizes of all non-holey edgewise-contiguous regions whose cells are strictly lower than every orthogonally adjacent border cell.Hard9Union-findGraph+2No attempts yet2s512 MBJudgeable
Beautiful ManyeongroCount directed paths in a rooted tree whose edge-label string equals a given pattern P.Hard9TrieDFS+2No attempts yet2s512 MBJudgeable
Wind of ChangeTwo weighted trees on the same vertex labels define a distance as the sum of both tree distances; for every vertex find the nearest other vertex under that combined metric.Hard9TreeDivide and conquer+2No attempts yet10s1024 MBJudgeable
CityAssign small integer codes to nodes of a tree where depth from node 0 is at most 18, so that a decoder with only the two codes can tell which of two cities lies on the path from 0 to the other.Hard9TreeBit manipulation+2No attempts yet2s512 MBJudgeable
Bracket Euler TourFind an Euler tour of an undirected graph whose vertex bracket labels, read in traversal order, form a correct bracket sequence, or report that none exists.Hard9GraphDFS+2No attempts yet2s512 MBJudgeable
Rooted SubtreesFor each query with two roots r and p, count the distinct non-empty sets that are the intersection of a subtree of the tree rooted at r and a subtree of the tree rooted at p.Hard9TreeDFS+2No attempts yet11s512 MBJudgeable
814 - 2Print an 8 by 14 grid of digits so that every number from 1 up to some X can be traced as an adjacent-cell path, maximizing X.Hard9GraphDFS+2No attempts yet0.814s814 MBJudgeable
Karaoke MeetupIn a weighted tree, some vertices are marked as houses. For each vertex compute the ratio of the nearest marked vertex distance to the farthest, and output the maximum ratio as a reduced fraction.Hard9TreeDFS+2No attempts yet8s512 MBJudgeable
Phone CallA tree of houses has m phone lines, each letting any two vertices in the union of two tree paths call at cost w. Find the maximum number of reachable houses from house 1 and the minimum cost.Hard9GraphMinimum spanning tree+2No attempts yet1s512 MBJudgeable
Master Zhu and RikkaGiven a rooted tree with values on vertices, answer queries that ask for the GCD of sums of values occurring exactly a times and exactly b times in a subtree or on a path.Hard9TreeDFS+2No attempts yet3s512 MBJudgeable
Pet TreeCount assignments of edge lengths (each within its own interval) to a tree's edges so the resulting tree diameter falls between S and E, modulo 1e9+7.Hard9Dynamic programmingTree+2No attempts yet8s1024 MBJudgeable
IslandGiven the edge list of a tree whose N leaves are towns and whose internal nodes all have degree at least 3, count the distinct circular orderings of the leaves realizable as the outer face, and print the count as a product of prime powers.Hard9TreeDFS+2No attempts yet1s512 MBJudgeable