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'You are given a rectangular grid with n rows and m columns. n and m are divisible by 4 . Some of the cells are already colored black or white. It is guaranteed that no two colored cells share a corner or an edge. Color the remaining cells in a way that both the black and the white cells becomes orthogonally connected or determine that it is impossible. Consider a graph, where the black cells are the nodes. Two nodes are adjacent if the corresponding cells share an edge. If the described graph is connected, the black cells are orthogonally connected. Same for white cells. The input consists of multiple test cases. The first line of the input contains a single integer t ( 1 <= t <= 4000 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains two integers n , m ( 8 <= n, m <= 500 , n and m are divisible by 4 ) -- the number of rows and columns. Each of the next n lines contains m characters. Each character is either 'B ', 'W ' or '. ', representing black, white or empty cell respectively. Two colored (black or white) cell does not share a corner or an edge. It is guaranteed that the sum of n cdot m over all test cases does not exceed 250 ,000 . For each testcase print "NO" if there is no solution, otherwise print "YES" and a grid with the same format. If there are multiple solutions, you can print any. Solution for test case 1: Test case 2: one can see that the black and the white part can 't be connected in the same time. So the answer is "NO". '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
154250600 |
gzchenben |
F |
April 21, 2022, 6:11 a.m. |
OK |
GNU C++14 |
TESTS |
381 |
109 |
4096000 |
|
3500 |
154644598 |
peti1234 |
F |
April 23, 2022, 10:21 a.m. |
OK |
GNU C++17 |
TESTS |
381 |
93 |
4096000 |
|
3500 |
154257754 |
Not_Determinedd |
F |
April 21, 2022, 8:21 a.m. |
OK |
GNU C++17 |
TESTS |
381 |
93 |
4096000 |
|
3500 |
154256094 |
Meredov |
F |
April 21, 2022, 7:53 a.m. |
OK |
GNU C++17 |
TESTS |
381 |
93 |
4096000 |
|
3500 |
154249881 |
AbdufattohBarotov |
F |
April 21, 2022, 5:56 a.m. |
OK |
GNU C++17 |
TESTS |
381 |
93 |
4096000 |
|
3500 |
154232916 |
huikang |
F |
April 20, 2022, 10:19 p.m. |
OK |
GNU C++17 |
TESTS |
381 |
93 |
4096000 |
|
3500 |
154254282 |
Sakib1092 |
F |
April 21, 2022, 7:20 a.m. |
OK |
GNU C++17 |
TESTS |
381 |
108 |
4096000 |
|
3500 |
154820321 |
seccse |
F |
April 24, 2022, 7:20 a.m. |
OK |
GNU C++17 |
TESTS |
381 |
109 |
4096000 |
|
3500 |
154606747 |
mohamedelsadek |
F |
April 23, 2022, 1:06 a.m. |
OK |
GNU C++17 |
TESTS |
381 |
109 |
4096000 |
|
3500 |
154236071 |
VIRUSGAMING |
F |
April 21, 2022, 12:15 a.m. |
OK |
GNU C++17 |
TESTS |
381 |
109 |
4096000 |
|
3500 |
154879966 |
TemurSempai |
F |
April 24, 2022, 5:58 p.m. |
OK |
GNU C++20 (64) |
TESTS |
381 |
78 |
4096000 |
|
3500 |
154642121 |
zhenja |
F |
April 23, 2022, 9:52 a.m. |
OK |
GNU C++20 (64) |
TESTS |
381 |
78 |
4096000 |
|
3500 |
154579947 |
GoLobby1x1solomidSF |
F |
April 22, 2022, 4:56 p.m. |
OK |
GNU C++20 (64) |
TESTS |
381 |
78 |
4096000 |
|
3500 |
154484828 |
NazhmudinovTRLI |
F |
April 22, 2022, 10:11 a.m. |
OK |
GNU C++20 (64) |
TESTS |
381 |
78 |
4096000 |
|
3500 |
154286477 |
anonymous_777 |
F |
April 21, 2022, 2:31 p.m. |
OK |
GNU C++20 (64) |
TESTS |
381 |
78 |
4096000 |
|
3500 |
154258547 |
IVANAFANBEL |
F |
April 21, 2022, 8:34 a.m. |
OK |
GNU C++20 (64) |
TESTS |
381 |
78 |
4096000 |
|
3500 |
remove filters
Back to search problems