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
Given a tree with (n) vertices, you need to assign a color to each edge. Define the inconvenience of an assignment as the maximum number of colors on the path between any two vertices. You need to assign exactly (k) different colors (each color must appear at least once) to the edges while minimizing the inconvenience of the assignment. Please calculate the minimum inconvenience for all (k=1,2,\ldots,n-1). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of the input contains one positive integer (n) ((3\le n\le3\cdot10^5)) — the number of vertices. The next (n-1) lines each contain two positive integers (u_i,v_i) ((1\le u_i,v_i\le n)) — indicating that there is an edge between vertices (u_i) and (v_i). It is guaranteed that the edges in the input form a tree. It is guaranteed that the sum of (n) over all test cases does not exceed (3\cdot10^5). For each test case, print a single line containing (n-1) integers. The (i)-th integer represents the minimum inconvenience for (k=i). In the first test case, possible solutions for (k=1,2,\ldots,n-1) are as follows: |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
349323031 |
TadijaSebez |
E |
Nov. 16, 2025, 4:31 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
49 |
687 |
16998400 |
|
|
|
349306447 |
JDScript0117 |
E |
Nov. 16, 2025, 3:40 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
49 |
811 |
36761600 |
|
|
|
349354773 |
ArturSmolenski |
E |
Nov. 16, 2025, 11:16 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
49 |
1108 |
34406400 |
|
|
|
349363891 |
VaHiX |
E |
Nov. 17, 2025, 2:35 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
49 |
1187 |
34406400 |
|
|
|
349349288 |
maxplus |
E |
Nov. 16, 2025, 9:15 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
108 |
5120000 |
|
|
|
349327116 |
maxplus |
E |
Nov. 16, 2025, 5:11 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
187 |
5120000 |
|
|
|
349326569 |
maxplus |
E |
Nov. 16, 2025, 5:08 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
187 |
5120000 |
|
|
|
349334778 |
icecuber |
E |
Nov. 16, 2025, 6:13 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
452 |
17715200 |
|
|
|
349320123 |
www_bilibili_com |
E |
Nov. 16, 2025, 4:22 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
499 |
28160000 |
|
|
|
349316397 |
maxplus |
E |
Nov. 16, 2025, 4:10 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
624 |
30720000 |
|
|
|
349330378 |
Ormlis |
E |
Nov. 16, 2025, 5:35 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
639 |
32870400 |
|
|
|
349317701 |
dsgrekova2 |
E |
Nov. 16, 2025, 4:14 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
656 |
59084800 |
|
|
|
349372129 |
ORzyzRO |
E |
Nov. 17, 2025, 4:26 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
702 |
43417600 |
|
|
|
349317809 |
strapple |
E |
Nov. 16, 2025, 4:15 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
733 |
120524800 |
|
|
|
349326642 |
ecnerwala |
E |
Nov. 16, 2025, 5:09 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
437 |
17100800 |
|
|
|
349366059 |
Sirantic |
E |
Nov. 17, 2025, 3:14 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
437 |
27955200 |
|
|
|
349323238 |
ttamx |
E |
Nov. 16, 2025, 4:32 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
453 |
28160000 |
|
|
|
349303795 |
Nachia |
E |
Nov. 16, 2025, 3:33 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
468 |
40857600 |
|
|
|
349332181 |
tfg |
E |
Nov. 16, 2025, 5:51 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
483 |
16691200 |
|
|
|
349300010 |
maroonrk |
E |
Nov. 16, 2025, 3:24 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
499 |
47411200 |
|
|
|
349334132 |
Mitsukasa_Ayase |
E |
Nov. 16, 2025, 6:07 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
624 |
34508800 |
|
|
|
349337909 |
BenjaminJ |
E |
Nov. 16, 2025, 6:42 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
718 |
32972800 |
|
|
|
349307780 |
ecnerwala |
E |
Nov. 16, 2025, 3:43 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
796 |
30105600 |
|
|
|
349334520 |
gloria_mundi |
E |
Nov. 16, 2025, 6:11 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
828 |
32870400 |
|
|
|
349331603 |
rainboy |
E |
Nov. 16, 2025, 5:46 p.m. |
OK |
GNU C11 |
TESTS |
49 |
1406 |
6144000 |
|
|
|
349321552 |
Tlatoani |
E |
Nov. 16, 2025, 4:27 p.m. |
OK |
Kotlin 2.2 |
TESTS |
49 |
1859 |
75264000 |
|
|
remove filters
Back to search problems