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
It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The election campaigns of both parties include numerous demonstrations on n main squares of the capital of Berland. Each of the n squares certainly can have demonstrations of only one party, otherwise it could lead to riots. On the other hand, both parties have applied to host a huge number of demonstrations, so that on all squares demonstrations must be held. Now the capital management will distribute the area between the two parties. Some pairs of squares are connected by ( n - 1) bidirectional roads such that between any pair of squares there is a unique way to get from one square to another. Some squares are on the outskirts of the capital meaning that they are connected by a road with only one other square, such squares are called dead end squares. The mayor of the capital instructed to distribute all the squares between the parties so that the dead end squares had the same number of demonstrations of the first and the second party. It is guaranteed that the number of dead end squares of the city is even. To prevent possible conflicts between the zublicanes and the mumocrates it was decided to minimize the number of roads connecting the squares with the distinct parties. You, as a developer of the department of distributing squares, should determine this smallest number. The first line of the input contains a single integer n ( 2 ≤ n ≤ 5000 ) — the number of squares in the capital of Berland. Next n - 1 lines contain the pairs of integers x , y ( 1 ≤ x , y ≤ n , x ≠ y ) — the numbers of the squares connected by the road. All squares are numbered with integers from 1 to n . It is guaranteed that the number of dead end squares of the city is even. Print a single number — the minimum number of roads connecting the squares with demonstrations of different parties. |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
17065003 |
wuxuanyi27 |
F |
March 31, 2016, 2:23 a.m. |
OK |
GNU C++ |
TESTS |
50 |
46 |
104550400 |
|
2600 |
|
24803479 |
vjudge2 |
F |
Feb. 19, 2017, 1:53 p.m. |
OK |
GNU C++ |
TESTS |
50 |
61 |
102707200 |
|
2600 |
|
17064970 |
wuxuanyi27 |
F |
March 31, 2016, 2:20 a.m. |
OK |
GNU C++ |
TESTS |
50 |
62 |
104550400 |
|
2600 |
|
14321723 |
ericxu0 |
F |
Nov. 18, 2015, 6:54 a.m. |
OK |
GNU C++ |
TESTS |
50 |
77 |
100659200 |
|
2600 |
|
13500825 |
deepak44 |
F |
Oct. 8, 2015, 8:48 p.m. |
OK |
GNU C++ |
TESTS |
50 |
77 |
100659200 |
|
2600 |
|
13467197 |
ArcherKing |
F |
Oct. 7, 2015, 6:22 a.m. |
OK |
GNU C++ |
TESTS |
50 |
77 |
100966400 |
|
2600 |
|
24802289 |
vjudge3 |
F |
Feb. 19, 2017, 12:55 p.m. |
OK |
GNU C++ |
TESTS |
50 |
77 |
102707200 |
|
2600 |
|
24739900 |
vjudge3 |
F |
Feb. 17, 2017, 3:02 p.m. |
OK |
GNU C++ |
TESTS |
50 |
77 |
102707200 |
|
2600 |
|
19973206 |
vjudge5 |
F |
Aug. 20, 2016, 1:09 a.m. |
OK |
GNU C++ |
TESTS |
50 |
77 |
104550400 |
|
2600 |
|
17065027 |
vjudge1 |
F |
March 31, 2016, 2:26 a.m. |
OK |
GNU C++ |
TESTS |
50 |
77 |
104550400 |
|
2600 |
|
40986059 |
ReaLNero1 |
F |
July 30, 2018, 8:20 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
46 |
307200 |
|
2600 |
|
13408361 |
JohStraat |
F |
Oct. 4, 2015, 9:02 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
46 |
307200 |
|
2600 |
|
15889710 |
joisino |
F |
Feb. 8, 2016, 2:40 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
46 |
100761600 |
|
2600 |
|
27960350 |
user202729_ |
F |
June 22, 2017, 8:24 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
61 |
2560000 |
|
2600 |
|
57957792 |
vjudge1 |
F |
July 29, 2019, 7:45 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
61 |
102502400 |
|
2600 |
|
34918217 |
vjudge3 |
F |
Feb. 4, 2018, 8:47 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
61 |
102707200 |
|
2600 |
|
57319359 |
clya2004 |
F |
July 19, 2019, 9:22 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
62 |
100249600 |
|
2600 |
|
14552959 |
huanghongxun |
F |
Nov. 29, 2015, 7:19 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
62 |
100454400 |
|
2600 |
|
57884403 |
lopare |
F |
July 28, 2019, 9:11 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
62 |
100966400 |
|
2600 |
|
57817119 |
py_ultron |
F |
July 26, 2019, 8:21 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
62 |
100966400 |
|
2600 |
|
30052192 |
fengsuiyan |
F |
Sept. 4, 2017, 11:58 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
61 |
100966400 |
|
2600 |
|
33459361 |
MAMBA |
F |
Dec. 20, 2017, 3:12 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
93 |
2662400 |
|
2600 |
|
67067450 |
BamiTorabi |
F |
Dec. 17, 2019, 11:36 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
108 |
100761600 |
|
2600 |
|
27304488 |
shadowatyy |
F |
May 23, 2017, 3:41 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
109 |
100864000 |
|
2600 |
|
39086770 |
ArshiaDadras |
F |
June 10, 2018, 8:13 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
124 |
100966400 |
|
2600 |
|
28901171 |
boook |
F |
July 26, 2017, 10:27 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
124 |
104448000 |
|
2600 |
|
67675993 |
Zetr0 |
F |
Dec. 27, 2019, 1:48 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
124 |
200908800 |
|
2600 |
|
41432170 |
Hiasat |
F |
Aug. 10, 2018, 1:11 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
124 |
201523200 |
|
2600 |
|
44391358 |
I_love_Y_UME |
F |
Oct. 16, 2018, 8:46 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
124 |
204800000 |
|
2600 |
|
45513477 |
KATATONIA |
F |
Nov. 10, 2018, 2:22 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
139 |
100761600 |
|
2600 |
|
57616400 |
ijmg |
F |
July 24, 2019, 1:48 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
78 |
102604800 |
|
2600 |
|
49555508 |
pishbeenZ |
F |
Feb. 7, 2019, 9:22 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
92 |
101171200 |
|
2600 |
|
52924250 |
chinmay0906 |
F |
April 17, 2019, 7:31 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
93 |
100761600 |
|
2600 |
|
67021692 |
AliShahali1382 |
F |
Dec. 16, 2019, 1:09 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
93 |
100966400 |
|
2600 |
|
60191556 |
CiriloMorax17 |
F |
Sept. 6, 2019, 9:50 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
93 |
100966400 |
|
2600 |
|
48712065 |
vjudge3 |
F |
Jan. 22, 2019, 9:03 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
93 |
101068800 |
|
2600 |
|
53822442 |
Atreus |
F |
May 6, 2019, 1:58 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
109 |
201523200 |
|
2600 |
|
60668777 |
chuducanhchy |
F |
Sept. 16, 2019, 9:35 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
101068800 |
|
2600 |
|
60679145 |
chuducanhchy |
F |
Sept. 16, 2019, 1:26 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
104652800 |
|
2600 |
|
60678979 |
chuducanhchy |
F |
Sept. 16, 2019, 1:23 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
104652800 |
|
2600 |
|
13495630 |
Trasier |
F |
Oct. 8, 2015, 2:49 p.m. |
OK |
Java 7 |
TESTS |
50 |
389 |
141721600 |
|
2600 |
|
15430970 |
mkirsche |
F |
Jan. 18, 2016, 5:54 p.m. |
OK |
Java 7 |
TESTS |
50 |
1996 |
412569600 |
|
2600 |
|
39341195 |
megh422 |
F |
June 17, 2018, 5:52 p.m. |
OK |
Java 8 |
TESTS |
50 |
576 |
0 |
|
2600 |
|
14437213 |
Ruins |
F |
Nov. 24, 2015, 9:32 a.m. |
OK |
Java 8 |
TESTS |
50 |
592 |
0 |
|
2600 |
|
14054901 |
WonderMouse |
F |
Nov. 4, 2015, 10:10 a.m. |
OK |
Java 8 |
TESTS |
50 |
608 |
327884800 |
|
2600 |
|
14054590 |
WonderMouse |
F |
Nov. 4, 2015, 9:49 a.m. |
OK |
Java 8 |
TESTS |
50 |
639 |
327884800 |
|
2600 |
|
13415339 |
Valixon |
F |
Oct. 5, 2015, 12:14 p.m. |
OK |
Java 8 |
TESTS |
50 |
857 |
132096000 |
|
2600 |
|
23516766 |
p1p13 |
F |
Jan. 3, 2017, 1:02 p.m. |
OK |
Java 8 |
TESTS |
50 |
1684 |
289177600 |
|
2600 |
|
13858080 |
szilard |
F |
Oct. 25, 2015, 6:16 p.m. |
OK |
Java 8 |
TESTS |
50 |
2059 |
314163200 |
|
2600 |
|
13517312 |
ulandev |
F |
Oct. 9, 2015, 8:49 p.m. |
OK |
JavaScript |
TESTS |
50 |
529 |
4915200 |
|
2600 |
|
13420037 |
camypaper |
F |
Oct. 5, 2015, 5:14 p.m. |
OK |
MS C# |
TESTS |
50 |
217 |
4915200 |
|
2600 |
|
17033418 |
Martinue |
F |
March 30, 2016, 12:15 p.m. |
OK |
MS C++ |
TESTS |
50 |
62 |
100454400 |
|
2600 |
|
17033739 |
vjudge3 |
F |
March 30, 2016, 12:31 p.m. |
OK |
MS C++ |
TESTS |
50 |
93 |
100454400 |
|
2600 |
|
17033487 |
Martinue |
F |
March 30, 2016, 12:20 p.m. |
OK |
MS C++ |
TESTS |
50 |
93 |
100454400 |
|
2600 |
|
50162865 |
vjudge2 |
F |
Feb. 19, 2019, 1:22 p.m. |
OK |
MS C++ |
TESTS |
50 |
108 |
100454400 |
|
2600 |
|
13731397 |
vanvector |
F |
Oct. 19, 2015, 5:19 p.m. |
OK |
MS C++ |
TESTS |
50 |
124 |
200704000 |
|
2600 |
|
48771966 |
vjudge3 |
F |
Jan. 23, 2019, 1:05 a.m. |
OK |
MS C++ |
TESTS |
50 |
280 |
201420800 |
|
2600 |
|
48771129 |
vjudge5 |
F |
Jan. 23, 2019, 12:08 a.m. |
OK |
MS C++ |
TESTS |
50 |
296 |
200908800 |
|
2600 |
remove filters
Back to search problems