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 matrix, consisting of n rows and m columns. The j -th cell of the i -th row contains an integer a_{ij} . First, you have to color each row of the matrix either red or blue in such a way that at least one row is colored red and at least one row is colored blue. Then, you have to choose an integer k ( 1 <= k < m ) and cut the colored matrix in such a way that the first k columns become a separate matrix (the left matrix) and the last m-k columns become a separate matrix (the right matrix). The coloring and the cut are called perfect if two properties hold: Find any perfect coloring and cut, or report that there are none. The first line contains a single integer t ( 1 <= t <= 1000 ) -- the number of testcases. Then the descriptions of t testcases follow. The first line of each testcase contains two integers n and m ( 2 <= n, m <= 5 cdot 10^5 ; n cdot m <= 10^6 ) -- the number of rows and the number of columns in the matrix, respectively. The i -th of the next n lines contains m integers a_{i1}, a_{i2}, ... , a_{im} ( 1 <= a_{ij} <= 10^6 ). The sum of n cdot m over all testcases doesn 't exceed 10^6 . For each testcase print an answer. If there are no perfect colorings and cuts in the matrix, then print "NO". Otherwise, first, print "YES". Then a string, consisting of n characters: the i -th character should be 'R ' if the i -th row is colored red and 'B ' if it 's colored blue. The string should contain at least one 'R ' and at least one 'B '. Finally, print an integer k ( 1 <= k < m ) -- the number of columns from the left that are cut. The coloring and the cut for the first testcase: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
133517132 |
rainboy |
D |
Oct. 29, 2021, 4:26 p.m. |
OK |
GNU C11 |
TESTS |
40 |
280 |
26726400 |
|
|
133530626 |
Shinkiw |
D |
Oct. 29, 2021, 5:51 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
342 |
31129600 |
|
|
133521596 |
2018gtyz10 |
D |
Oct. 29, 2021, 4:39 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
343 |
30105600 |
|
|
133546864 |
Alireza |
D |
Oct. 29, 2021, 9:51 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
389 |
38604800 |
|
|
133549816 |
oceeff |
D |
Oct. 29, 2021, 11:28 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
420 |
71168000 |
|
|
133524526 |
Larry0101 |
D |
Oct. 29, 2021, 4:58 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
468 |
28672000 |
|
|
133523206 |
Birjik |
D |
Oct. 29, 2021, 4:49 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
483 |
91545600 |
|
|
133531770 |
mishras839392 |
D |
Oct. 29, 2021, 6:01 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
514 |
55910400 |
|
|
133559353 |
shejunda |
D |
Oct. 30, 2021, 3:32 a.m. |
OK |
GNU C++14 |
TESTS |
40 |
545 |
91545600 |
|
|
133557127 |
FreeSin2000 |
D |
Oct. 30, 2021, 2:45 a.m. |
OK |
GNU C++14 |
TESTS |
40 |
561 |
110796800 |
|
|
133513487 |
adam_rajsky |
D |
Oct. 29, 2021, 4:16 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
576 |
82124800 |
|
|
133554186 |
zhouzhi |
D |
Oct. 30, 2021, 1:38 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
311 |
33689600 |
|
|
133523759 |
catsareliquid |
D |
Oct. 29, 2021, 4:52 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
343 |
58163200 |
|
|
133525031 |
Kniaz |
D |
Oct. 29, 2021, 5:02 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
420 |
72396800 |
|
|
133550557 |
kurtsaeed |
D |
Oct. 29, 2021, 11:50 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
421 |
87552000 |
|
|
133517651 |
woolims |
D |
Oct. 29, 2021, 4:27 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
436 |
58470400 |
|
|
133523505 |
Komeiji_Green |
D |
Oct. 29, 2021, 4:51 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
452 |
101785600 |
|
|
133513507 |
bnkalya1502 |
D |
Oct. 29, 2021, 4:16 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
483 |
32563200 |
|
|
133566432 |
boltUsain |
D |
Oct. 30, 2021, 5:34 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
483 |
66355200 |
|
|
133517847 |
D.A_TAU |
D |
Oct. 29, 2021, 4:28 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
498 |
29388800 |
|
|
133521654 |
bktl4ever |
D |
Oct. 29, 2021, 4:40 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
529 |
92467200 |
|
|
133559218 |
Turkey |
D |
Oct. 30, 2021, 3:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
233 |
58368000 |
|
|
133524487 |
errorgorn |
D |
Oct. 29, 2021, 4:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
265 |
59289600 |
|
|
133538008 |
mukim |
D |
Oct. 29, 2021, 7:14 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
280 |
51712000 |
|
|
133519799 |
Yuu |
D |
Oct. 29, 2021, 4:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
405 |
69939200 |
|
|
133522626 |
cuiaoxiang |
D |
Oct. 29, 2021, 4:45 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
436 |
116428800 |
|
|
133547195 |
SampsonYW |
D |
Oct. 29, 2021, 9:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
436 |
130252800 |
|
|
133547170 |
sorry_sorry_thebighead |
D |
Oct. 29, 2021, 9:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
436 |
130252800 |
|
|
133513037 |
SevenDawns |
D |
Oct. 29, 2021, 4:15 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
451 |
79462400 |
|
|
133541057 |
darkcoder123 |
D |
Oct. 29, 2021, 7:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
452 |
52838400 |
|
|
133559258 |
dqk |
D |
Oct. 30, 2021, 3:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
467 |
88064000 |
|
|
133524482 |
yzy1 |
D |
Oct. 29, 2021, 4:58 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
373 |
70144000 |
|
|
133522144 |
Gretskiy_oreshek |
D |
Oct. 29, 2021, 4:42 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
420 |
98304000 |
|
|
133513887 |
Estinka |
D |
Oct. 29, 2021, 4:17 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
452 |
106188800 |
|
|
133557297 |
wisest |
D |
Oct. 30, 2021, 2:49 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
467 |
112230400 |
|
|
133546393 |
toureiffel-2018 |
D |
Oct. 29, 2021, 9:39 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
468 |
112230400 |
|
|
133517608 |
Radhe_Loves_To_Eat |
D |
Oct. 29, 2021, 4:27 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
498 |
156876800 |
|
|
133516757 |
pill |
D |
Oct. 29, 2021, 4:25 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
499 |
99840000 |
|
|
133530732 |
AGRU |
D |
Oct. 29, 2021, 5:52 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
514 |
156876800 |
|
|
133564655 |
follow_diana_please |
D |
Oct. 30, 2021, 5:10 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
545 |
104140800 |
|
|
133559993 |
kieusontungcva |
D |
Oct. 30, 2021, 3:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
560 |
157081600 |
|
|
133522497 |
bobib |
D |
Oct. 29, 2021, 4:44 p.m. |
OK |
Java 11 |
TESTS |
40 |
1262 |
154112000 |
|
|
133528811 |
Dukkha |
D |
Oct. 29, 2021, 5:36 p.m. |
OK |
Java 11 |
TESTS |
40 |
2667 |
157388800 |
|
|
133526772 |
pichulia |
D |
Oct. 29, 2021, 5:17 p.m. |
OK |
MS C++ 2017 |
TESTS |
40 |
2183 |
154419200 |
|
|
133524583 |
GILGAMESH |
D |
Oct. 29, 2021, 4:59 p.m. |
OK |
MS C++ 2017 |
TESTS |
40 |
3603 |
142336000 |
|
|
133552835 |
kakel_san |
D |
Oct. 30, 2021, 1:02 a.m. |
OK |
.NET Core C# |
TESTS |
40 |
1263 |
145305600 |
|
|
133515463 |
mban259 |
D |
Oct. 29, 2021, 4:22 p.m. |
OK |
.NET Core C# |
TESTS |
40 |
1325 |
166297600 |
|
|
133518659 |
Andybar |
D |
Oct. 29, 2021, 4:30 p.m. |
OK |
.NET Core C# |
TESTS |
40 |
1559 |
109875200 |
|
|
133527923 |
mkawa2 |
D |
Oct. 29, 2021, 5:29 p.m. |
OK |
PyPy 3 |
TESTS |
40 |
3540 |
185139200 |
|
|
133527634 |
nwi |
D |
Oct. 29, 2021, 5:26 p.m. |
OK |
Python 2 |
TESTS |
40 |
3853 |
76083200 |
|
|
133527262 |
nwi |
D |
Oct. 29, 2021, 5:22 p.m. |
OK |
Python 2 |
TESTS |
40 |
3946 |
87347200 |
|
|
133517042 |
Slayer_ |
D |
Oct. 29, 2021, 4:26 p.m. |
OK |
Scala |
TESTS |
40 |
1887 |
162816000 |
|
|
remove filters
Back to search problems