-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unique question codeforces round 923
- Loading branch information
1 parent
9b8b56d
commit 3e7f697
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
int how_many(string c, int index) { | ||
|
||
int count = 0, start = 0, end = 0; | ||
|
||
for(int i = 0; i < index; ++i) { | ||
|
||
if(c[i] == 'B' && count == 0) { | ||
count++; | ||
start = i; | ||
} | ||
|
||
if(c[i] == 'B' && count != 0) | ||
end = i; | ||
|
||
} | ||
|
||
return end-start+1; | ||
|
||
} | ||
|
||
|
||
int main(void){ | ||
|
||
int n, index; | ||
string c; | ||
|
||
cin >> n; | ||
|
||
for(int i = 0; i < n; ++i) { | ||
cin >> index >> c; | ||
cout << how_many(c, index) << endl; | ||
} | ||
|
||
} |