knightnemo commited on
Commit
47d2738
·
verified ·
1 Parent(s): 542e33f

Upload code_segments/segment_329.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_329.txt +11 -0
code_segments/segment_329.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ In the heart of an ancient kingdom grows the legendary Tree of Life — the only one of its kind and the source of magical power for the entire world. The tree consists of $n$ nodes. Each node of this tree is a magical source, connected to other such sources through magical channels (edges). In total, there are $n-1$ channels in the tree, with the $i$-th channel connecting nodes $v_i$ and $u_i$. Moreover, there exists a unique simple path through the channels between any two nodes in the tree.
2
+
3
+ However, the magical energy flowing through these channels must be balanced; otherwise, the power of the Tree of Life may disrupt the natural order and cause catastrophic consequences. The sages of the kingdom discovered that when two magical channels converge at a single node, a dangerous "magical resonance vibration" occurs between them. To protect the Tree of Life and maintain its balance, it is necessary to select several paths and perform special rituals along them. A path is a sequence of distinct nodes $v_1, v_2, \ldots, v_k$, where each pair of adjacent nodes $v_i$ and $v_{i+1}$ is connected by a channel. When the sages perform a ritual along such a path, the resonance vibration between the channels $(v_i, v_{i+1})$ and $(v_{i+1}, v_{i+2})$ is blocked for each $1 \leq i \leq k - 2$.
4
+
5
+ The sages' task is to select the minimum number of paths and perform rituals along them to block all resonance vibrations. This means that for every pair of channels emanating from a single node, there must exist at least one selected path that contains both of these channels.
6
+
7
+ Help the sages find the minimum number of such paths so that the magical balance of the Tree of Life is preserved, and its power continues to nourish the entire world!
8
+
9
+ Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 4 \cdot 10^4$) — the number of test cases. The description of the test cases follows.
10
+
11
+ The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the nu