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 and m two-way roads in Berland, each road connecting two distinct cities. Recently the Berland government has made a tough decision to transfer ownership of the roads to private companies. In total, there are 100500 private companies in Berland, numbered by integers from 1 to 100500 . After the privatization, every road should belong to exactly one company. The anti-monopoly committee demands that after the privatization each company can own at most two roads. The urbanists of Berland also stated their opinion: each city should be adjacent to the roads owned by at most k companies. Help the government to distribute the roads between the companies so that both conditions are satisfied. That is, each company gets at most two roads, and each city has roads of at most k distinct companies adjacent to it. Input contains one or several test cases. The first line contains an integer t ( 1 <= t <= 300 ) -- the number of test cases in the input. Solve test cases separately, test cases are completely independent and do not affect each other. The following lines describe the test cases. Each case starts with a line consisting of three space-separated integers n , m and k ( 2 <= n <= 600 , 1 <= m <= 600 , 1 <= k <= n - 1 ) -- the number of cities, the number of roads and the maximum diversity of the roads adjacent to a city. Then m lines follow, each having a pair of space-separated integers a_i , b_i ( 1 <= a_i, b_i <= n ; a_i ne b_i ). It means that the i -th road connects cities a_i and b_i . All roads are two-way. There is at most one road between a pair of the cities. The sum of n values for all test cases doesn't exceed 600 . The sum of m values for all test cases doesn't exceed 600 . Print t lines: the i -th line should contain the answer for the i -th test case. For a t"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
52333237 |
suncongbo |
I |
April 5, 2019, 6:36 a.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
0 |
|
2600 |
44729833 |
chenxun |
I |
Oct. 23, 2018, 9:55 a.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
0 |
|
2600 |
50313786 |
klfly |
I |
Feb. 22, 2019, 11:14 a.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
102400 |
|
2600 |
50313687 |
klfly |
I |
Feb. 22, 2019, 11:11 a.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
102400 |
|
2600 |
49499262 |
vjudge4 |
I |
Feb. 5, 2019, 2:22 p.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
102400 |
|
2600 |
48213093 |
cyn2006 |
I |
Jan. 11, 2019, 1:10 p.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
102400 |
|
2600 |
46249126 |
_aether |
I |
Nov. 26, 2018, 1:14 p.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
102400 |
|
2600 |
46006901 |
krijgertje |
I |
Nov. 20, 2018, 5:29 p.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
102400 |
|
2600 |
45344482 |
OmarHashim |
I |
Nov. 6, 2018, 1:22 a.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
102400 |
|
2600 |
44735299 |
dasinlsb |
I |
Oct. 23, 2018, 12:34 p.m. |
OK |
GNU C++11 |
TESTS |
108 |
31 |
102400 |
|
2600 |
46351027 |
felkost |
I |
Nov. 28, 2018, 9:45 p.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
102400 |
|
2600 |
45394933 |
GabrielPessoa |
I |
Nov. 7, 2018, 3:11 a.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
102400 |
|
2600 |
45172749 |
Qinz sfiction |
I |
Nov. 1, 2018, 1:26 p.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
102400 |
|
2600 |
44598683 |
calabash_boy |
I |
Oct. 20, 2018, 1:21 p.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
102400 |
|
2600 |
49936022 |
bestFy |
I |
Feb. 15, 2019, 7:19 a.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
204800 |
|
2600 |
45578808 |
vjudge4 |
I |
Nov. 12, 2018, 1 a.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
204800 |
|
2600 |
44940807 |
iqqsoszs |
I |
Oct. 27, 2018, 7:42 a.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
204800 |
|
2600 |
44822353 |
shaochengxi |
I |
Oct. 25, 2018, 3:28 a.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
204800 |
|
2600 |
44728898 |
Zayin |
I |
Oct. 23, 2018, 9:25 a.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
204800 |
|
2600 |
44592210 |
RNS3 RNS_JKS RNS_KSB |
I |
Oct. 20, 2018, 11:27 a.m. |
OK |
GNU C++14 |
TESTS |
108 |
31 |
204800 |
|
2600 |
46773962 |
vremapriklucenij16 |
I |
Dec. 8, 2018, 6:47 p.m. |
OK |
GNU C++17 |
TESTS |
108 |
30 |
307200 |
|
2600 |
44655470 |
bomo JKS_PL mateusz |
I |
Oct. 21, 2018, 12:53 p.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
204800 |
|
2600 |
52634018 |
nikgaevoy |
I |
April 12, 2019, 8:53 a.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
307200 |
|
2600 |
51069182 |
black_horse2014 |
I |
March 9, 2019, 7:04 a.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
307200 |
|
2600 |
46776036 |
vremapriklucenij16 |
I |
Dec. 8, 2018, 8:27 p.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
307200 |
|
2600 |
46201135 |
anpans |
I |
Nov. 25, 2018, 11:27 a.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
307200 |
|
2600 |
46104853 |
filippos |
I |
Nov. 23, 2018, 8:29 a.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
307200 |
|
2600 |
46104793 |
filippos |
I |
Nov. 23, 2018, 8:27 a.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
307200 |
|
2600 |
46011514 |
Nebuchadnezzar |
I |
Nov. 20, 2018, 8:51 p.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
307200 |
|
2600 |
44770933 |
theodor.moroianu Rpd-Strike |
I |
Oct. 24, 2018, 12:20 p.m. |
OK |
GNU C++17 |
TESTS |
108 |
31 |
307200 |
|
2600 |
44696663 |
hulk_man |
I |
Oct. 22, 2018, 1:14 p.m. |
OK |
Java 8 |
TESTS |
108 |
124 |
0 |
|
2600 |
46717455 |
felfer |
I |
Dec. 7, 2018, 11:58 a.m. |
OK |
MS C++ |
TESTS |
108 |
46 |
102400 |
|
2600 |
44577759 |
|
I |
Oct. 20, 2018, 7:34 a.m. |
OK |
Unknown |
TESTS |
0 |
0 |
0 |
|
2600 |
44577642 |
|
I |
Oct. 20, 2018, 7:33 a.m. |
OK |
Unknown |
TESTS |
0 |
0 |
0 |
|
2600 |
44577566 |
|
I |
Oct. 20, 2018, 7:33 a.m. |
OK |
Unknown |
TESTS |
0 |
0 |
0 |
|
2600 |
remove filters
Back to search problems