Kotlin Heroes: Episode 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
1297 Kotlin Heroes: Episode 3 FINISHED False 9000 154542311 Feb. 27, 2020, 1:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 205 ) E Modernization of Treeland PROGRAMMING *special dfs and similar trees

B'Treeland consists of n cities and n-1 two-way roads connecting pairs of cities. From every city, you can reach every other city moving only by the roads. You are right, the system of cities and roads in this country forms an undirected tree. The government has announced a program for the modernization of urban infrastructure of some cities. You have been assigned to select an arbitrary subset of cities S to upgrade (potentially all the cities) that satisfies the following requirements: Help Treeland upgrade its cities. Find any of the possible subsets S or determine that such a subset does not exist. The first line contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases in the input. This is followed by the test cases themselves. Each test case begins with a line that contains two integers n and k ( 2 <= n <= 3 cdot 10^5 , 1 <= k <= n ) -- the number of cities in Treeland and the number of "dead-end" cities required in the subset S . This is followed by n-1 lines with road descriptions. Each road is given by two integers x and y ( 1 <= x, y <= n ; x ne y ) -- the numbers of the cities that are connected by this road. It is guaranteed that from every city you can reach any other, moving only by the roads. The sum of the values of n for all test cases in the input does not exceed 3 cdot 10^5 . For each test case print Yes or No (in any case, upper or lower), depending on whether the answer exists or not. If the answer exists, then print an integer m ( 1 <= m <= n ) -- the number of cities in the found subset. Then print m different numbers from 1 to n -- the numbers of the cities in the found subset. City numbers can be printed in any order. If there are several answers, print any of them. '...

Tutorials

Kotlin Heroes: Episode 3 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
72025197 Ebrahim_Emon E Feb. 28, 2020, 9:10 a.m. OK Kotlin TESTS 69 248 23040000
71979411 Egor E Feb. 27, 2020, 2:12 p.m. OK Kotlin TESTS 69 264 23040000
71979463 eatmore E Feb. 27, 2020, 2:13 p.m. OK Kotlin TESTS 69 467 18534400
72071989 Spheniscine E Feb. 29, 2020, 3:03 a.m. OK Kotlin TESTS 69 499 44748800
71984985 firiexp E Feb. 27, 2020, 3:20 p.m. OK Kotlin TESTS 69 546 104652800
71988086 okwedook E Feb. 27, 2020, 4:02 p.m. OK Kotlin TESTS 69 670 54579200
71982223 dalt E Feb. 27, 2020, 2:44 p.m. OK Kotlin TESTS 69 717 120422400
72021873 icebound E Feb. 28, 2020, 7:56 a.m. OK Kotlin TESTS 69 732 83353600
72022367 icebound E Feb. 28, 2020, 8:07 a.m. OK Kotlin TESTS 69 732 84275200
71980372 Fortin E Feb. 27, 2020, 2:23 p.m. OK Kotlin TESTS 69 748 35737600

remove filters

Back to search problems