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 an unweighted tree with n vertices. Then n xe2 x80 x89- xe2 x80 x891 following operations are applied to the tree. A single operation consists of the following steps: Initial answer (before applying operations) is 0. Obviously after n xe2 x80 x89- xe2 x80 x891 such operations the tree will consist of a single vertex. Calculate the maximal possible answer you can achieve, and construct a sequence of operations that allows you to achieve this answer! The first line contains one integer number n (2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892 xc2 xb7105) -- the number of vertices in the tree. Next n xe2 x80 x89- xe2 x80 x891 lines describe the edges of the tree in form ai, xe2 x80 x89bi (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai, bi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, ai xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89bi). It is guaranteed that given graph is a tree. In the first line print one integer number -- maximal possible answer. In the next n xe2 x80 x89- xe2 x80 x891 lines print the operations in order of their applying in format ai, xe2 x80 x89bi, xe2 x80 x89ci, where ai, xe2 x80 x89bi -- pair of the leaves that are chosen in the current operation (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai, bi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n), ci (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ci xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, ci xe2 x80 x89= xe2 x80 x89ai or ci xe2 x80 x89= xe2 x80 x89bi) -- choosen leaf that is removed from the tree in the current operation. See the examples for better understanding. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
33739277 |
fluffyowl |
F |
Dec. 28, 2017, 4:07 p.m. |
OK |
D |
TESTS |
93 |
623 |
52838400 |
|
2500 |
40978690 |
ReaLNero1 |
F |
July 30, 2018, 4:45 p.m. |
OK |
GNU C++ |
TESTS |
93 |
109 |
36249600 |
|
2500 |
33735991 |
QQ_kotori |
F |
Dec. 28, 2017, 3:45 p.m. |
OK |
GNU C++ |
TESTS |
93 |
109 |
38297600 |
|
2500 |
37228682 |
luogu_bot1 |
F |
April 11, 2018, 3:42 p.m. |
OK |
GNU C++ |
TESTS |
93 |
109 |
39731200 |
|
2500 |
34544812 |
Scut82 |
F |
Jan. 25, 2018, 11:55 a.m. |
OK |
GNU C++ |
TESTS |
93 |
155 |
22937600 |
|
2500 |
34533906 |
Scut82 |
F |
Jan. 25, 2018, 2:43 a.m. |
OK |
GNU C++ |
TESTS |
93 |
155 |
25804800 |
|
2500 |
33883402 |
iamqzh |
F |
Jan. 3, 2018, 11:18 a.m. |
OK |
GNU C++ |
TESTS |
93 |
156 |
36659200 |
|
2500 |
35143680 |
GCC314 |
F |
Feb. 11, 2018, 6:09 a.m. |
OK |
GNU C++ |
TESTS |
93 |
171 |
18022400 |
|
2500 |
40733157 |
luogu_bot2 |
F |
July 25, 2018, 8:34 a.m. |
OK |
GNU C++ |
TESTS |
93 |
186 |
21606400 |
|
2500 |
33834839 |
sxy_to_the_end |
F |
Dec. 31, 2017, 3:58 p.m. |
OK |
GNU C++ |
TESTS |
93 |
187 |
16691200 |
|
2500 |
34990845 |
SovietPower |
F |
Feb. 7, 2018, 7:01 a.m. |
OK |
GNU C++ |
TESTS |
93 |
187 |
24473600 |
|
2500 |
68087935 |
rainboy |
F |
Jan. 2, 2020, 4:58 p.m. |
OK |
GNU C11 |
TESTS |
93 |
904 |
16179200 |
|
2500 |
33760925 |
hideeaschool |
F |
Dec. 29, 2017, 1:32 p.m. |
OK |
GNU C++11 |
TESTS |
93 |
124 |
38297600 |
|
2500 |
62548313 |
M_sea |
F |
Oct. 14, 2019, 7:28 a.m. |
OK |
GNU C++11 |
TESTS |
93 |
155 |
13209600 |
|
2500 |
45394424 |
tjjyzhu |
F |
Nov. 7, 2018, 2:29 a.m. |
OK |
GNU C++11 |
TESTS |
93 |
155 |
16793600 |
|
2500 |
62551695 |
zzy2005 |
F |
Oct. 14, 2019, 8:54 a.m. |
OK |
GNU C++11 |
TESTS |
93 |
155 |
19148800 |
|
2500 |
63837579 |
Eric_Aslan |
F |
Oct. 30, 2019, 2:46 p.m. |
OK |
GNU C++11 |
TESTS |
93 |
156 |
13824000 |
|
2500 |
62656058 |
WhiteCmile |
F |
Oct. 16, 2019, 1:43 a.m. |
OK |
GNU C++11 |
TESTS |
93 |
156 |
16179200 |
|
2500 |
62548086 |
M_sea |
F |
Oct. 14, 2019, 7:22 a.m. |
OK |
GNU C++11 |
TESTS |
93 |
171 |
14028800 |
|
2500 |
33902860 |
wfj_2048 |
F |
Jan. 4, 2018, 12:21 p.m. |
OK |
GNU C++11 |
TESTS |
93 |
171 |
15769600 |
|
2500 |
46295304 |
Emma194 |
F |
Nov. 28, 2018, 1:24 a.m. |
OK |
GNU C++11 |
TESTS |
93 |
171 |
18329600 |
|
2500 |
47959946 |
dqa2020 |
F |
Jan. 5, 2019, 8:47 a.m. |
OK |
GNU C++11 |
TESTS |
93 |
171 |
18432000 |
|
2500 |
33848668 |
Marco_L_T |
F |
Jan. 1, 2018, 2:07 p.m. |
OK |
GNU C++14 |
TESTS |
93 |
109 |
33894400 |
|
2500 |
45269623 |
sunshiness |
F |
Nov. 4, 2018, 7:52 a.m. |
OK |
GNU C++14 |
TESTS |
93 |
124 |
14438400 |
|
2500 |
34227575 |
_AjReme_ |
F |
Jan. 16, 2018, 4:49 p.m. |
OK |
GNU C++14 |
TESTS |
93 |
202 |
25292800 |
|
2500 |
34102157 |
LLLoscar |
F |
Jan. 12, 2018, 8:56 a.m. |
OK |
GNU C++14 |
TESTS |
93 |
202 |
30105600 |
|
2500 |
34448871 |
chenjb |
F |
Jan. 22, 2018, 1:36 p.m. |
OK |
GNU C++14 |
TESTS |
93 |
233 |
16486400 |
|
2500 |
33903459 |
shenyunhan |
F |
Jan. 4, 2018, 12:56 p.m. |
OK |
GNU C++14 |
TESTS |
93 |
233 |
26112000 |
|
2500 |
53703675 |
SayGB |
F |
May 3, 2019, 12:03 p.m. |
OK |
GNU C++14 |
TESTS |
93 |
234 |
17817600 |
|
2500 |
34099071 |
BeNoble |
F |
Jan. 12, 2018, 2:19 a.m. |
OK |
GNU C++14 |
TESTS |
93 |
234 |
21094400 |
|
2500 |
33847365 |
shaochengxi |
F |
Jan. 1, 2018, 12:56 p.m. |
OK |
GNU C++14 |
TESTS |
93 |
234 |
23449600 |
|
2500 |
33981652 |
qoo2p5 |
F |
Jan. 7, 2018, 11:24 a.m. |
OK |
GNU C++14 |
TESTS |
93 |
248 |
26521600 |
|
2500 |
44724727 |
yangjinhao |
F |
Oct. 23, 2018, 7:30 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
202 |
13824000 |
|
2500 |
63645825 |
9baka_Cirno |
F |
Oct. 28, 2019, 9:38 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
202 |
15974400 |
|
2500 |
58411321 |
NiroBC |
F |
Aug. 7, 2019, 1:50 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
233 |
13619200 |
|
2500 |
61407620 |
yuxizi |
F |
Sept. 28, 2019, 7:32 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
234 |
21811200 |
|
2500 |
63632121 |
zhy123 |
F |
Oct. 28, 2019, 6:48 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
248 |
31436800 |
|
2500 |
53373901 |
darkkcyan |
F |
April 26, 2019, 6:56 p.m. |
OK |
GNU C++17 |
TESTS |
93 |
249 |
14028800 |
|
2500 |
41990346 |
nerve_ending |
F |
Aug. 23, 2018, 8:27 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
264 |
26112000 |
|
2500 |
40228374 |
KyleYoung |
F |
July 12, 2018, 10:22 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
265 |
14643200 |
|
2500 |
51811665 |
Holidin |
F |
March 25, 2019, 6:16 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
265 |
29798400 |
|
2500 |
60058645 |
Mjgonzales |
F |
Sept. 5, 2019, 5:48 a.m. |
OK |
GNU C++17 |
TESTS |
93 |
280 |
20684800 |
|
2500 |
33959084 |
filo |
F |
Jan. 6, 2018, 8:30 a.m. |
OK |
Go |
TESTS |
93 |
1091 |
69324800 |
|
2500 |
68087933 |
Dukkha |
F |
Jan. 2, 2020, 4:58 p.m. |
OK |
Java 11 |
TESTS |
93 |
748 |
16793600 |
|
2500 |
40095860 |
aabdelzaher |
F |
July 8, 2018, 10:14 p.m. |
OK |
Java 8 |
TESTS |
93 |
467 |
25907200 |
|
2500 |
33730567 |
uwi |
F |
Dec. 28, 2017, 3:09 p.m. |
OK |
Java 8 |
TESTS |
93 |
577 |
60211200 |
|
2500 |
33752073 |
mathmaniac |
F |
Dec. 29, 2017, 6:14 a.m. |
OK |
Java 8 |
TESTS |
93 |
857 |
105779200 |
|
2500 |
33807844 |
coderbond007 |
F |
Dec. 30, 2017, 11:31 a.m. |
OK |
Java 8 |
TESTS |
93 |
857 |
123699200 |
|
2500 |
33754837 |
xodiac |
F |
Dec. 29, 2017, 8:36 a.m. |
OK |
Java 8 |
TESTS |
93 |
888 |
126464000 |
|
2500 |
33808226 |
coderbond007 |
F |
Dec. 30, 2017, 11:51 a.m. |
OK |
Java 8 |
TESTS |
93 |
919 |
123801600 |
|
2500 |
33815320 |
sturdyplum |
F |
Dec. 30, 2017, 5:03 p.m. |
OK |
Java 8 |
TESTS |
93 |
982 |
107110400 |
|
2500 |
36940340 |
dalt |
F |
April 4, 2018, 5:40 a.m. |
OK |
Java 8 |
TESTS |
93 |
997 |
138444800 |
|
2500 |
34153788 |
RP_9 |
F |
Jan. 13, 2018, 3:26 p.m. |
OK |
Java 8 |
TESTS |
93 |
997 |
185446400 |
|
2500 |
33759246 |
Noureldin |
F |
Dec. 29, 2017, 12:14 p.m. |
OK |
Java 8 |
TESTS |
93 |
998 |
83251200 |
|
2500 |
50822544 |
vjudge1 |
F |
March 5, 2019, 2:08 p.m. |
OK |
MS C++ |
TESTS |
93 |
217 |
32256000 |
|
2500 |
33731600 |
yuugumo |
F |
Dec. 28, 2017, 3:15 p.m. |
OK |
MS C++ |
TESTS |
93 |
249 |
12902400 |
|
2500 |
45394443 |
vjudge3 |
F |
Nov. 7, 2018, 2:31 a.m. |
OK |
MS C++ |
TESTS |
93 |
249 |
13004800 |
|
2500 |
33734856 |
innok96 |
F |
Dec. 28, 2017, 3:37 p.m. |
OK |
MS C++ |
TESTS |
93 |
265 |
20275200 |
|
2500 |
35193536 |
RCG |
F |
Feb. 13, 2018, 8:18 a.m. |
OK |
MS C++ |
TESTS |
93 |
327 |
21708800 |
|
2500 |
33870014 |
Ronnie007 |
F |
Jan. 2, 2018, 4:34 p.m. |
OK |
MS C++ |
TESTS |
93 |
358 |
38707200 |
|
2500 |
33903474 |
mshcherba |
F |
Jan. 4, 2018, 12:57 p.m. |
OK |
MS C++ |
TESTS |
93 |
717 |
20480000 |
|
2500 |
33826409 |
Maffka |
F |
Dec. 31, 2017, 7:10 a.m. |
OK |
MS C++ |
TESTS |
93 |
826 |
16486400 |
|
2500 |
63626254 |
EDawn |
F |
Oct. 28, 2019, 3:56 a.m. |
OK |
MS C++ 2017 |
TESTS |
93 |
295 |
23859200 |
|
2500 |
63772697 |
wh2005 |
F |
Oct. 30, 2019, 8:32 a.m. |
OK |
MS C++ 2017 |
TESTS |
93 |
343 |
34508800 |
|
2500 |
33797990 |
pajenegod |
F |
Dec. 30, 2017, 12:46 a.m. |
OK |
PyPy 3 |
TESTS |
93 |
1668 |
83763200 |
|
2500 |
33736172 |
nwi |
F |
Dec. 28, 2017, 3:46 p.m. |
OK |
Python 2 |
TESTS |
93 |
1544 |
51404800 |
|
2500 |
39257774 |
Ali_Pi |
F |
June 15, 2018, 5:19 a.m. |
OK |
Python 2 |
TESTS |
93 |
1715 |
66969600 |
|
2500 |
33899954 |
Aitbits |
F |
Jan. 4, 2018, 9:45 a.m. |
OK |
Python 3 |
TESTS |
93 |
1746 |
88883200 |
|
2500 |
34227270 |
denny_sem |
F |
Jan. 16, 2018, 4:35 p.m. |
OK |
Python 3 |
TESTS |
93 |
1793 |
88883200 |
|
2500 |
remove filters
Back to search problems