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"Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and there are no more possible improvements he can think of during the day (he now prefers to sleep at night). However, his assistants have found a solution and they now draw an imaginary city on a paper sheet and suggest the mayor can propose its improvements. Right now he has a map of some imaginary city with n subway stations. Some stations are directly connected with tunnels in such a way that the whole map is a tree (assistants were short on time and enthusiasm). It means that there exists exactly one simple path between each pair of station. We call a path simple if it uses each tunnel no more than once. One of Sergey Semyonovich's favorite quality objectives is the sum of all pairwise distances between every pair of stations. The distance between two stations is the minimum possible number of tunnels on a path between them. Sergey Semyonovich decided to add new tunnels to the subway map. In particular, he connected any two stations u and v that were not connected with a direct tunnel but share a common neighbor, i.e. there exists such a station w that the original map has a tunnel between u and w and a tunnel between w and v . You are given a task to compute the sum of pairwise distances between all pairs of stations in the new map. The first line of the input contains a single integer n ( 2 <= q n <= q 200 ,000 ) -- the number of subway stations in the imaginary city drawn by mayor's assistants. Each of the following n - 1 lines contains two integers u_i and v_i ( 1 <= q u_i, v_i <= q n , u_i ne v_i ), meaning the station with these indices are connected with a direct tunnel. It is guaranteed that these n stations and n - 1 tunnels form a tre"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
44020594 |
cbl_nhathuy |
E |
Oct. 9, 2018, 3:38 a.m. |
OK |
FPC |
TESTS |
38 |
140 |
11264000 |
|
2000 |
43815376 |
luogu_bot2 |
E |
Oct. 5, 2018, 4:54 a.m. |
OK |
FPC |
TESTS |
38 |
140 |
18432000 |
|
2000 |
45154981 |
zrzluck99 |
E |
Oct. 31, 2018, 11:59 p.m. |
OK |
FPC |
TESTS |
38 |
171 |
45670400 |
|
2000 |
44751181 |
ReaLNero1 |
E |
Oct. 23, 2018, 8:01 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
6246400 |
|
2000 |
63520574 |
luogu_bot2 |
E |
Oct. 27, 2019, 3:35 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
6656000 |
|
2000 |
51117574 |
Karnage |
E |
March 10, 2019, 7:39 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
9420800 |
|
2000 |
46427817 |
luogu_bot5 |
E |
Dec. 1, 2018, 2:36 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
9625600 |
|
2000 |
46427811 |
Althen |
E |
Dec. 1, 2018, 2:36 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
9625600 |
|
2000 |
48582227 |
gmr |
E |
Jan. 19, 2019, 5:13 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
9932800 |
|
2000 |
46428663 |
ZredXNy |
E |
Dec. 1, 2018, 3:25 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
10035200 |
|
2000 |
50929439 |
chc_1234567890 |
E |
March 7, 2019, 1:17 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
11059200 |
|
2000 |
44724886 |
Captain_Paul |
E |
Oct. 23, 2018, 7:34 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
11468800 |
|
2000 |
58649146 |
Orange_JuiCE |
E |
Aug. 12, 2019, 6:53 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
46 |
11673600 |
|
2000 |
44169576 |
Enzyme125 |
E |
Oct. 12, 2018, 4:40 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
61 |
11673600 |
|
2000 |
45985846 |
wleung_bvg |
E |
Nov. 20, 2018, 6:29 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
93 |
13619200 |
|
2000 |
44424812 |
FlyInTheSky |
E |
Oct. 17, 2018, 3:18 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
109 |
10854400 |
|
2000 |
44409788 |
nnbszxx |
E |
Oct. 16, 2018, 4:17 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
109 |
10854400 |
|
2000 |
47608529 |
mayiyang |
E |
Dec. 28, 2018, 6:47 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
109 |
12902400 |
|
2000 |
50619542 |
dhruval161 |
E |
Feb. 28, 2019, 10:54 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
109 |
16588800 |
|
2000 |
64055804 |
vjudge3 |
E |
Nov. 2, 2019, 1:19 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
124 |
9932800 |
|
2000 |
51203861 |
mayaohua2003 |
E |
March 12, 2019, 2:58 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
124 |
10137600 |
|
2000 |
54655650 |
bojverdict2 |
E |
May 26, 2019, 8:11 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
124 |
11673600 |
|
2000 |
44259370 |
mingzzc |
E |
Oct. 13, 2018, 1:47 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
124 |
11673600 |
|
2000 |
44065708 |
F.J |
E |
Oct. 10, 2018, 9:08 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
61 |
21196800 |
|
2000 |
43790427 |
Trisolaris |
E |
Oct. 4, 2018, 1:39 p.m. |
OK |
GNU C++17 |
TESTS |
38 |
77 |
12902400 |
|
2000 |
43775790 |
JewRaper |
E |
Oct. 4, 2018, 8:48 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
108 |
212582400 |
|
2000 |
69818809 |
Pharaoh1 |
E |
Jan. 30, 2020, 7:02 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
124 |
6656000 |
|
2000 |
44543090 |
shuafen |
E |
Oct. 19, 2018, 12:23 p.m. |
OK |
GNU C++17 |
TESTS |
38 |
124 |
12083200 |
|
2000 |
60833198 |
vjudge3 |
E |
Sept. 19, 2019, 7:52 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
124 |
12492800 |
|
2000 |
60833144 |
Magicdog_Jo |
E |
Sept. 19, 2019, 7:51 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
124 |
12492800 |
|
2000 |
46302696 |
tyzc |
E |
Nov. 28, 2018, 8:09 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
124 |
14540800 |
|
2000 |
43789291 |
Trisolaris |
E |
Oct. 4, 2018, 1:16 p.m. |
OK |
GNU C++17 |
TESTS |
38 |
124 |
27852800 |
|
2000 |
43782239 |
eom |
E |
Oct. 4, 2018, 11 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
124 |
28160000 |
|
2000 |
43804701 |
aman28rwt |
E |
Oct. 4, 2018, 7:05 p.m. |
OK |
Java 8 |
TESTS |
38 |
218 |
16179200 |
|
2000 |
46397002 |
donli |
E |
Nov. 30, 2018, 10:01 a.m. |
OK |
Java 8 |
TESTS |
38 |
233 |
4812800 |
|
2000 |
43798457 |
StayAwayFromBitches |
E |
Oct. 4, 2018, 4:27 p.m. |
OK |
Java 8 |
TESTS |
38 |
358 |
35635200 |
|
2000 |
45510552 |
Srinivasa_Ramanujan |
E |
Nov. 10, 2018, 12:48 p.m. |
OK |
Java 8 |
TESTS |
38 |
358 |
53350400 |
|
2000 |
43951708 |
fetetriste |
E |
Oct. 7, 2018, 4:50 p.m. |
OK |
Java 8 |
TESTS |
38 |
389 |
37171200 |
|
2000 |
45510581 |
Srinivasa_Ramanujan |
E |
Nov. 10, 2018, 12:49 p.m. |
OK |
Java 8 |
TESTS |
38 |
404 |
51302400 |
|
2000 |
48479966 |
amolpratap007 |
E |
Jan. 17, 2019, 5:35 a.m. |
OK |
Java 8 |
TESTS |
38 |
436 |
69939200 |
|
2000 |
44537735 |
BaZ_ |
E |
Oct. 19, 2018, 9:49 a.m. |
OK |
Java 8 |
TESTS |
38 |
452 |
60006400 |
|
2000 |
63627132 |
FluffyPotato |
E |
Oct. 28, 2019, 4:31 a.m. |
OK |
Java 8 |
TESTS |
38 |
483 |
46899200 |
|
2000 |
43803710 |
Ahmad |
E |
Oct. 4, 2018, 6:36 p.m. |
OK |
Java 8 |
TESTS |
38 |
498 |
40243200 |
|
2000 |
43864792 |
omikad |
E |
Oct. 5, 2018, 5:44 p.m. |
OK |
Mono C# |
TESTS |
38 |
624 |
43724800 |
|
2000 |
43787786 |
omikad |
E |
Oct. 4, 2018, 12:47 p.m. |
OK |
Mono C# |
TESTS |
38 |
670 |
37376000 |
|
2000 |
57200420 |
vjudge1 |
E |
July 17, 2019, 1:33 p.m. |
OK |
MS C++ |
TESTS |
38 |
78 |
9113600 |
|
2000 |
44113429 |
vjudge2 |
E |
Oct. 11, 2018, 12:58 p.m. |
OK |
MS C++ |
TESTS |
38 |
93 |
11264000 |
|
2000 |
64057504 |
vjudge2 |
E |
Nov. 2, 2019, 2:11 a.m. |
OK |
MS C++ |
TESTS |
38 |
108 |
8601600 |
|
2000 |
64055578 |
vjudge1 |
E |
Nov. 2, 2019, 1:11 a.m. |
OK |
MS C++ |
TESTS |
38 |
108 |
9113600 |
|
2000 |
64516195 |
vjudge2 |
E |
Nov. 8, 2019, 10:48 a.m. |
OK |
MS C++ |
TESTS |
38 |
124 |
11059200 |
|
2000 |
57193745 |
vjudge5 |
E |
July 17, 2019, 11:31 a.m. |
OK |
MS C++ |
TESTS |
38 |
124 |
16896000 |
|
2000 |
64349731 |
vjudge3 |
E |
Nov. 6, 2019, 7:50 a.m. |
OK |
MS C++ |
TESTS |
38 |
124 |
18944000 |
|
2000 |
57190734 |
vjudge1 |
E |
July 17, 2019, 10:29 a.m. |
OK |
MS C++ |
TESTS |
38 |
124 |
60620800 |
|
2000 |
57201099 |
vjudge5 |
E |
July 17, 2019, 1:45 p.m. |
OK |
MS C++ |
TESTS |
38 |
139 |
14438400 |
|
2000 |
64057641 |
vjudge5 |
E |
Nov. 2, 2019, 2:15 a.m. |
OK |
MS C++ |
TESTS |
38 |
156 |
20582400 |
|
2000 |
66072166 |
Svlad_Cjelli |
E |
Nov. 30, 2019, 8:08 p.m. |
OK |
Ocaml |
TESTS |
38 |
296 |
24166400 |
|
2000 |
45559620 |
Jonasz |
E |
Nov. 11, 2018, 10:49 a.m. |
OK |
Python 2 |
TESTS |
38 |
1965 |
68198400 |
|
2000 |
56494146 |
maxtelll |
E |
July 4, 2019, 1:34 a.m. |
OK |
Python 3 |
TESTS |
38 |
1388 |
212684800 |
|
2000 |
54257868 |
vjudge2 |
E |
May 16, 2019, 9:32 p.m. |
OK |
Python 3 |
TESTS |
38 |
1465 |
212684800 |
|
2000 |
47892349 |
whatshisbucket |
E |
Jan. 4, 2019, 7:41 a.m. |
OK |
Python 3 |
TESTS |
38 |
1466 |
212275200 |
|
2000 |
56494340 |
vjudge1 |
E |
July 4, 2019, 1:44 a.m. |
OK |
Python 3 |
TESTS |
38 |
1544 |
218214400 |
|
2000 |
56494307 |
maxtelll |
E |
July 4, 2019, 1:43 a.m. |
OK |
Python 3 |
TESTS |
38 |
1544 |
218214400 |
|
2000 |
44603645 |
yakamoto |
E |
Oct. 20, 2018, 3:41 p.m. |
OK |
Scala |
TESTS |
38 |
857 |
32358400 |
|
2000 |
remove filters
Back to search problems