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"Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. The only difference between the two versions is the operation. Alex has a grid with n rows and m columns consisting of '.' and '#' characters. A set of '#' cells forms a connected component if from any cell in this set, it is possible to reach any other cell in this set by only moving to another cell in the set that shares a common side. The size of a connected component is the number of cells in the set. In one operation, Alex selects any row r ( 1 <= r <= n ) or any column c ( 1 <= c <= m ), then sets every cell in row r or column c to be '#'. Help Alex find the maximum possible size of the largest connected component of '#' cells that he can achieve after performing the operation at most once. The first line of the input contains a single integer t ( 1 <= q t <= q 10^4 ) -- the number of test cases. The first line of each test case contains two integers n and m ( 1 <= n cdot m <= 10^6 ) -- the number of rows and columns of the grid. The next n lines each contain m characters. Each character is either '.' or '#'. It is guaranteed that the sum of n cdot m over all test cases does not exceed 10^6 . For each test case, output a single integer -- the maximum possible size of a connected component of '#' cells that Alex can achieve. In the second test case, it is optimal for Alex to set all cells in column 2 to be '#'. Doing so will lead to the largest connected component of '#' having a size of 6 . In the third test case, it is optimal for Alex to set all cells in row 2 to be '#'. Doing so will lead to the largest connected component of '#' having a size of 9 . In the fourth test case, it is optimal for Alex to set all cells in row 4 to be '#'. Doing so will lead to the largest connected component of '#' having a"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
265402657 |
ayush_r28 |
H1 |
June 11, 2024, 7:13 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
546 |
13824000 |
|
|
265406860 |
kush122 |
H1 |
June 11, 2024, 8:03 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
561 |
13721600 |
|
|
265406760 |
kush122 |
H1 |
June 11, 2024, 8:01 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
655 |
33996800 |
|
|
265435559 |
jat_sunil.. |
H1 |
June 12, 2024, 4:33 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
671 |
41164800 |
|
|
265400131 |
figdan |
H1 |
June 11, 2024, 6:47 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
686 |
58777600 |
|
|
265400292 |
12_Utpal |
H1 |
June 11, 2024, 6:49 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
734 |
24780800 |
|
|
265444005 |
Ruthvik2835 |
H1 |
June 12, 2024, 6:01 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
749 |
36864000 |
|
|
265418525 |
chaoslong |
H1 |
June 11, 2024, 11:48 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
796 |
119500800 |
|
|
265429234 |
Karan741187 |
H1 |
June 12, 2024, 3:13 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
952 |
70348800 |
|
|
265435937 |
raviteja3333 |
H1 |
June 12, 2024, 4:37 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
1124 |
177254400 |
|
|
265430068 |
NotFound |
H1 |
June 12, 2024, 3:25 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
156 |
13312000 |
|
|
265439072 |
Zbc |
H1 |
June 12, 2024, 5:14 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
156 |
32358400 |
|
|
265419833 |
Keftiu |
H1 |
June 12, 2024, 12:22 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
186 |
32358400 |
|
|
265391268 |
naman22 |
H1 |
June 11, 2024, 5:38 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
186 |
32358400 |
|
|
265403009 |
DvX5 |
H1 |
June 11, 2024, 7:17 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
187 |
29286400 |
|
|
265413140 |
phoenix6017 |
H1 |
June 11, 2024, 9:33 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
202 |
32460800 |
|
|
265404470 |
ardekarsanket |
H1 |
June 11, 2024, 7:34 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
202 |
70860800 |
|
|
265395628 |
Actium |
H1 |
June 11, 2024, 6:06 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
202 |
130867200 |
|
|
265441901 |
ABASD |
H1 |
June 12, 2024, 5:41 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
217 |
37068800 |
|
|
265423343 |
kayn.cm |
H1 |
June 12, 2024, 1:44 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
218 |
44441600 |
|
|
265436827 |
nehcoah |
H1 |
June 12, 2024, 4:49 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
124 |
40448000 |
|
|
265422726 |
YakultGo |
H1 |
June 12, 2024, 1:30 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
124 |
40448000 |
|
|
265431372 |
hitoriray |
H1 |
June 12, 2024, 3:41 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
125 |
52428800 |
|
|
265426565 |
daoqi |
H1 |
June 12, 2024, 2:37 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
125 |
52428800 |
|
|
265406722 |
Nullptrs |
H1 |
June 11, 2024, 8:01 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
140 |
40345600 |
|
|
265442993 |
LNian |
H1 |
June 12, 2024, 5:52 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
140 |
40448000 |
|
|
265440039 |
Talent_Camellia |
H1 |
June 12, 2024, 5:24 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
140 |
40448000 |
|
|
265432726 |
wyf0722 |
H1 |
June 12, 2024, 3:59 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
140 |
40448000 |
|
|
265426784 |
SpongeBob_ |
H1 |
June 12, 2024, 2:40 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
140 |
40448000 |
|
|
265441757 |
kukudestar |
H1 |
June 12, 2024, 5:40 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
140 |
92467200 |
|
|
265443550 |
xylu |
H1 |
June 12, 2024, 5:56 a.m. |
OK |
Go |
TESTS |
23 |
156 |
29491200 |
|
|
265443713 |
xylu |
H1 |
June 12, 2024, 5:58 a.m. |
OK |
Go |
TESTS |
23 |
358 |
52736000 |
|
|
265436438 |
_wisdom |
H1 |
June 12, 2024, 4:44 a.m. |
OK |
Java 21 |
TESTS |
23 |
968 |
91238400 |
|
|
265404503 |
WORTH |
H1 |
June 11, 2024, 7:34 p.m. |
OK |
Java 21 |
TESTS |
23 |
1062 |
84992000 |
|
|
265404399 |
WORTH |
H1 |
June 11, 2024, 7:33 p.m. |
OK |
Java 21 |
TESTS |
23 |
1092 |
83763200 |
|
|
265435975 |
_wisdom |
H1 |
June 12, 2024, 4:38 a.m. |
OK |
Java 21 |
TESTS |
23 |
1124 |
90828800 |
|
|
265433743 |
Bandwidth |
H1 |
June 12, 2024, 4:11 a.m. |
OK |
Java 21 |
TESTS |
23 |
1249 |
82432000 |
|
|
265435560 |
_wisdom |
H1 |
June 12, 2024, 4:33 a.m. |
OK |
Java 21 |
TESTS |
23 |
1280 |
98611200 |
|
|
265412325 |
bluebeetle |
H1 |
June 11, 2024, 9:17 p.m. |
OK |
Java 21 |
TESTS |
23 |
1281 |
81100800 |
|
|
265403795 |
WORTH |
H1 |
June 11, 2024, 7:26 p.m. |
OK |
Java 21 |
TESTS |
23 |
1312 |
161280000 |
|
|
265418049 |
Eslam_Ahmed |
H1 |
June 11, 2024, 11:35 p.m. |
OK |
Java 21 |
TESTS |
23 |
1343 |
134348800 |
|
|
265403893 |
WORTH |
H1 |
June 11, 2024, 7:27 p.m. |
OK |
Java 21 |
TESTS |
23 |
1796 |
158105600 |
|
|
265411192 |
CipherSphinx_Raj |
H1 |
June 11, 2024, 8:57 p.m. |
OK |
Java 8 |
TESTS |
23 |
1140 |
166195200 |
|
|
265422681 |
faresbadr316 |
H1 |
June 12, 2024, 1:29 a.m. |
OK |
Java 8 |
TESTS |
23 |
1218 |
158617600 |
|
|
265412521 |
Sumitsingh7 |
H1 |
June 11, 2024, 9:20 p.m. |
OK |
Java 8 |
TESTS |
23 |
1234 |
95641600 |
|
|
265422809 |
faresbadr316 |
H1 |
June 12, 2024, 1:33 a.m. |
OK |
Java 8 |
TESTS |
23 |
1343 |
245760000 |
|
|
265424646 |
Yousef_Badr |
H1 |
June 12, 2024, 2:08 a.m. |
OK |
Java 8 |
TESTS |
23 |
1405 |
245555200 |
|
|
265407589 |
RahulAhuja2901 |
H1 |
June 11, 2024, 8:11 p.m. |
OK |
Java 8 |
TESTS |
23 |
1530 |
100659200 |
|
|
265434053 |
achyut88 |
H1 |
June 12, 2024, 4:15 a.m. |
OK |
Java 8 |
TESTS |
23 |
1608 |
101888000 |
|
|
265441358 |
xyktyjayket |
H1 |
June 12, 2024, 5:36 a.m. |
OK |
PyPy 3 |
TESTS |
23 |
1249 |
58880000 |
|
|
265435687 |
min_worked |
H1 |
June 12, 2024, 4:34 a.m. |
OK |
PyPy 3 |
TESTS |
23 |
1686 |
157286400 |
|
|
265437169 |
gardengnome |
H1 |
June 12, 2024, 4:53 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
483 |
78028800 |
|
|
265396906 |
hohohohohohong |
H1 |
June 11, 2024, 6:16 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
514 |
78540800 |
|
|
265434884 |
yuhangliu1224 |
H1 |
June 12, 2024, 4:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
624 |
106086400 |
|
|
265395882 |
ow3nLLL |
H1 |
June 11, 2024, 6:07 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
718 |
68505600 |
|
|
265396064 |
ow3nLLL |
H1 |
June 11, 2024, 6:09 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
890 |
68608000 |
|
|
265403085 |
abhaumik24 |
H1 |
June 11, 2024, 7:18 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
936 |
162201600 |
|
|
265425059 |
yefei162 |
H1 |
June 12, 2024, 2:15 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
1124 |
171622400 |
|
|
265400745 |
hsr_69 |
H1 |
June 11, 2024, 6:53 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
1249 |
209203200 |
|
|
265400408 |
hsr_69 |
H1 |
June 11, 2024, 6:50 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
1281 |
209203200 |
|
|
265393807 |
kibr |
H1 |
June 11, 2024, 5:51 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
1328 |
196608000 |
|
|
remove filters
Back to search problems