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'Tenzing has an undirected tree of n vertices. Define the value of a tree with black and white vertices in the following way. The value of an edge is the absolute difference between the number of black nodes in the two components of the tree after deleting the edge. The value of the tree is the sum of values over all edges. For all k such that 0 <= q k <= q n , Tenzing wants to know the maximum value of the tree when k vertices are painted black and n-k vertices are painted white. The first line of the input contains a single integer n ( 1 <= q n <= q 5000 ) -- the number of vertices. The following n-1 lines of the input contains 2 integers u_i and v_i ( 1 <= q u_i, v_i <= q n, u_i neq v_i ) -- indicating an edge between vertices u_i and v_i . It is guaranteed that the given edges form a tree. Output n+1 numbers. The i -th number is the answer of k=i-1 . Consider the first example. When k=2 , Tenzing can paint vertices 1 and 2 black then the value of edge (1,2) is 0, and the values of other edges are all equal to 2 . So the value of that tree is 4 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
210966338 |
rainboy |
F |
June 24, 2023, 8:08 p.m. |
OK |
GNU C11 |
TESTS |
59 |
468 |
409600 |
|
|
210939691 |
awoo |
F |
June 24, 2023, 4:23 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
514 |
409600 |
|
|
210991038 |
72oced |
F |
June 25, 2023, 5:23 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
529 |
409600 |
|
|
210936132 |
cyh_toby |
F |
June 24, 2023, 4:11 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
546 |
512000 |
|
|
210939112 |
Noam527 |
F |
June 24, 2023, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
592 |
409600 |
|
|
210986394 |
jrscy |
F |
June 25, 2023, 3:48 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
717 |
101068800 |
|
|
210949534 |
Suwan |
F |
June 24, 2023, 5:01 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
733 |
201420800 |
|
|
210947633 |
0wuming0 |
F |
June 24, 2023, 4:54 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
748 |
402227200 |
|
|
210958220 |
Ecrade_ |
F |
June 24, 2023, 6:31 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
842 |
614400 |
|
|
210953812 |
wrhaco |
F |
June 24, 2023, 5:59 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
842 |
1126400 |
|
|
210986108 |
Ja711 |
F |
June 25, 2023, 3:40 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
858 |
1024000 |
|
|
210972436 |
juliany2 |
F |
June 24, 2023, 9:44 p.m. |
OK |
GNU C++17 |
TESTS |
59 |
468 |
409600 |
|
|
210970542 |
archiver |
F |
June 24, 2023, 9:11 p.m. |
OK |
GNU C++17 |
TESTS |
59 |
483 |
409600 |
|
|
210957238 |
chen_zexing |
F |
June 24, 2023, 6:23 p.m. |
OK |
GNU C++17 |
TESTS |
59 |
499 |
409600 |
|
|
210942483 |
radoslav11 |
F |
June 24, 2023, 4:33 p.m. |
OK |
GNU C++17 |
TESTS |
59 |
514 |
409600 |
|
|
210974896 |
marsxiang5902 |
F |
June 24, 2023, 10:38 p.m. |
OK |
GNU C++17 |
TESTS |
59 |
514 |
614400 |
|
|
210982403 |
NKheyuxiang |
F |
June 25, 2023, 2:09 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
546 |
614400 |
|
|
210979366 |
amirhoseinfar1385 |
F |
June 25, 2023, 12:45 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
561 |
1024000 |
|
|
210984266 |
SDqwq |
F |
June 25, 2023, 2:56 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
592 |
614400 |
|
|
210982067 |
__stick |
F |
June 25, 2023, 2 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
608 |
512000 |
|
|
210946914 |
cxaphoenix |
F |
June 24, 2023, 4:52 p.m. |
OK |
GNU C++17 |
TESTS |
59 |
608 |
614400 |
|
|
210981115 |
neal |
F |
June 25, 2023, 1:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
312 |
2048000 |
|
|
210955828 |
sevlll777 |
F |
June 24, 2023, 6:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
483 |
409600 |
|
|
210955967 |
sevlll777 |
F |
June 24, 2023, 6:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
499 |
409600 |
|
|
210941644 |
SanweiTreap |
F |
June 24, 2023, 4:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
499 |
409600 |
|
|
210975888 |
66H6 |
F |
June 24, 2023, 11:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
499 |
409600 |
|
|
210939397 |
icecuber |
F |
June 24, 2023, 4:22 p.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
530 |
409600 |
|
|
210948996 |
jinqihao2026 |
F |
June 24, 2023, 4:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
530 |
6041600 |
|
|
210955753 |
sevlll777 |
F |
June 24, 2023, 6:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
545 |
512000 |
|
|
210986529 |
hgzxwzf |
F |
June 25, 2023, 3:51 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
546 |
409600 |
|
|
210939668 |
chinerist |
F |
June 24, 2023, 4:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
561 |
409600 |
|
|
210984340 |
rqoi032 |
F |
June 25, 2023, 2:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
390 |
102400 |
|
|
210970348 |
A_G |
F |
June 24, 2023, 9:07 p.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
420 |
409600 |
|
|
210982427 |
rqoi032 |
F |
June 25, 2023, 2:09 a.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
421 |
102400 |
|
|
210944313 |
ToTLeS |
F |
June 24, 2023, 4:41 p.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
436 |
100966400 |
|
|
210953964 |
KrK |
F |
June 24, 2023, 5:59 p.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
468 |
307200 |
|
|
210971510 |
A_G |
F |
June 24, 2023, 9:27 p.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
468 |
409600 |
|
|
210962003 |
Ronnie007 |
F |
June 24, 2023, 7:12 p.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
483 |
409600 |
|
|
210980652 |
lsantire |
F |
June 25, 2023, 1:20 a.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
498 |
409600 |
|
|
210953784 |
flashmt |
F |
June 24, 2023, 5:59 p.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
499 |
921600 |
|
|
210986886 |
mod998244353 |
F |
June 25, 2023, 3:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
59 |
514 |
307200 |
|
|
remove filters
Back to search problems