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 |
---|---|---|---|---|---|---|
1385 | Codeforces Round 656 (Div. 3) | FINISHED | False | 8100 | 142183463 | July 17, 2020, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 2611 ) | F | Removing Leaves | PROGRAMMING | data structures dfs and similar divide and conquer greedy implementation trees | 2300 |
B'You are given a tree (connected graph without cycles) consisting of n vertices. The tree is unrooted -- it is just a connected undirected graph without cycles. In one move, you can choose exactly k leaves (leaf is such a vertex that is connected to only one another vertex) connected to the same vertex and remove them with edges incident to them. I.e. you choose such leaves u_1, u_2, ... , u_k that there are edges (u_1, v) , (u_2, v) , ... , (u_k, v) and remove these leaves and these edges. Your task is to find the maximum number of moves you can perform if you remove leaves optimally. You have to answer t independent test cases. The first line of the input contains one integer t ( 1 <= t <= 2 cdot 10^4 ) -- the number of test cases. Then t test cases follow. The first line of the test case contains two integers n and k ( 2 <= n <= 2 cdot 10^5 ; 1 <= k < n ) -- the number of vertices in the tree and the number of leaves you remove in one move, respectively. The next n-1 lines describe edges. The i -th edge is represented as two integers x_i and y_i ( 1 <= x_i, y_i <= n ), where x_i and y_i are vertices the i -th edge connects. It is guaranteed that the given set of edges forms a tree. It is guaranteed that the sum of n does not exceed 2 cdot 10^5 ( sum n <= 2 cdot 10^5 ). For each test case, print the answer -- the maximum number of moves you can perform if you remove leaves optimally. The picture corresponding to the first test case of the example: There you can remove vertices 2 , 5 and 3 during the first move and vertices 1 , 7 and 4 during the second move. The picture corresponding to the second test case of the example: There you can remove vertices 7 , 8 and 9 during the first move, then vertices 5 , 6 and 10 during the sec'... |
Codeforces Round #656 (Div. 3) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
87132099 | Gassa | F | July 17, 2020, 3:41 p.m. | OK | D | TESTS | 36 | 514 | 80793600 | 2300 | |
87135434 | rainboy | F | July 17, 2020, 3:47 p.m. | OK | GNU C11 | TESTS | 36 | 124 | 6963200 | 2300 | |
87190954 | scimoon | F | July 18, 2020, 2:59 a.m. | OK | GNU C++11 | TESTS | 36 | 46 | 10444800 | 2300 | |
87151377 | dysyn1314 | F | July 17, 2020, 4:25 p.m. | OK | GNU C++11 | TESTS | 36 | 77 | 25190400 | 2300 | |
87144101 | selia | F | July 17, 2020, 4:06 p.m. | OK | GNU C++11 | TESTS | 36 | 78 | 11161600 | 2300 | |
87129529 | stoorz | F | July 17, 2020, 3:36 p.m. | OK | GNU C++11 | TESTS | 36 | 78 | 12800000 | 2300 | |
87195394 | adityapathak1630 | F | July 18, 2020, 4:45 a.m. | OK | GNU C++11 | TESTS | 36 | 78 | 12800000 | 2300 | |
87191034 | YHHxBULIATANIA | F | July 18, 2020, 3:01 a.m. | OK | GNU C++11 | TESTS | 36 | 93 | 17408000 | 2300 | |
87138795 | wyj200266 | F | July 17, 2020, 3:55 p.m. | OK | GNU C++11 | TESTS | 36 | 109 | 27852800 | 2300 | |
87151169 | SOSCHINA | F | July 17, 2020, 4:25 p.m. | OK | GNU C++11 | TESTS | 36 | 124 | 11878400 | 2300 | |
87132328 | Prabowo | F | July 17, 2020, 3:41 p.m. | OK | GNU C++11 | TESTS | 36 | 124 | 12800000 | 2300 | |
87143152 | yao11617 | F | July 17, 2020, 4:04 p.m. | OK | GNU C++11 | TESTS | 36 | 124 | 14643200 | 2300 | |
87133091 | dlalswp25 | F | July 17, 2020, 3:43 p.m. | OK | GNU C++14 | TESTS | 36 | 124 | 12390400 | 2300 | |
87183786 | alleviatedRules | F | July 17, 2020, 10:28 p.m. | OK | GNU C++14 | TESTS | 36 | 124 | 12390400 | 2300 | |
87182338 | Potassium | F | July 17, 2020, 9:42 p.m. | OK | GNU C++14 | TESTS | 36 | 124 | 14336000 | 2300 | |
87178994 | anmolsri | F | July 17, 2020, 8:19 p.m. | OK | GNU C++14 | TESTS | 36 | 139 | 12390400 | 2300 | |
87198211 | islingr | F | July 18, 2020, 5:45 a.m. | OK | GNU C++14 | TESTS | 36 | 139 | 23552000 | 2300 | |
87170816 | xsc | F | July 17, 2020, 6:18 p.m. | OK | GNU C++14 | TESTS | 36 | 140 | 12390400 | 2300 | |
87160057 | fpeterfalvi | F | July 17, 2020, 4:48 p.m. | OK | GNU C++14 | TESTS | 36 | 140 | 13209600 | 2300 | |
87186641 | robertyu02 | F | July 18, 2020, 12:39 a.m. | OK | GNU C++14 | TESTS | 36 | 140 | 27136000 | 2300 | |
87167668 | SuperJ6 | F | July 17, 2020, 5:43 p.m. | OK | GNU C++14 | TESTS | 36 | 155 | 14848000 | 2300 | |
87174046 | ardan | F | July 17, 2020, 6:57 p.m. | OK | GNU C++14 | TESTS | 36 | 155 | 15052800 | 2300 | |
87138905 | Marcythm | F | July 17, 2020, 3:55 p.m. | OK | GNU C++17 | TESTS | 36 | 46 | 11264000 | 2300 | |
87155521 | Austin_Griffin2 | F | July 17, 2020, 4:36 p.m. | OK | GNU C++17 | TESTS | 36 | 109 | 9830400 | 2300 | |
87163820 | fcxooosq | F | July 17, 2020, 5:07 p.m. | OK | GNU C++17 | TESTS | 36 | 124 | 11161600 | 2300 | |
87198868 | cuiaoxiang | F | July 18, 2020, 5:54 a.m. | OK | GNU C++17 | TESTS | 36 | 124 | 12390400 | 2300 | |
87198339 | cuiaoxiang | F | July 18, 2020, 5:47 a.m. | OK | GNU C++17 | TESTS | 36 | 139 | 12390400 | 2300 | |
87198523 | cuiaoxiang | F | July 18, 2020, 5:49 a.m. | OK | GNU C++17 | TESTS | 36 | 139 | 12390400 | 2300 | |
87198064 | rath772k | F | July 18, 2020, 5:43 a.m. | OK | GNU C++17 | TESTS | 36 | 139 | 13209600 | 2300 | |
87198859 | cuiaoxiang | F | July 18, 2020, 5:54 a.m. | OK | GNU C++17 | TESTS | 36 | 140 | 12390400 | 2300 | |
87199046 | cuiaoxiang | F | July 18, 2020, 5:57 a.m. | OK | GNU C++17 | TESTS | 36 | 140 | 12390400 | 2300 | |
87183512 | monkeyOnTypewriter | F | July 17, 2020, 10:18 p.m. | OK | GNU C++17 | TESTS | 36 | 140 | 12492800 | 2300 | |
87169488 | neal | F | July 17, 2020, 6:04 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 124 | 15872000 | 2300 | |
87164273 | Valera_Grinenko | F | July 17, 2020, 5:11 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 124 | 17715200 | 2300 | |
87163781 | galen_colin | F | July 17, 2020, 5:07 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 124 | 41984000 | 2300 | |
87153307 | joseacaz | F | July 17, 2020, 4:30 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 139 | 15769600 | 2300 | |
87175843 | smax | F | July 17, 2020, 7:23 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 139 | 16179200 | 2300 | |
87164509 | galen_colin | F | July 17, 2020, 5:13 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 139 | 41779200 | 2300 | |
87126194 | ALILILILILI-KHAN | F | July 17, 2020, 3:30 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 140 | 14540800 | 2300 | |
87186986 | MostafaAbdalla | F | July 18, 2020, 12:55 a.m. | OK | GNU C++17 (64) | TESTS | 36 | 140 | 15769600 | 2300 | |
87172162 | zuhn | F | July 17, 2020, 6:34 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 140 | 15769600 | 2300 | |
87175084 | Manel_Nesquik | F | July 17, 2020, 7:12 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 140 | 16076800 | 2300 | |
87178635 | meooow | F | July 17, 2020, 8:12 p.m. | OK | Go | TESTS | 36 | 140 | 26112000 | 2300 | |
87185274 | Richard727 | F | July 17, 2020, 11:25 p.m. | OK | Java 11 | TESTS | 36 | 265 | 31334400 | 2300 | |
87185260 | Richard727 | F | July 17, 2020, 11:25 p.m. | OK | Java 11 | TESTS | 36 | 280 | 31334400 | 2300 | |
87179209 | idk321 | F | July 17, 2020, 8:24 p.m. | OK | Java 11 | TESTS | 36 | 545 | 79667200 | 2300 | |
87135972 | Dukkha | F | July 17, 2020, 3:49 p.m. | OK | Java 11 | TESTS | 36 | 654 | 24473600 | 2300 | |
87153677 | Apfeloxid | F | July 17, 2020, 4:31 p.m. | OK | Java 11 | TESTS | 36 | 842 | 185344000 | 2300 | |
87172890 | abc_000 | F | July 17, 2020, 6:43 p.m. | OK | Java 8 | TESTS | 36 | 405 | 54784000 | 2300 | |
87127032 | bleh0.5 | F | July 17, 2020, 3:32 p.m. | OK | Java 8 | TESTS | 36 | 452 | 51712000 | 2300 | |
87181429 | MagentaCobra | F | July 17, 2020, 9:16 p.m. | OK | Java 8 | TESTS | 36 | 499 | 61952000 | 2300 | |
87161984 | akram-adel | F | July 17, 2020, 4:55 p.m. | OK | Java 8 | TESTS | 36 | 639 | 61644800 | 2300 | |
87164879 | out_of_the_box | F | July 17, 2020, 5:16 p.m. | OK | Java 8 | TESTS | 36 | 780 | 88985600 | 2300 | |
87197154 | flyman3046 | F | July 18, 2020, 5:30 a.m. | OK | Java 8 | TESTS | 36 | 1231 | 156774400 | 2300 | |
87138617 | ekaerovets | F | July 17, 2020, 3:54 p.m. | OK | Kotlin | TESTS | 36 | 358 | 53145600 | 2300 | |
87137255 | Hakiobo | F | July 17, 2020, 3:51 p.m. | OK | Kotlin | TESTS | 36 | 389 | 63180800 | 2300 | |
87128027 | Tlatoani | F | July 17, 2020, 3:33 p.m. | OK | Kotlin | TESTS | 36 | 560 | 56012800 | 2300 | |
87165909 | terry_u16 | F | July 17, 2020, 5:25 p.m. | OK | Mono C# | TESTS | 36 | 514 | 39424000 | 2300 | |
87171981 | r57shell | F | July 17, 2020, 6:31 p.m. | OK | MS C++ | TESTS | 36 | 171 | 18124800 | 2300 | |
87162942 | r57shell | F | July 17, 2020, 5:01 p.m. | OK | MS C++ | TESTS | 36 | 327 | 33996800 | 2300 | |
87165780 | youx | F | July 17, 2020, 5:24 p.m. | OK | MS C++ 2017 | TESTS | 36 | 171 | 11878400 | 2300 | |
87128355 | pichulia | F | July 17, 2020, 3:34 p.m. | OK | MS C++ 2017 | TESTS | 36 | 171 | 11980800 | 2300 | |
87165113 | otarra | F | July 17, 2020, 5:18 p.m. | OK | MS C++ 2017 | TESTS | 36 | 186 | 12390400 | 2300 | |
87170787 | xsc | F | July 17, 2020, 6:17 p.m. | OK | MS C++ 2017 | TESTS | 36 | 374 | 12492800 | 2300 | |
87149019 | kupriyanov | F | July 17, 2020, 4:19 p.m. | OK | MS C++ 2017 | TESTS | 36 | 530 | 24576000 | 2300 | |
87161913 | DavitMarg | F | July 17, 2020, 4:55 p.m. | OK | MS C++ 2017 | TESTS | 36 | 717 | 35225600 | 2300 | |
87151575 | asher10000 | F | July 17, 2020, 4:26 p.m. | OK | MS C++ 2017 | TESTS | 36 | 1060 | 83968000 | 2300 | |
87151996 | pajenegod | F | July 17, 2020, 4:27 p.m. | OK | PyPy 2 | TESTS | 36 | 343 | 58368000 | 2300 | |
87163666 | pajenegod | F | July 17, 2020, 5:06 p.m. | OK | PyPy 2 | TESTS | 36 | 374 | 57651200 | 2300 | |
87163988 | stnkien | F | July 17, 2020, 5:09 p.m. | OK | PyPy 3 | TESTS | 36 | 655 | 44441600 | 2300 | |
87170221 | throwawayatcoder | F | July 17, 2020, 6:12 p.m. | OK | PyPy 3 | TESTS | 36 | 670 | 82227200 | 2300 | |
87189931 | mkawa2 | F | July 18, 2020, 2:31 a.m. | OK | PyPy 3 | TESTS | 36 | 670 | 120012800 | 2300 | |
87129544 | qwertz73355a | F | July 17, 2020, 3:36 p.m. | OK | PyPy 3 | TESTS | 36 | 748 | 61542400 | 2300 | |
87128983 | FireBird23 | F | July 17, 2020, 3:35 p.m. | OK | PyPy 3 | TESTS | 36 | 857 | 86630400 | 2300 | |
87143972 | tganonymous | F | July 17, 2020, 4:06 p.m. | OK | PyPy 3 | TESTS | 36 | 1793 | 44134400 | 2300 | |
87173109 | alon276 | F | July 17, 2020, 6:46 p.m. | OK | Python 3 | TESTS | 36 | 1013 | 82636800 | 2300 | |
87166893 | sh1194 | F | July 17, 2020, 5:35 p.m. | OK | Python 3 | TESTS | 36 | 1996 | 67584000 | 2300 | |
87139190 | LHamster | F | July 17, 2020, 3:56 p.m. | OK | Python 3 | TESTS | 36 | 1996 | 67584000 | 2300 | |
87193429 | sansen | F | July 18, 2020, 3:57 a.m. | OK | Rust | TESTS | 36 | 140 | 25292800 | 2300 | |
87156844 | robostac | F | July 17, 2020, 4:40 p.m. | OK | Rust | TESTS | 36 | 1309 | 23961600 | 2300 |
Back to search problems