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'Berland has n cities, some of which are connected by roads. Each road is bidirectional, connects two distinct cities and for each two cities there 's at most one road connecting them. The president of Berland decided to split country into r states in such a way that each city will belong to exactly one of these r states. After this split each road will connect either cities of the same state or cities of the different states. Let 's call roads that connect two cities of the same state "inner" roads. The president doesn 't like odd people, odd cities and odd numbers, so he wants this split to be done in such a way that each city would have even number of "inner" roads connected to it. Please help president to find smallest possible r for which such a split exists. The input contains one or several test cases. The first input line contains a single integer number t -- number of test cases. Then, t test cases follow. Solve test cases separately, test cases are completely independent and do not affect each other. Then t blocks of input data follow. Each block starts from empty line which separates it from the remaining input data. The second line of each block contains two space-separated integers n , m ( 1 <= n <= 2000 , 0 <= m <= 10000 ) -- the number of cities and number of roads in the Berland. Each of the next m lines contains two space-separated integers -- x_i , y_i ( 1 <= x_i, y_i <= n ; x_i ne y_i ), which denotes that the i -th road connects cities x_i and y_i . Each pair of cities are connected by at most one road. Sum of values n across all test cases doesn 't exceed 2000 . Sum of values m across all test cases doesn 't exceed 10000 . For each test case first print a line containing a single integer r -- smallest possible number of states for which required split is possible. In the next line print n space'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
45083469 |
function348 |
L |
Oct. 30, 2018, 5:27 a.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
512000 |
|
2800 |
44723742 |
samjia2000 |
L |
Oct. 23, 2018, 6:58 a.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
716800 |
|
2800 |
44829956 |
lawfung |
L |
Oct. 25, 2018, 7:58 a.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
819200 |
|
2800 |
44740036 |
vjudge1 |
L |
Oct. 23, 2018, 2:19 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
819200 |
|
2800 |
44620940 |
251 |
L |
Oct. 21, 2018, 6:18 a.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
819200 |
|
2800 |
44595116 |
wxh010910 sagitta_luminis jiangIy |
L |
Oct. 20, 2018, 12:17 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
819200 |
|
2800 |
44594717 |
ljt12138 tqyaaaaaaaang __stdcall |
L |
Oct. 20, 2018, 12:11 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
819200 |
|
2800 |
46935855 |
Itst |
L |
Dec. 12, 2018, 1:50 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
62 |
512000 |
|
2800 |
44594595 |
Um_nik |
L |
Oct. 20, 2018, 12:09 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
62 |
614400 |
|
2800 |
45087000 |
zhouyuyang |
L |
Oct. 30, 2018, 7:55 a.m. |
OK |
GNU C++11 |
TESTS |
63 |
62 |
819200 |
|
2800 |
45285377 |
Dreamchaser101 |
L |
Nov. 4, 2018, 4:17 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
46 |
512000 |
|
2800 |
44761394 |
jhdjames37 |
L |
Oct. 24, 2018, 7:22 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
46 |
512000 |
|
2800 |
44582477 |
dario2994 Giada |
L |
Oct. 20, 2018, 8:48 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
46 |
716800 |
|
2800 |
44936264 |
kjp4155 ainta molamola. |
L |
Oct. 27, 2018, 5:33 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
46 |
819200 |
|
2800 |
45985538 |
Kuroni |
L |
Nov. 20, 2018, 6:13 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
61 |
512000 |
|
2800 |
44673739 |
ecnerwala xyz111 ksun48 |
L |
Oct. 22, 2018, 12:52 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
61 |
921600 |
|
2800 |
44617976 |
zscoder |
L |
Oct. 21, 2018, 3:47 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
61 |
921600 |
|
2800 |
44830184 |
waynetuinfor |
L |
Oct. 25, 2018, 8:05 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
61 |
1024000 |
|
2800 |
44830163 |
waynetuinfor |
L |
Oct. 25, 2018, 8:05 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
61 |
1024000 |
|
2800 |
44722470 |
iaojnh |
L |
Oct. 23, 2018, 6:09 a.m. |
OK |
GNU C++14 |
TESTS |
63 |
61 |
4608000 |
|
2800 |
45916982 |
teapotd |
L |
Nov. 18, 2018, 2:28 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
46 |
512000 |
|
2800 |
44596258 |
davidlee1999WTK liangjs linkct |
L |
Oct. 20, 2018, 12:36 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
46 |
1024000 |
|
2800 |
44742378 |
.o. alex9801 ko_osaga |
L |
Oct. 23, 2018, 3:14 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
46 |
1228800 |
|
2800 |
44657441 |
vjudge4 |
L |
Oct. 21, 2018, 1:37 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
61 |
819200 |
|
2800 |
44656882 |
lucyanna2018 |
L |
Oct. 21, 2018, 1:24 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
61 |
1228800 |
|
2800 |
45915657 |
teapotd |
L |
Nov. 18, 2018, 1:52 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
62 |
512000 |
|
2800 |
46097866 |
Benq |
L |
Nov. 23, 2018, 2:35 a.m. |
OK |
GNU C++17 |
TESTS |
63 |
62 |
1024000 |
|
2800 |
45188336 |
ggoh |
L |
Nov. 1, 2018, 10:32 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
62 |
1228800 |
|
2800 |
44665578 |
tabasz |
L |
Oct. 21, 2018, 5:41 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
77 |
1536000 |
|
2800 |
44758239 |
RedTea |
L |
Oct. 24, 2018, 5:05 a.m. |
OK |
GNU C++17 |
TESTS |
63 |
78 |
1126400 |
|
2800 |
remove filters
Back to search problems