#trees
CF 2222G - Statistics on Tree
CF 2222G - Statistics on Tree Rating: - Tags: binary search, brute force, dfs and similar, divide and conquer, graphs, trees Solve time: 6m 33s Verified: no Solution Problem Understanding We are given a tree. For a pair of vertices $(u,v)$, we remove every edge belonging to the unique simple path between them. After those edges are deleted, the tree breaks into several connected components. The value of the pair...
CF 1949C - Annual Ants' Gathering
CF 1949C - Annual Ants' Gathering Rating: 1900 Tags: dfs and similar, dp, greedy, trees Solve time: 4m 48s Verified: yes Solution Problem Understanding Each vertex of the tree initially contains exactly one ant. A move chooses an edge $(u,v)$ and orders all ants currently gathered at $u$ to move to $v$. The ants obey only when the destination already contains at least as many ants as the source. If...
CF 1949F - Dating
CF 1949F - Dating Rating: 2200 Tags: greedy, sortings, trees Solve time: 1m 57s Verified: no Solution Problem Understanding Each user can be viewed as a set of activities. We need to find two users whose sets satisfy three conditions simultaneously: They share at least one activity. The first user has at least one activity that the second user does not have. The second user has at least one activity...
CF 1949J - Amanda the Amoeba
CF 1949J - Amanda the Amoeba Rating: 2600 Tags: graphs, implementation, trees, two pointers Solve time: 1m 3s Verified: no Solution Problem Understanding We are asked to guide Amanda the Amoeba from an initial configuration to a target configuration on a rectangular grid. Each configuration marks Amanda's body with * , free pixels with . , and blocked pixels with X . Her body is connected and contains at least...
CF 48G - Galaxy Union
CF 48G - Galaxy Union Rating: 2700 Tags: dp, trees, two pointers Solve time: 2m 23s Verified: yes Solution Problem Understanding We are given an undirected weighted graph with exactly n vertices and n edges. Since a connected graph with n vertices and n edges contains exactly one cycle, the graph is a unicyclic graph, a tree with one extra edge. For every planet u , we must compute the...
Finger Search
Finger Search Finger search exploits locality. Instead of searching from the root or beginning, it starts from a known position called a finger and moves toward the target. The cost depends on the distance between the finger and the target, not the total size of the structure. This method appears in ordered data structures such as balanced trees, skip lists, and sorted arrays with auxiliary links. Problem Given an ordered...