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"Filip has a row of cells, some of which are blocked, and some are empty. He wants all empty cells to have water in them. He has two actions at his disposal: If at some moment cell i ( 2 <= i <= n-1 ) is empty and both cells i-1 and i+1 contains water, then it becomes filled with water. Find the minimum number of times he needs to perform action 1 in order to fill all empty cells with water. Note that you don't need to minimize the use of action 2 . Note that blocked cells neither contain water nor can Filip place water in them. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 100 ). The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 100 ) -- the number of cells. The next line contains a string s of length n . The i -th character of s is '.' if the cell i is empty and '#' if cell i is blocked. For each test case, output a single number -- the minimal amount of actions 1 needed to fill all empty cells with water. Test Case 1 In the first test case, Filip can put water in cells 1 and 3 . As cell 2 is between 2 cells with water, it gets filled with water too. Test Case 2 In the second case, he can put water sources in cells 3 and 5 . That results in cell 4 getting filled with water. Then he will remove water from cell 5 and place it into cell 6 . As cell 5 's neighbors, cell 4 and cell 6 , have water in them, cell 5 also gets filled with water. You can see the illustration of this case below. Test Case 3 In the third case, he can put water in all the empty cells. That requires 5 actions of type 1 . Test Case 4 In the fourth case, there are no empty cells. Therefore, he does not have to put any water in them. Test Case 5 In the fifth test case, there exists a"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
234476154 |
alevdenizakca |
A |
Nov. 26, 2023, 4:13 p.m. |
OK |
C# 10 |
TESTS |
11 |
46 |
0 |
|
|
234468845 |
ungerfall |
A |
Nov. 26, 2023, 3:49 p.m. |
OK |
C# 10 |
TESTS |
11 |
46 |
512000 |
|
|
234523969 |
sh_arman |
A |
Nov. 27, 2023, 1:01 a.m. |
OK |
C# 10 |
TESTS |
11 |
77 |
204800 |
|
|
234519376 |
bluemegane |
A |
Nov. 26, 2023, 10:47 p.m. |
OK |
C# 8 |
TESTS |
11 |
92 |
204800 |
|
|
234470029 |
resulmutluer |
A |
Nov. 26, 2023, 3:53 p.m. |
OK |
C# 8 |
TESTS |
11 |
155 |
409600 |
|
|
234492118 |
tahmidulislam998 |
A |
Nov. 26, 2023, 6:13 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
11 |
31 |
0 |
|
|
234485728 |
Relake |
A |
Nov. 26, 2023, 5:25 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
11 |
31 |
0 |
|
|
234521934 |
Sunrikis |
A |
Nov. 27, 2023, midnight |
OK |
Clang++20 Diagnostics |
TESTS |
11 |
46 |
0 |
|
|
234510445 |
Javeple |
A |
Nov. 26, 2023, 8:19 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
11 |
46 |
0 |
|
|
234490892 |
Shivam_Codes |
A |
Nov. 26, 2023, 6:03 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
11 |
46 |
0 |
|
|
234534113 |
vamsi1281977 |
A |
Nov. 27, 2023, 4:24 a.m. |
OK |
FPC |
TESTS |
11 |
15 |
102400 |
|
|
234524994 |
yuyc |
A |
Nov. 27, 2023, 1:28 a.m. |
OK |
GNU C++14 |
TESTS |
11 |
0 |
0 |
|
|
234490985 |
Ra_ist |
A |
Nov. 26, 2023, 6:04 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
0 |
0 |
|
|
234469162 |
amanuniyal |
A |
Nov. 26, 2023, 3:50 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
0 |
0 |
|
|
234468988 |
bloodyvj |
A |
Nov. 26, 2023, 3:50 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
0 |
0 |
|
|
234493653 |
ceruly |
A |
Nov. 26, 2023, 6:28 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
0 |
102400 |
|
|
234527803 |
Mars_Dingdang |
A |
Nov. 27, 2023, 2:35 a.m. |
OK |
GNU C++14 |
TESTS |
11 |
0 |
2150400 |
|
|
234498237 |
Assem.Amr |
A |
Nov. 26, 2023, 7:17 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
0 |
16076800 |
|
|
234539356 |
sajalmittal1501 |
A |
Nov. 27, 2023, 5:31 a.m. |
OK |
GNU C++14 |
TESTS |
11 |
15 |
0 |
|
|
234538837 |
tonmoy197 |
A |
Nov. 27, 2023, 5:25 a.m. |
OK |
GNU C++14 |
TESTS |
11 |
15 |
0 |
|
|
234538803 |
ahwabanmukherjee |
A |
Nov. 27, 2023, 5:24 a.m. |
OK |
GNU C++14 |
TESTS |
11 |
15 |
0 |
|
|
remove filters
Back to search problems