Codeforces Round 506 (Div. 3)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1029 Codeforces Round 506 (Div. 3) FINISHED False 7200 196700999 Aug. 24, 2018, 2:50 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 2945 ) E Tree with Small Distances PROGRAMMING dp graphs greedy 2200

B'You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex 1 to any other vertex is at most 2 . Note that you are not allowed to add loops and multiple edges. The first line contains one integer n ( 2 <= n <= 2 cdot 10^5 ) -- the number of vertices in the tree. The following n - 1 lines contain edges: edge i is given as a pair of vertices u_i, v_i ( 1 <= u_i, v_i <= n ). It is guaranteed that the given edges form a tree. It is guaranteed that there are no loops and multiple edges in the given edges. Print a single integer -- the minimum number of edges you have to add in order to make the shortest distance from the vertex 1 to any other vertex at most 2 . Note that you are not allowed to add loops and multiple edges. The tree corresponding to the first example: The answer is 2 , some of the possible answers are the following: [(1, 5), (1, 6)] , [(1, 4), (1, 7)] , [(1, 6), (1, 7)] . The tree corresponding to the second example: The answer is 0 . The tree corresponding to the third example: The answer is 1 , only one possible way to reach it is to add the edge (1, 3) . '...

Tutorials

Codeforces Round #506 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
42136560 rr_ E Aug. 27, 2018, 12:40 a.m. OK D TESTS 32 280 22835200 2200
42937320 cpy E Sept. 16, 2018, 11:44 a.m. OK D TESTS 32 311 52531200 2200
42937705 cpy E Sept. 16, 2018, 11:46 a.m. OK D TESTS 32 312 52531200 2200
42358231 changxv E Sept. 2, 2018, 10:08 a.m. OK GNU C++ TESTS 32 62 13619200 2200
42410107 Scut82 E Sept. 2, 2018, 11:44 p.m. OK GNU C++ TESTS 32 77 19558400 2200
42445387 luogu_bot1 E Sept. 4, 2018, 2:35 a.m. OK GNU C++ TESTS 32 78 20787200 2200
42116905 Even_Bao E Aug. 26, 2018, 10:18 a.m. OK GNU C++ TESTS 32 93 11468800 2200
42428488 Dilute E Sept. 3, 2018, 1:46 p.m. OK GNU C++ TESTS 32 93 13004800 2200
42332926 luojinyao E Sept. 1, 2018, 11:33 a.m. OK GNU C++ TESTS 32 93 26419200 2200
42112476 Silver-Water E Aug. 26, 2018, 7:09 a.m. OK GNU C++ TESTS 32 109 11161600 2200
42140485 vjudge2 E Aug. 27, 2018, 4:59 a.m. OK GNU C++ TESTS 32 109 13619200 2200
42239082 bnc1010 E Aug. 29, 2018, 11:29 a.m. OK GNU C++ TESTS 32 109 22425600 2200
42428465 Dilute E Sept. 3, 2018, 1:45 p.m. OK GNU C++ TESTS 32 124 13004800 2200
44759677 miaokehao E Oct. 24, 2018, 6:17 a.m. OK GNU C++11 TESTS 32 46 8704000 2200
42855321 wxh0l0910 E Sept. 14, 2018, 8:59 a.m. OK GNU C++11 TESTS 32 46 13414400 2200
44759705 foreverlasting E Oct. 24, 2018, 6:18 a.m. OK GNU C++11 TESTS 32 46 20787200 2200
42696018 ReaLNero1 E Sept. 9, 2018, 7:12 a.m. OK GNU C++11 TESTS 32 61 13414400 2200
42194316 Letmecry E Aug. 28, 2018, 5:29 a.m. OK GNU C++11 TESTS 32 61 13414400 2200
42326848 goldgenius E Sept. 1, 2018, 6:28 a.m. OK GNU C++11 TESTS 32 61 18432000 2200
44766963 luogu_bot4 E Oct. 24, 2018, 10:26 a.m. OK GNU C++11 TESTS 32 61 18944000 2200
49849946 luogu_bot4 E Feb. 13, 2019, 2:32 a.m. OK GNU C++11 TESTS 32 61 40857600 2200
44721775 Captain_Paul E Oct. 23, 2018, 5:40 a.m. OK GNU C++11 TESTS 32 62 13414400 2200
45414852 luogu_bot4 E Nov. 7, 2018, 1:41 p.m. OK GNU C++11 TESTS 32 62 13824000 2200
42141887 Mr.ugly E Aug. 27, 2018, 6:09 a.m. OK GNU C++14 TESTS 32 109 13619200 2200
42364420 IMIMIMIIM E Sept. 2, 2018, 1:45 p.m. OK GNU C++14 TESTS 32 124 13619200 2200
42356708 msyao E Sept. 2, 2018, 9:10 a.m. OK GNU C++14 TESTS 32 124 13619200 2200
53490210 vjudge4 E April 29, 2019, 8:02 a.m. OK GNU C++14 TESTS 32 124 21606400 2200
48444666 ytrsk E Jan. 16, 2019, 6:45 a.m. OK GNU C++14 TESTS 32 124 21606400 2200
42146227 tyshiwo1 E Aug. 27, 2018, 8:59 a.m. OK GNU C++14 TESTS 32 139 18432000 2200
46103424 icelemon E Nov. 23, 2018, 7:34 a.m. OK GNU C++14 TESTS 32 140 10137600 2200
42207533 5120164053 E Aug. 28, 2018, 12:26 p.m. OK GNU C++14 TESTS 32 140 14540800 2200
50819511 MengXiaoLong E March 5, 2019, 12:57 p.m. OK GNU C++14 TESTS 32 140 15974400 2200
42656133 rl2100 E Sept. 7, 2018, 10:27 p.m. OK GNU C++14 TESTS 32 140 18432000 2200
65830890 910306264 E Nov. 27, 2019, 1:57 p.m. OK GNU C++17 TESTS 32 124 11673600 2200
50710339 vjudge3 E March 3, 2019, 6:33 a.m. OK GNU C++17 TESTS 32 124 16076800 2200
62060966 JingLuozz E Oct. 7, 2019, 1:38 p.m. OK GNU C++17 TESTS 32 124 23244800 2200
61404437 wadewlison E Sept. 28, 2019, 6:32 a.m. OK GNU C++17 TESTS 32 139 10137600 2200
62057208 vjudge3 E Oct. 7, 2019, 12:29 p.m. OK GNU C++17 TESTS 32 139 23244800 2200
42126291 Lanceloia E Aug. 26, 2018, 3:26 p.m. OK GNU C++17 TESTS 32 140 15974400 2200
54981717 oskarfiuk1 E June 2, 2019, 1:30 p.m. OK GNU C++17 TESTS 32 155 19353600 2200
45156501 fcwww E Nov. 1, 2018, 3:11 a.m. OK GNU C++17 TESTS 32 155 19763200 2200
42193492 czdb E Aug. 28, 2018, 4:55 a.m. OK GNU C++17 TESTS 32 156 20787200 2200
44727020 BryantYm E Oct. 23, 2018, 8:31 a.m. OK GNU C++17 TESTS 32 156 37580800 2200
42246266 Marii E Aug. 29, 2018, 3:29 p.m. OK Go TESTS 32 546 29286400 2200
42199771 Letmecry E Aug. 28, 2018, 8:14 a.m. OK Go TESTS 32 701 33689600 2200
42430589 Ahmad E Sept. 3, 2018, 2:38 p.m. OK Java 8 TESTS 32 311 37888000 2200
42127114 kushwaha_vi E Aug. 26, 2018, 3:58 p.m. OK Java 8 TESTS 32 483 17817600 2200
46017395 aminul E Nov. 21, 2018, 5:13 a.m. OK Java 8 TESTS 32 498 51712000 2200
65519396 yaoct E Nov. 22, 2019, 7:33 a.m. OK Java 8 TESTS 32 530 49049600 2200
42338954 AhmedAbdou E Sept. 1, 2018, 3:48 p.m. OK Java 8 TESTS 32 560 55398400 2200
66250415 bluesky111 E Dec. 4, 2019, 1:11 a.m. OK Java 8 TESTS 32 576 79257600 2200
45063834 vjudge4 E Oct. 29, 2018, 4:06 p.m. OK Java 8 TESTS 32 577 47104000 2200
45063777 vjudge2 E Oct. 29, 2018, 4:04 p.m. OK Java 8 TESTS 32 577 47104000 2200
45061307 vjudge1 E Oct. 29, 2018, 2:58 p.m. OK Java 8 TESTS 32 592 47001600 2200
42158809 java_geek E Aug. 27, 2018, 4:37 p.m. OK Java 8 TESTS 32 592 139468800 2200
68887792 lorgio.gonzalez E Jan. 15, 2020, 11:28 p.m. OK Mono C# TESTS 32 451 28774400 2200
44047541 omikad E Oct. 9, 2018, 5:59 p.m. OK Mono C# TESTS 32 560 46694400 2200
42145646 lxn E Aug. 27, 2018, 8:40 a.m. OK MS C++ TESTS 32 93 12902400 2200
50738785 vjudge4 E March 3, 2019, 2:14 p.m. OK MS C++ TESTS 32 139 18227200 2200
43897097 MiserableWisdom E Oct. 6, 2018, 11:17 a.m. OK MS C++ TESTS 32 202 16691200 2200
43608446 vjudge2 E Sept. 30, 2018, 1:16 p.m. OK MS C++ TESTS 32 202 17920000 2200
50740761 vjudge1 E March 3, 2019, 3:20 p.m. OK MS C++ TESTS 32 312 18227200 2200
50745221 vjudge5 E March 3, 2019, 3:57 p.m. OK MS C++ TESTS 32 327 18227200 2200
50740955 vjudge5 E March 3, 2019, 3:26 p.m. OK MS C++ TESTS 32 342 18227200 2200
51403914 vjudge3 E March 17, 2019, 8:51 a.m. OK MS C++ TESTS 32 343 18227200 2200
42671334 _mactep E Sept. 8, 2018, 11:09 a.m. OK MS C++ TESTS 32 374 13414400 2200
48206584 jernchr11 E Jan. 11, 2019, 9:14 a.m. OK MS C++ TESTS 32 405 19660800 2200
58418841 yorky E Aug. 7, 2019, 6:45 a.m. OK MS C++ 2017 TESTS 32 452 28774400 2200
62658630 pajenegod E Oct. 16, 2019, 4 a.m. OK PyPy 2 TESTS 32 452 31129600 2200
47715451 titia E Dec. 30, 2018, 7:18 a.m. OK PyPy 3 TESTS 32 998 51404800 2200
61353055 sansen E Sept. 27, 2019, 9:15 a.m. OK Rust TESTS 32 139 16179200 2200
42197432 Letmecry E Aug. 28, 2018, 7:07 a.m. OK Rust TESTS 32 171 42700800 2200
42230993 Letmecry E Aug. 29, 2018, 6:40 a.m. OK Rust TESTS 32 187 14028800 2200
42197493 Letmecry E Aug. 28, 2018, 7:09 a.m. OK Rust TESTS 32 187 42700800 2200
42457697 vain0 E Sept. 4, 2018, 12:18 p.m. OK Rust TESTS 32 187 78131200 2200
42112762 yakamoto E Aug. 26, 2018, 7:22 a.m. OK Scala TESTS 32 701 5734400 2200

remove filters

Back to search problems