Kotlin Heroes: Episode 2

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
1211 Kotlin Heroes: Episode 2 FINISHED False 9000 169572287 Sept. 7, 2019, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 46 ) H Road Repair in Treeland PROGRAMMING *special binary search dp trees 3000

B'There are n cities and n-1 two-way roads in Treeland. Each road connects a pair of different cities. From any city you can drive to any other, moving only along the roads. Cities are numbered from 1 to n . Yes, of course, you recognized an undirected tree in this description. The government plans to repair all the roads. Each road will be repaired by some private company. In total, the country has 10^6 private companies that are numbered from 1 to 10^6 . It is possible that some companies will not repair roads at all, and some will repair many roads. To simplify the control over the work of private companies, the following restriction was introduced: for each city, we calculate the number of different companies that repair roads that have this city at one end. This number for each city should not exceed 2 . In other words, for each city, there should be no more than two different companies that repair roads related to this city. The National Anti-Corruption Committee of Treeland raises concerns that all (or almost all) of the work will go to one private company. For this reason, the committee requires that roads be distributed among companies in such a way as to minimize the value of r . For each company, we calculate the number of roads assigned to it, the maximum among all companies is called the number r . Help the government find such a way to distribute all roads among companies in the required way. The first line contains an integer t ( 1 <= t <= 1000 ) -- the number of input cases in the input. Next, the input cases themselves are given. The first line of each test case set contains an integer n ( 2 <= n <= 3000 ) -- the number of cities in Treeland. Next, in the n-1 lines the roads are written: a line contains two integers x_i , y_i ( 1 <= x_i, y_i <= n ), indicating that the i -th road connects the cities x_i and y_i . It is guar'...

Tutorials

Kotlin Heroes: Episode 2 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
60230723 eatmore H Sept. 7, 2019, 4:23 p.m. OK Kotlin TESTS 31 233 0 3000
60926983 112 H Sept. 20, 2019, 12:34 p.m. OK Kotlin TESTS 31 326 19353600 3000
60243933 vadimmm H Sept. 8, 2019, 12:11 a.m. OK Kotlin TESTS 31 327 19353600 3000
60366358 knightL H Sept. 10, 2019, 9:11 p.m. OK Kotlin TESTS 31 389 44851200 3000
63194326 adal_nu H Oct. 22, 2019, 6:05 p.m. OK Kotlin TESTS 31 405 9830400 3000
60228910 tourist H Sept. 7, 2019, 3:52 p.m. OK Kotlin TESTS 31 420 9728000 3000
60229462 MiFaFaOvO H Sept. 7, 2019, 4:01 p.m. OK Kotlin TESTS 31 467 1638400 3000
60230298 Benq H Sept. 7, 2019, 4:15 p.m. OK Kotlin TESTS 31 1076 94412800 3000
62614929 serega.ktl H Oct. 15, 2019, 11:09 a.m. OK Kotlin TESTS 31 2527 225075200 3000
60231511 ecnerwala H Sept. 7, 2019, 4:38 p.m. OK Kotlin TESTS 31 2542 225075200 3000

remove filters

Back to search problems