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 is a grid, consisting of 2 rows and n columns. Each cell of the grid is either free or blocked. A free cell y is reachable from a free cell x if at least one of these conditions holds: A connected region is a set of free cells of the grid such that all cells in it are reachable from one another, but adding any other free cell to the set violates this rule. For example, consider the following layout, where white cells are free, and dark grey cells are blocked: There are 3 regions in it, denoted with red, green and blue color respectively: The given grid contains at most 1 connected region. Your task is to calculate the number of free cells meeting the following constraint: The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The first line of each test case contains a single integer n ( 1 <= n <= 2 cdot 10^5 ) -- the number of columns. The i -th of the next two lines contains a description of the i -th row of the grid -- the string s_i , consisting of n characters. Each character is either . (denoting a free cell) or x (denoting a blocked cell). Additional constraint on the input: For each test case, print a single integer -- the number of cells such that the number of connected regions becomes 3 if this cell is blocked. In the first test case, if the cell (1, 3) is blocked, the number of connected regions becomes 3 (as shown in the picture from the statement). '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
273644524 |
hehehedada |
B |
July 31, 2024, 1:38 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273664199 |
letrong |
B |
July 31, 2024, 5:08 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273659119 |
UltraInstncT |
B |
July 31, 2024, 4:10 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273659062 |
Yexo_Rainbow |
B |
July 31, 2024, 4:09 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273658975 |
Yexo_Rainbow |
B |
July 31, 2024, 4:08 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273658778 |
CM_This_Year |
B |
July 31, 2024, 4:06 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273657494 |
0123456789_2024 |
B |
July 31, 2024, 3:52 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273648224 |
FangXia |
B |
July 31, 2024, 2:20 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273646778 |
Liujb |
B |
July 31, 2024, 2:04 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273646668 |
2h_xingren |
B |
July 31, 2024, 2:03 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
6 |
46 |
0 |
|
|
273664081 |
sudhanshu_21 |
B |
July 31, 2024, 5:07 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
31 |
0 |
|
|
273637614 |
negetive_iq |
B |
July 31, 2024, 12:05 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
31 |
0 |
|
|
273667130 |
XoXoHarsh |
B |
July 31, 2024, 5:38 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
46 |
0 |
|
|
273668484 |
Hanto_jar_920 |
B |
July 31, 2024, 5:51 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
46 |
0 |
|
|
273668040 |
t_a_n_m_o_y |
B |
July 31, 2024, 5:47 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
46 |
0 |
|
|
273668029 |
alb_in_004 |
B |
July 31, 2024, 5:47 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
46 |
0 |
|
|
273668016 |
abg_001 |
B |
July 31, 2024, 5:47 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
46 |
0 |
|
|
273667443 |
Logistic_18 |
B |
July 31, 2024, 5:41 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
46 |
0 |
|
|
273667332 |
satyji08 |
B |
July 31, 2024, 5:40 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
46 |
0 |
|
|
273667056 |
Chankya123 |
B |
July 31, 2024, 5:37 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
6 |
46 |
0 |
|
|
273603234 |
Ashish_Jha_ |
B |
July 30, 2024, 5:21 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273663708 |
ayush.604 |
B |
July 31, 2024, 5:02 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273649787 |
akshay402 |
B |
July 31, 2024, 2:36 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273640478 |
Maikyou |
B |
July 31, 2024, 12:38 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273626738 |
Pegimon |
B |
July 30, 2024, 8:32 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273622774 |
HAJER_22 |
B |
July 30, 2024, 7:43 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273610965 |
Ahmed_El_Gendy |
B |
July 30, 2024, 6:05 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273607807 |
Ebrahiim |
B |
July 30, 2024, 5:47 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273603325 |
dwj601 |
B |
July 30, 2024, 5:22 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273601182 |
Ryuga_ |
B |
July 30, 2024, 5:11 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
6 |
31 |
0 |
|
|
273634893 |
bluemegane |
B |
July 30, 2024, 10:59 p.m. |
OK |
C# 8 |
TESTS |
6 |
108 |
1945600 |
|
|
273602084 |
yashdbzfan |
B |
July 30, 2024, 5:15 p.m. |
OK |
GNU C11 |
TESTS |
6 |
46 |
1126400 |
|
|
273599533 |
basakdeepra |
B |
July 30, 2024, 5:03 p.m. |
OK |
GNU C11 |
TESTS |
6 |
77 |
512000 |
|
|
273609603 |
NoobCoderWT |
B |
July 30, 2024, 5:57 p.m. |
OK |
GNU C11 |
TESTS |
6 |
171 |
512000 |
|
|
273608379 |
1936557 |
B |
July 30, 2024, 5:50 p.m. |
OK |
Haskell |
TESTS |
6 |
93 |
1024000 |
|
|
273607447 |
AkshatSaxena_05 |
B |
July 30, 2024, 5:45 p.m. |
OK |
Java 21 |
TESTS |
6 |
234 |
819200 |
|
|
273644256 |
Zhanzhe_Lee |
B |
July 31, 2024, 1:35 a.m. |
OK |
Java 21 |
TESTS |
6 |
249 |
204800 |
|
|
273658584 |
Priyanshu_pandey15 |
B |
July 31, 2024, 4:04 a.m. |
OK |
Java 21 |
TESTS |
6 |
249 |
921600 |
|
|
273613932 |
dzhi |
B |
July 30, 2024, 6:25 p.m. |
OK |
Java 21 |
TESTS |
6 |
264 |
614400 |
|
|
273619848 |
LakhimpurKheri |
B |
July 30, 2024, 7:13 p.m. |
OK |
Java 21 |
TESTS |
6 |
264 |
819200 |
|
|
273667336 |
aspgarv112 |
B |
July 31, 2024, 5:40 a.m. |
OK |
Java 21 |
TESTS |
6 |
265 |
307200 |
|
|
273642701 |
flyingArpit |
B |
July 31, 2024, 1:14 a.m. |
OK |
Java 21 |
TESTS |
6 |
265 |
409600 |
|
|
273612121 |
Bhuwan_36 |
B |
July 30, 2024, 6:12 p.m. |
OK |
Java 21 |
TESTS |
6 |
265 |
409600 |
|
|
273641782 |
goalboy |
B |
July 31, 2024, 1:02 a.m. |
OK |
Java 21 |
TESTS |
6 |
281 |
512000 |
|
|
273611556 |
sakshamjain08 |
B |
July 30, 2024, 6:09 p.m. |
OK |
Java 21 |
TESTS |
6 |
281 |
512000 |
|
|
273637381 |
Yousef_Badr |
B |
July 30, 2024, 11:59 p.m. |
OK |
Java 8 |
TESTS |
6 |
124 |
0 |
|
|
273613381 |
faresbadr316 |
B |
July 30, 2024, 6:21 p.m. |
OK |
Java 8 |
TESTS |
6 |
124 |
0 |
|
|
273641753 |
Artistic_code |
B |
July 31, 2024, 1:01 a.m. |
OK |
Java 8 |
TESTS |
6 |
140 |
0 |
|
|
273614866 |
etian6795 |
B |
July 30, 2024, 6:31 p.m. |
OK |
Java 8 |
TESTS |
6 |
155 |
0 |
|
|
273618313 |
aj_786 |
B |
July 30, 2024, 6:59 p.m. |
OK |
Java 8 |
TESTS |
6 |
156 |
0 |
|
|
273662055 |
NerfThis |
B |
July 31, 2024, 4:43 a.m. |
OK |
Java 8 |
TESTS |
6 |
171 |
0 |
|
|
273614634 |
lanby |
B |
July 30, 2024, 6:30 p.m. |
OK |
Java 8 |
TESTS |
6 |
171 |
0 |
|
|
273606146 |
kasiru_69 |
B |
July 30, 2024, 5:37 p.m. |
OK |
Java 8 |
TESTS |
6 |
171 |
0 |
|
|
273605512 |
Kanishka_bansode |
B |
July 30, 2024, 5:33 p.m. |
OK |
Java 8 |
TESTS |
6 |
171 |
0 |
|
|
273613985 |
aj_786 |
B |
July 30, 2024, 6:25 p.m. |
OK |
Java 8 |
TESTS |
6 |
171 |
512000 |
|
|
273603299 |
MTA9402 |
B |
July 30, 2024, 5:21 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
250 |
8704000 |
|
|
273619300 |
03sajalsrivastava11 |
B |
July 30, 2024, 7:08 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
312 |
14131200 |
|
|
273619190 |
Raihan2500 |
B |
July 30, 2024, 7:07 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
359 |
8294400 |
|
|
273622231 |
snowball_ice_cream |
B |
July 30, 2024, 7:37 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
359 |
8396800 |
|
|
273658279 |
manoharsingh2402 |
B |
July 31, 2024, 4 a.m. |
OK |
PyPy 3 |
TESTS |
6 |
374 |
9113600 |
|
|
273665760 |
AyuAnchor |
B |
July 31, 2024, 5:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
93 |
3686400 |
|
|
273660649 |
gsomani |
B |
July 31, 2024, 4:28 a.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
109 |
4608000 |
|
|
273660024 |
gsomani |
B |
July 31, 2024, 4:20 a.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
124 |
4608000 |
|
|
273639537 |
CarefulWhisperer |
B |
July 31, 2024, 12:16 a.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
124 |
4812800 |
|
|
273602383 |
Drought |
B |
July 30, 2024, 5:17 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
124 |
5017600 |
|
|
273648698 |
patiljyotiraditya123 |
B |
July 31, 2024, 2:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
124 |
7475200 |
|
|
273619646 |
OmarMoBadr |
B |
July 30, 2024, 7:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
139 |
5836800 |
|
|
273609722 |
Om_Singh_ |
B |
July 30, 2024, 5:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
140 |
5222400 |
|
|
273624745 |
NitroSpear |
B |
July 30, 2024, 8:06 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
155 |
6656000 |
|
|
273646706 |
tricktator |
B |
July 31, 2024, 2:03 a.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
156 |
22323200 |
|
|
273602959 |
ArafHasan |
B |
July 30, 2024, 5:20 p.m. |
OK |
Python 3 |
TESTS |
6 |
124 |
3584000 |
|
|
273649206 |
z_squared |
B |
July 31, 2024, 2:30 a.m. |
OK |
Python 3 |
TESTS |
6 |
125 |
409600 |
|
|
273667220 |
anonymus118 |
B |
July 31, 2024, 5:39 a.m. |
OK |
Python 3 |
TESTS |
6 |
140 |
307200 |
|
|
273662491 |
lhhhhhhhhh |
B |
July 31, 2024, 4:48 a.m. |
OK |
Python 3 |
TESTS |
6 |
140 |
307200 |
|
|
273654777 |
manoharsingh2402 |
B |
July 31, 2024, 3:25 a.m. |
OK |
Python 3 |
TESTS |
6 |
140 |
409600 |
|
|
273614852 |
anna16 |
B |
July 30, 2024, 6:31 p.m. |
OK |
Python 3 |
TESTS |
6 |
140 |
409600 |
|
|
273608759 |
Rogue_Ningen |
B |
July 30, 2024, 5:52 p.m. |
OK |
Python 3 |
TESTS |
6 |
140 |
3993600 |
|
|
273633393 |
NHOmi |
B |
July 30, 2024, 10:24 p.m. |
OK |
Python 3 |
TESTS |
6 |
155 |
307200 |
|
|
273643229 |
fync02zxy |
B |
July 31, 2024, 1:21 a.m. |
OK |
Python 3 |
TESTS |
6 |
155 |
409600 |
|
|
273598810 |
amod_24 |
B |
July 30, 2024, 5 p.m. |
OK |
Python 3 |
TESTS |
6 |
155 |
409600 |
|
|
remove filters
Back to search problems