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 tree with n nodes. For each node, you either color it in 0 or 1 . The value of a path (u,v) is equal to the MEX ^ dagger of the colors of the nodes from the shortest path between u and v . The value of a coloring is equal to the sum of values of all paths (u,v) such that 1 <= q u <= q v <= q n . What is the maximum possible value of any coloring of the tree? ^{ dagger} The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance: Each test contains multiple test cases. The first line of input contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 2 cdot 10^5 ) -- the number of nodes in the tree. The following n-1 lines of each test case contains 2 integers a_i and b_i ( 1 <= q a_i, b_i <= q n, a_i neq b_i ) -- indicating an edge between vertices a_i and b_i . It is guaranteed that the given edges form a tree. It is guaranteed that the sum of n across all test cases does not exceed 2 cdot 10^5 . For each test case, print the maximum possible value of any coloring of the tree. In the first sample, we will color vertex 2 in 1 and vertices 1,3 in 0 . After this, we consider all paths: We notice the sum of values is 8 which is the maximum possible. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
207710447 |
Potassium |
D |
May 29, 2023, 4:13 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
795 |
32972800 |
|
|
207707907 |
ztcakioi |
D |
May 29, 2023, 3:30 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
904 |
22118400 |
|
|
207694890 |
zhiyangfan |
D |
May 29, 2023, 1:23 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
920 |
30412800 |
|
|
207710416 |
Potassium |
D |
May 29, 2023, 4:13 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
998 |
32972800 |
|
|
207710385 |
Potassium |
D |
May 29, 2023, 4:12 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
1091 |
33075200 |
|
|
207709940 |
MakaPakka |
D |
May 29, 2023, 4:05 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
1138 |
22118400 |
|
|
207708494 |
Flamire |
D |
May 29, 2023, 3:41 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
1138 |
26316800 |
|
|
207695106 |
ZSH_ZSH |
D |
May 29, 2023, 1:28 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
1341 |
32870400 |
|
|
207683429 |
Wangxueyi |
D |
May 28, 2023, 8:02 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
1404 |
28876800 |
|
|
207664238 |
grass8sheep |
D |
May 28, 2023, 4:56 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
1496 |
31232000 |
|
|
207630410 |
1a2b3c4 |
D |
May 28, 2023, 3:38 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
530 |
18329600 |
|
|
207670221 |
yuto1115 |
D |
May 28, 2023, 5:44 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
623 |
30515200 |
|
|
207712782 |
sd0061 |
D |
May 29, 2023, 4:52 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
780 |
25702400 |
|
|
207713803 |
sd0061 |
D |
May 29, 2023, 5:06 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
811 |
25702400 |
|
|
207712733 |
sd0061 |
D |
May 29, 2023, 4:51 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
811 |
25702400 |
|
|
207714006 |
sd0061 |
D |
May 29, 2023, 5:09 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
826 |
25702400 |
|
|
207713871 |
sd0061 |
D |
May 29, 2023, 5:07 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
888 |
212480000 |
|
|
207682842 |
magga |
D |
May 28, 2023, 7:52 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
920 |
25804800 |
|
|
207716697 |
Zy2 |
D |
May 29, 2023, 5:48 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
982 |
31232000 |
|
|
207699126 |
Zy2 |
D |
May 29, 2023, 2:50 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
997 |
31232000 |
|
|
207694974 |
orzdevinwang |
D |
May 29, 2023, 1:25 a.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
233 |
36864000 |
|
|
207699912 |
lqx2005 |
D |
May 29, 2023, 3:04 a.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
467 |
33484800 |
|
|
207658745 |
kotatsugame |
D |
May 28, 2023, 4:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
467 |
47820800 |
|
|
207645186 |
natsugiri |
D |
May 28, 2023, 4:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
468 |
38912000 |
|
|
207666381 |
Andreasyan |
D |
May 28, 2023, 5:02 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
529 |
48844800 |
|
|
207659407 |
forever_lose |
D |
May 28, 2023, 4:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
577 |
47923200 |
|
|
207652202 |
chinerist |
D |
May 28, 2023, 4:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
592 |
44032000 |
|
|
207661111 |
sunzh |
D |
May 28, 2023, 4:48 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
608 |
49049600 |
|
|
207674246 |
hitonanode |
D |
May 28, 2023, 6:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
686 |
54169600 |
|
|
207688647 |
GRT_2018 |
D |
May 28, 2023, 9:53 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
701 |
39936000 |
|
|
207680097 |
turmax |
D |
May 28, 2023, 7:14 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
202 |
39321600 |
|
|
207675630 |
Sputnik1234 |
D |
May 28, 2023, 6:23 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
218 |
41062400 |
|
|
207671666 |
A_G |
D |
May 28, 2023, 5:52 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
233 |
41062400 |
|
|
207683848 |
iliya7 |
D |
May 28, 2023, 8:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
234 |
41062400 |
|
|
207678956 |
jeroenodb |
D |
May 28, 2023, 7 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
280 |
40243200 |
|
|
207708717 |
bachbeo2007 |
D |
May 29, 2023, 3:44 a.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
280 |
61849600 |
|
|
207679101 |
jeroenodb |
D |
May 28, 2023, 7:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
280 |
66560000 |
|
|
207678933 |
jeroenodb |
D |
May 28, 2023, 6:59 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
296 |
40243200 |
|
|
207679044 |
jeroenodb |
D |
May 28, 2023, 7:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
311 |
40243200 |
|
|
207636175 |
jiangly |
D |
May 28, 2023, 3:49 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
311 |
58572800 |
|
|
207692789 |
arvindf232 |
D |
May 29, 2023, 12:23 a.m. |
OK |
Kotlin 1.6 |
TESTS |
42 |
2479 |
36044800 |
|
|
207642141 |
Egor |
D |
May 28, 2023, 4:01 p.m. |
OK |
Rust 2021 |
TESTS |
42 |
2589 |
136601600 |
|
|
remove filters
Back to search problems