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 have a horizontal strip of n cells. Each cell is either white or black. You can choose a continuous segment of cells once and paint them all white. After this action, all the black cells in this segment will become white, and the white ones will remain white. What is the minimum length of the segment that needs to be painted white in order for all n cells to become white? The first line of the input contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The descriptions of the test cases follow. The first line of each test case contains a single integer n ( 1 <= n <= 10 ) -- the length of the strip. The second line of each test case contains a string s , consisting of n characters, each of which is either 'W ' or 'B '. The symbol 'W ' denotes a white cell, and 'B ' -- a black one. It is guaranteed that at least one cell of the given strip is black. For each test case, output a single number -- the minimum length of a continuous segment of cells that needs to be painted white in order for the entire strip to become white. In the first test case of the example for the strip "WBBWBW", the minimum length of the segment to be repainted white is 4 . It is necessary to repaint to white the segment from the 2 -nd to the 5 -th cell (the cells are numbered from 1 from left to right). '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
245272999 |
_Ghoco_ |
A |
Feb. 7, 2024, 12:13 a.m. |
OK |
C# 10 |
TESTS |
5 |
46 |
1024000 |
|
|
245292239 |
kataanee |
A |
Feb. 7, 2024, 5:38 a.m. |
OK |
C# 10 |
TESTS |
5 |
77 |
921600 |
|
|
245269715 |
bluemegane |
A |
Feb. 6, 2024, 10:51 p.m. |
OK |
C# 8 |
TESTS |
5 |
140 |
1024000 |
|
|
245291355 |
atriyatuoli |
A |
Feb. 7, 2024, 5:26 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
5 |
108 |
0 |
|
|
245253846 |
shreyan203 |
A |
Feb. 6, 2024, 7:25 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
2 |
108 |
0 |
|
|
245291734 |
UdayKottana |
A |
Feb. 7, 2024, 5:31 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
5 |
155 |
0 |
|
|
245260355 |
MostafaAboSalama |
A |
Feb. 6, 2024, 8:31 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
5 |
155 |
0 |
|
|
245284941 |
aquily |
A |
Feb. 7, 2024, 3:58 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
5 |
155 |
102400 |
|
|
245276473 |
Zfox |
A |
Feb. 7, 2024, 1:34 a.m. |
OK |
Clang++20 Diagnostics |
TESTS |
5 |
78 |
0 |
|
|
245263441 |
itachi_1609 |
A |
Feb. 6, 2024, 9:09 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
5 |
139 |
0 |
|
|
245246458 |
udaynarwal72 |
A |
Feb. 6, 2024, 6:26 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
2 |
155 |
0 |
|
|
245245373 |
Krishnakk |
A |
Feb. 6, 2024, 6:19 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
2 |
202 |
0 |
|
|
remove filters
Back to search problems