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"There are n cities in Berland. Some pairs of cities are connected by roads. All roads are bidirectional. Each road connects two different cities. There is at most one road between a pair of cities. The cities are numbered from 1 to n . It is known that, from the capital (the city with the number 1 ), you can reach any other city by moving along the roads. The President of Berland plans to improve the country's road network. The budget is enough to repair exactly n-1 roads. The President plans to choose a set of n-1 roads such that: In other words, the set of n-1 roads should preserve the connectivity of the country, and the sum of distances from city 1 to all cities should be minimized (where you can only use the n-1 chosen roads). The president instructed the ministry to prepare k possible options to choose n-1 roads so that both conditions above are met. Write a program that will find k possible ways to choose roads for repair. If there are fewer than k ways, then the program should output all possible valid ways to choose roads. The first line of the input contains integers n , m and k ( 2 <= n <= 2 cdot10^5, n-1 <= m <= 2 cdot10^5, 1 <= k <= 2 cdot10^5 ), where n is the number of cities in the country, m is the number of roads and k is the number of options to choose a set of roads for repair. It is guaranteed that m cdot k <= 10^6 . The following m lines describe the roads, one road per line. Each line contains two integers a_i , b_i ( 1 <= a_i, b_i <= n , a_i ne b_i ) -- the numbers of the cities that the i -th road connects. There is at most one road between a pair of cities. The given set of roads is such that you can reach any city from the capital. Print t ( 1 <= t <= k ) -- the number of ways to choose a set of roads for repair. Recall that you need to find k differe"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
40251523 |
Qing_LKYi |
F |
July 13, 2018, 6:28 a.m. |
OK |
GNU C++ |
TESTS |
74 |
78 |
23142400 |
|
2400 |
41561140 |
jangjie |
F |
Aug. 13, 2018, 2:19 p.m. |
OK |
GNU C++ |
TESTS |
74 |
139 |
20480000 |
|
2400 |
40381546 |
zhtjtcz |
F |
July 15, 2018, 2:30 p.m. |
OK |
GNU C++ |
TESTS |
74 |
155 |
19046400 |
|
2400 |
40235590 |
luqingxin |
F |
July 12, 2018, 2:36 p.m. |
OK |
GNU C++ |
TESTS |
74 |
171 |
10854400 |
|
2400 |
40872862 |
vjudge3 |
F |
July 28, 2018, 7:09 a.m. |
OK |
GNU C++ |
TESTS |
74 |
171 |
19763200 |
|
2400 |
41123304 |
withoutpower |
F |
Aug. 2, 2018, 1:02 p.m. |
OK |
GNU C++ |
TESTS |
74 |
187 |
35020800 |
|
2400 |
40381895 |
guille |
F |
July 15, 2018, 2:48 p.m. |
OK |
GNU C++ |
TESTS |
74 |
202 |
42700800 |
|
2400 |
40308905 |
Silver-Water |
F |
July 14, 2018, 7:09 a.m. |
OK |
GNU C++ |
TESTS |
74 |
217 |
16486400 |
|
2400 |
40878253 |
vjudge5 |
F |
July 28, 2018, 9:27 a.m. |
OK |
GNU C++ |
TESTS |
74 |
217 |
17817600 |
|
2400 |
40173549 |
xielinhan |
F |
July 10, 2018, 1:46 p.m. |
OK |
GNU C++ |
TESTS |
74 |
217 |
23654400 |
|
2400 |
46705287 |
_zay |
F |
Dec. 7, 2018, 6:39 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
78 |
21504000 |
|
2400 |
41652870 |
hankeke |
F |
Aug. 16, 2018, 12:50 p.m. |
OK |
GNU C++11 |
TESTS |
74 |
93 |
13926400 |
|
2400 |
40729777 |
Frost_lvt |
F |
July 25, 2018, 7:03 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
109 |
14131200 |
|
2400 |
66532497 |
luogu_bot3 |
F |
Dec. 9, 2019, 8:05 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
109 |
22937600 |
|
2400 |
66532480 |
MoQianXue |
F |
Dec. 9, 2019, 8:04 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
109 |
22937600 |
|
2400 |
61212609 |
cmwqf |
F |
Sept. 24, 2019, 11:54 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
109 |
33280000 |
|
2400 |
40395362 |
HolyK |
F |
July 16, 2018, 4:47 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
124 |
50176000 |
|
2400 |
41669366 |
DragoonKiller |
F |
Aug. 17, 2018, 3:23 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
139 |
19456000 |
|
2400 |
40311883 |
zzb111 |
F |
July 14, 2018, 8:25 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
139 |
20275200 |
|
2400 |
59564343 |
nitrogens |
F |
Aug. 27, 2019, 10:03 a.m. |
OK |
GNU C++11 |
TESTS |
74 |
140 |
22323200 |
|
2400 |
60445596 |
AyaBenSaad |
F |
Sept. 12, 2019, 2:02 p.m. |
OK |
GNU C++14 |
TESTS |
74 |
186 |
16896000 |
|
2400 |
49514943 |
xiaowuc1 |
F |
Feb. 6, 2019, 1:14 a.m. |
OK |
GNU C++14 |
TESTS |
74 |
186 |
21606400 |
|
2400 |
47465748 |
ParagonX97 |
F |
Dec. 24, 2018, 5:55 p.m. |
OK |
GNU C++14 |
TESTS |
74 |
202 |
16691200 |
|
2400 |
40208506 |
Disacom |
F |
July 11, 2018, 5:15 p.m. |
OK |
GNU C++14 |
TESTS |
74 |
202 |
16691200 |
|
2400 |
40202573 |
the_timur |
F |
July 11, 2018, 1:29 p.m. |
OK |
GNU C++14 |
TESTS |
74 |
202 |
17203200 |
|
2400 |
50305848 |
cocktail |
F |
Feb. 22, 2019, 6:06 a.m. |
OK |
GNU C++14 |
TESTS |
74 |
202 |
17510400 |
|
2400 |
40300115 |
kobortor |
F |
July 14, 2018, 1:14 a.m. |
OK |
GNU C++14 |
TESTS |
74 |
202 |
20377600 |
|
2400 |
51083143 |
fblogy |
F |
March 9, 2019, 12:08 p.m. |
OK |
GNU C++14 |
TESTS |
74 |
202 |
23552000 |
|
2400 |
40191521 |
cycleke |
F |
July 11, 2018, 6:52 a.m. |
OK |
GNU C++14 |
TESTS |
74 |
202 |
24473600 |
|
2400 |
62530199 |
LODB---D |
F |
Oct. 13, 2019, 6:58 p.m. |
OK |
GNU C++14 |
TESTS |
74 |
202 |
25395200 |
|
2400 |
53005821 |
babilong |
F |
April 19, 2019, 9:31 a.m. |
OK |
GNU C++17 |
TESTS |
74 |
140 |
27238400 |
|
2400 |
50915170 |
vjudge1 |
F |
March 7, 2019, 5:50 a.m. |
OK |
GNU C++17 |
TESTS |
74 |
171 |
26316800 |
|
2400 |
57758671 |
Sisyy |
F |
July 25, 2019, 5:11 p.m. |
OK |
GNU C++17 |
TESTS |
74 |
187 |
23654400 |
|
2400 |
56704671 |
misir |
F |
July 8, 2019, 10:37 a.m. |
OK |
GNU C++17 |
TESTS |
74 |
202 |
16691200 |
|
2400 |
51475153 |
vjudge1 |
F |
March 19, 2019, 8:57 a.m. |
OK |
GNU C++17 |
TESTS |
74 |
202 |
19046400 |
|
2400 |
57949574 |
jyf111 |
F |
July 29, 2019, 3:50 p.m. |
OK |
GNU C++17 |
TESTS |
74 |
202 |
23449600 |
|
2400 |
40919528 |
nupt_ant |
F |
July 29, 2018, 1:46 p.m. |
OK |
GNU C++17 |
TESTS |
74 |
202 |
28569600 |
|
2400 |
40400008 |
978287546 |
F |
July 16, 2018, 7:13 a.m. |
OK |
GNU C++17 |
TESTS |
74 |
202 |
32051200 |
|
2400 |
41554691 |
situ |
F |
Aug. 13, 2018, 10:32 a.m. |
OK |
GNU C++17 |
TESTS |
74 |
202 |
32768000 |
|
2400 |
59915552 |
KrK |
F |
Sept. 2, 2019, 7:01 p.m. |
OK |
GNU C++17 |
TESTS |
74 |
202 |
32972800 |
|
2400 |
53081700 |
mikkk |
F |
April 21, 2019, 6:54 a.m. |
OK |
Java 8 |
TESTS |
74 |
764 |
110080000 |
|
2400 |
40376086 |
Atef |
F |
July 15, 2018, 11:05 a.m. |
OK |
Java 8 |
TESTS |
74 |
888 |
93491200 |
|
2400 |
40263908 |
bhishma |
F |
July 13, 2018, 2:08 p.m. |
OK |
Java 8 |
TESTS |
74 |
904 |
177868800 |
|
2400 |
41948992 |
BaZ_ |
F |
Aug. 21, 2018, 9:51 p.m. |
OK |
Java 8 |
TESTS |
74 |
919 |
99532800 |
|
2400 |
40376108 |
Atef |
F |
July 15, 2018, 11:06 a.m. |
OK |
Java 8 |
TESTS |
74 |
966 |
93491200 |
|
2400 |
40187092 |
flyman3046 |
F |
July 11, 2018, 2:43 a.m. |
OK |
Java 8 |
TESTS |
74 |
967 |
212480000 |
|
2400 |
40192210 |
uwi |
F |
July 11, 2018, 7:14 a.m. |
OK |
Java 8 |
TESTS |
74 |
1138 |
86425600 |
|
2400 |
40492752 |
out_of_the_box |
F |
July 17, 2018, 10:49 p.m. |
OK |
Java 8 |
TESTS |
74 |
1294 |
111820800 |
|
2400 |
40492634 |
out_of_the_box |
F |
July 17, 2018, 10:36 p.m. |
OK |
Java 8 |
TESTS |
74 |
1325 |
115404800 |
|
2400 |
40492727 |
out_of_the_box |
F |
July 17, 2018, 10:47 p.m. |
OK |
Java 8 |
TESTS |
74 |
1341 |
111923200 |
|
2400 |
40563397 |
vjudge2 |
F |
July 20, 2018, 2:57 a.m. |
OK |
MS C++ |
TESTS |
74 |
233 |
31846400 |
|
2400 |
40563434 |
vjudge4 |
F |
July 20, 2018, 2:59 a.m. |
OK |
MS C++ |
TESTS |
74 |
249 |
31846400 |
|
2400 |
40373648 |
j4357j |
F |
July 15, 2018, 9:32 a.m. |
OK |
MS C++ |
TESTS |
74 |
311 |
23449600 |
|
2400 |
40868780 |
CrashMaster |
F |
July 28, 2018, 5:18 a.m. |
OK |
MS C++ |
TESTS |
74 |
436 |
18022400 |
|
2400 |
63077567 |
yorky |
F |
Oct. 21, 2019, 2:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
74 |
467 |
28876800 |
|
2400 |
40229196 |
taiks |
F |
July 12, 2018, 10:55 a.m. |
OK |
Python 2 |
TESTS |
74 |
3899 |
78950400 |
|
2400 |
40179374 |
vrublack |
F |
July 10, 2018, 5:30 p.m. |
OK |
Python 3 |
TESTS |
74 |
2932 |
60723200 |
|
2400 |
40188410 |
demi12 |
F |
July 11, 2018, 4:20 a.m. |
OK |
Python 3 |
TESTS |
74 |
4009 |
79052800 |
|
2400 |
47491728 |
yakamoto |
F |
Dec. 25, 2018, 12:33 p.m. |
OK |
Scala |
TESTS |
74 |
982 |
64921600 |
|
2400 |
remove filters
Back to search problems