Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"You are given a rooted tree, consisting of n vertices, numbered from 1 to n . Vertex 1 is the root. Additionally, the root only has one child. You are asked to add exactly k edges to the tree (possibly, multiple edges and/or edges already existing in the tree). Recall that a bridge is such an edge that, after you remove it, the number of connected components in the graph increases. So, initially, all edges of the tree are bridges. After k edges are added, some original edges of the tree are still bridges and some are not anymore. You want to satisfy two conditions: Solve the task for all values of k from 1 to n - 1 and output the smallest number of bridges. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of testcases. The first line of each testcase contains a single integer n ( 2 <= n <= 3 cdot 10^5 ) -- the number of vertices of the tree. Each of the next n - 1 lines contain two integers v and u ( 1 <= v, u <= n ) -- the description of the edges of the tree. It's guaranteed that the given edges form a valid tree. Additional constraint on the input: the root (vertex 1 ) has exactly one child. The sum of n over all testcases doesn't exceed 3 cdot 10^5 . For each testcase, print n - 1 integers. For each k from 1 to n - 1 print the smallest number of bridges that can be left after you add k edges to the tree. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
263405405 |
SimpleCloud |
F |
May 31, 2024, 3:47 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
45 |
296 |
30105600 |
|
|
263555820 |
g1ove |
F |
May 31, 2024, 11:07 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
45 |
312 |
29900800 |
|
|
263498633 |
vjudge.4 |
F |
May 31, 2024, 12:38 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
45 |
327 |
29900800 |
|
|
263495681 |
vjudge.4 |
F |
May 31, 2024, 12:21 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
45 |
327 |
29900800 |
|
|
263500330 |
vjudge.4 |
F |
May 31, 2024, 12:50 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
45 |
374 |
29900800 |
|
|
263381664 |
sparsh301 |
F |
May 30, 2024, 7:39 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
45 |
499 |
31436800 |
|
|
263406748 |
cf521 |
F |
May 31, 2024, 4:04 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
45 |
718 |
44646400 |
|
|
263420150 |
Trickstar_is_the_best |
F |
May 31, 2024, 6:17 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
45 |
843 |
20275200 |
|
|
263679376 |
Satyanweshi45 |
F |
June 1, 2024, 8:31 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
359 |
25907200 |
|
|
263406864 |
20230158322023 |
F |
May 31, 2024, 4:05 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
390 |
46387200 |
|
|
263528302 |
k_balint |
F |
May 31, 2024, 4:46 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
406 |
31129600 |
|
|
263394038 |
jdurie |
F |
May 31, 2024, 12:02 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
421 |
46899200 |
|
|
263383599 |
ywjylx |
F |
May 30, 2024, 8:06 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
436 |
28979200 |
|
|
263399934 |
AliiSh |
F |
May 31, 2024, 2:26 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
436 |
30208000 |
|
|
263664409 |
SANYASI_RAJA |
F |
June 1, 2024, 5:35 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
452 |
49049600 |
|
|
263429405 |
InDI2k |
F |
May 31, 2024, 7:29 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
452 |
60211200 |
|
|
263398864 |
fjashufi |
F |
May 31, 2024, 2:06 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
453 |
28979200 |
|
|
263427284 |
zc2707 |
F |
May 31, 2024, 7:12 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
45 |
468 |
18227200 |
|
|
263525023 |
Engineer |
F |
May 31, 2024, 4:17 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
265 |
33689600 |
|
|
263522463 |
Leo_0503 |
F |
May 31, 2024, 3:55 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
280 |
33689600 |
|
|
263559504 |
N_z__ |
F |
June 1, 2024, 12:49 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
296 |
31948800 |
|
|
263594466 |
JueFan |
F |
June 1, 2024, 7:51 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
343 |
40345600 |
|
|
263401972 |
CocoCream |
F |
May 31, 2024, 2:59 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
343 |
52326400 |
|
|
263423095 |
iantsai0616 |
F |
May 31, 2024, 6:40 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
343 |
54067200 |
|
|
263396329 |
Lynkcat |
F |
May 31, 2024, 1:08 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
358 |
73113600 |
|
|
263604162 |
fishcathu. |
F |
June 1, 2024, 9:11 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
359 |
45056000 |
|
|
263400942 |
becaido |
F |
May 31, 2024, 2:44 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
359 |
47513600 |
|
|
263397633 |
hhoangcp |
F |
May 31, 2024, 1:38 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
45 |
359 |
54681600 |
|
|
263555506 |
dzhi |
F |
May 31, 2024, 10:57 p.m. |
OK |
Java 21 |
TESTS |
45 |
1687 |
142848000 |
|
|
263555338 |
dzhi |
F |
May 31, 2024, 10:53 p.m. |
OK |
Java 21 |
TESTS |
45 |
1906 |
143052800 |
|
|
263676787 |
titia |
F |
June 1, 2024, 7:51 p.m. |
OK |
PyPy 3-64 |
TESTS |
45 |
1171 |
108748800 |
|
|
263520899 |
strashila |
F |
May 31, 2024, 3:42 p.m. |
OK |
PyPy 3-64 |
TESTS |
45 |
1343 |
73318400 |
|
|
263415572 |
toor |
F |
May 31, 2024, 5:36 a.m. |
OK |
Rust 2021 |
TESTS |
45 |
312 |
96051200 |
|
|
263622990 |
M1ngXu |
F |
June 1, 2024, 11:40 a.m. |
OK |
Rust 2021 |
TESTS |
45 |
546 |
96768000 |
|
|
remove filters
Back to search problems