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'Given a rooted tree with n nodes. The Night King removes exactly one node from the tree and all the edges associated with it. Doing this splits the tree and forms a forest. The node which is removed is not a part of the forest. The root of a tree in the forest is the node in that tree which does not have a parent. We define the strength of the forest as the size of largest tree in forest. Jon Snow wants to minimize the strength of the forest. To do this he can perform the following operation at most once. He removes the edge between a node and its parent and inserts a new edge between this node and any other node in forest such that the total number of trees in forest remain same. For each node v you need to find the minimum value of strength of the forest formed when node v is removed. The first line of the input contains an integer n (1 xe2 x80 x89 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89 xe2 x80 x89n xe2 x80 x89 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89 xe2 x80 x89105) -- the number of vertices in the tree. Each of the next n lines contains a pair of vertex indices ui and vi (1 xe2 x80 x89 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89 xe2 x80 x89ui, xe2 x80 x89 xe2 x80 x89vi xe2 x80 x89 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89 xe2 x80 x89n) where ui is the parent of vi. If ui xe2 x80 x89= xe2 x80 x890 then vi is the root. Print n line each containing a single integer. The i-th of them should be equal to minimum value of strength of forest formed when i-th node is removed and Jon Snow performs the operation described above at most once. The tree for first test case is depicted below. When you remove the first node, the tree splits to form the following forest. The strength of this forest is 4. Jon Snow now changes the parent of vertex 10 from 5 to 3. The strength of forest now becomes 3. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
37600474 |
lsonan |
G |
April 25, 2018, 2:39 p.m. |
OK |
GNU C++ |
TESTS |
69 |
93 |
51609600 |
|
3000 |
38142067 |
Scut82 |
G |
May 12, 2018, 3:09 p.m. |
OK |
GNU C++ |
TESTS |
69 |
124 |
15462400 |
|
3000 |
40982410 |
ReaLNero1 |
G |
July 30, 2018, 6:25 p.m. |
OK |
GNU C++ |
TESTS |
69 |
139 |
11673600 |
|
3000 |
25571214 |
ShinFeb |
G |
March 17, 2017, 11:59 a.m. |
OK |
GNU C++ |
TESTS |
69 |
171 |
21401600 |
|
3000 |
41559711 |
zhangqingqi |
G |
Aug. 13, 2018, 1:31 p.m. |
OK |
GNU C++ |
TESTS |
69 |
187 |
88678400 |
|
3000 |
24862891 |
Dylans |
G |
Feb. 21, 2017, 6:20 a.m. |
OK |
GNU C++ |
TESTS |
69 |
249 |
13107200 |
|
3000 |
24862834 |
Dylans |
G |
Feb. 21, 2017, 6:18 a.m. |
OK |
GNU C++ |
TESTS |
69 |
264 |
13107200 |
|
3000 |
25117578 |
xzyxzy |
G |
March 1, 2017, 7:55 a.m. |
OK |
GNU C++ |
TESTS |
69 |
280 |
13721600 |
|
3000 |
25112448 |
JoelSotoMamani |
G |
Feb. 28, 2017, 11:46 p.m. |
OK |
GNU C++ |
TESTS |
69 |
358 |
13824000 |
|
3000 |
24954319 |
Hillan |
G |
Feb. 24, 2017, 4:30 a.m. |
OK |
GNU C++ |
TESTS |
69 |
358 |
13824000 |
|
3000 |
48324705 |
Hany01 |
G |
Jan. 13, 2019, 11:14 a.m. |
OK |
GNU C++11 |
TESTS |
69 |
156 |
55296000 |
|
3000 |
48403134 |
ylsoi |
G |
Jan. 15, 2019, 12:18 a.m. |
OK |
GNU C++11 |
TESTS |
69 |
170 |
84172800 |
|
3000 |
48456255 |
ylsoi |
G |
Jan. 16, 2019, 12:46 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
171 |
84172800 |
|
3000 |
43021328 |
jangjie |
G |
Sept. 18, 2018, 5:14 a.m. |
OK |
GNU C++11 |
TESTS |
69 |
186 |
27852800 |
|
3000 |
48324735 |
Hany01 |
G |
Jan. 13, 2019, 11:15 a.m. |
OK |
GNU C++11 |
TESTS |
69 |
186 |
55296000 |
|
3000 |
43031254 |
jangjie |
G |
Sept. 18, 2018, 11:46 a.m. |
OK |
GNU C++11 |
TESTS |
69 |
187 |
27852800 |
|
3000 |
33098421 |
wnmMrrd |
G |
Dec. 11, 2017, 9:43 a.m. |
OK |
GNU C++11 |
TESTS |
69 |
187 |
50585600 |
|
3000 |
27396258 |
braveTester |
G |
May 27, 2017, 7:39 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
249 |
79462400 |
|
3000 |
24855744 |
aid |
G |
Feb. 20, 2017, 9:29 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
265 |
18124800 |
|
3000 |
24853725 |
LHiC |
G |
Feb. 20, 2017, 8:24 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
280 |
35942400 |
|
3000 |
64451234 |
yhx-12243 |
G |
Nov. 7, 2019, 7:09 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
140 |
111616000 |
|
3000 |
58667258 |
beginend |
G |
Aug. 12, 2019, 1:02 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
171 |
127078400 |
|
3000 |
25235852 |
PrashantM |
G |
March 5, 2017, 7:47 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
218 |
14028800 |
|
3000 |
48318901 |
zhou888 |
G |
Jan. 13, 2019, 8:09 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
218 |
130252800 |
|
3000 |
53378948 |
bhargav_0085 |
G |
April 26, 2019, 9:02 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
233 |
11059200 |
|
3000 |
24851145 |
Reyna |
G |
Feb. 20, 2017, 6:38 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
234 |
14233600 |
|
3000 |
25339793 |
BigBag |
G |
March 8, 2017, 11:25 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
249 |
12902400 |
|
3000 |
24865288 |
la1la1la |
G |
Feb. 21, 2017, 8:15 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
249 |
56934400 |
|
3000 |
24866849 |
la1la1la |
G |
Feb. 21, 2017, 9:23 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
296 |
56934400 |
|
3000 |
48318303 |
hyj542682306 |
G |
Jan. 13, 2019, 7:51 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
312 |
165478400 |
|
3000 |
64743391 |
little_gift |
G |
Nov. 12, 2019, 12:44 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
202 |
20172800 |
|
3000 |
63498111 |
NiroBC |
G |
Oct. 26, 2019, 4:13 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
202 |
55910400 |
|
3000 |
64365481 |
little_gift |
G |
Nov. 6, 2019, 12:55 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
233 |
20172800 |
|
3000 |
39733735 |
Als123 |
G |
June 28, 2018, 5:56 a.m. |
OK |
GNU C++17 |
TESTS |
69 |
483 |
13004800 |
|
3000 |
64306397 |
little_gift |
G |
Nov. 5, 2019, 11:33 a.m. |
OK |
GNU C++17 |
TESTS |
69 |
514 |
12390400 |
|
3000 |
64364819 |
little_gift |
G |
Nov. 6, 2019, 12:44 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
530 |
13004800 |
|
3000 |
66052400 |
Martin53 |
G |
Nov. 30, 2019, 5:53 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
530 |
13414400 |
|
3000 |
64307632 |
little_gift |
G |
Nov. 5, 2019, 11:51 a.m. |
OK |
GNU C++17 |
TESTS |
69 |
577 |
12390400 |
|
3000 |
50208152 |
Rzepa |
G |
Feb. 19, 2019, 8:36 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
733 |
49868800 |
|
3000 |
57113581 |
Benq |
G |
July 15, 2019, 6:41 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
748 |
20377600 |
|
3000 |
24882675 |
eatmore |
G |
Feb. 22, 2017, 12:45 a.m. |
OK |
Java 8 |
TESTS |
69 |
670 |
199372800 |
|
3000 |
25063128 |
IgorKoval |
G |
Feb. 26, 2017, 7:17 p.m. |
OK |
Java 8 |
TESTS |
69 |
686 |
70758400 |
|
3000 |
25061792 |
IgorKoval |
G |
Feb. 26, 2017, 6:07 p.m. |
OK |
Java 8 |
TESTS |
69 |
701 |
70860800 |
|
3000 |
25063090 |
IgorKoval |
G |
Feb. 26, 2017, 7:15 p.m. |
OK |
Java 8 |
TESTS |
69 |
779 |
71372800 |
|
3000 |
24859939 |
Los_Angelos_Laycurse |
G |
Feb. 21, 2017, 3:09 a.m. |
OK |
MS C++ |
TESTS |
69 |
514 |
31948800 |
|
3000 |
61962697 |
vjudge1 |
G |
Oct. 6, 2019, 7:56 a.m. |
OK |
MS C++ |
TESTS |
69 |
624 |
10444800 |
|
3000 |
24859930 |
Los_Angelos_Laycurse |
G |
Feb. 21, 2017, 3:08 a.m. |
OK |
MS C++ |
TESTS |
69 |
624 |
31948800 |
|
3000 |
remove filters
Back to search problems