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 are given a string s of length n consisting of characters texttt{A} and texttt{B} . You are allowed to do the following operation: You are only allowed to do the operation at most once for each index 1 <= i <= n - 1 . However, you can do it in any order you want. Find the maximum number of operations that you can carry out. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 1000 ). Description of the test cases follows. The first line of each test case contains a single integer n ( 2 <= n <= 2 cdot 10^5 ) -- the length of string s . The second line of each test case contains the string s ( s_i= texttt{A} or s_i= texttt{B} ). It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, print a single integer containing the maximum number of operations that you can carry out. In the first test case, we can do the operation exactly once for i=1 as s_1= texttt{A} and s_2= texttt{B} . In the second test case, it can be proven that it is not possible to do an operation. In the third test case, we can do an operation on i=2 to form texttt{ABAB} , then another operation on i=3 to form texttt{ABBA} , and finally another operation on i=1 to form texttt{BABA} . Note that even though at the end, s_2 = texttt{A} and s_3 = texttt{B} , we cannot do an operation on i=2 again as we can only do the operation at most once for each index. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
234342746 |
sh_arman |
B |
Nov. 26, 2023, 1:23 a.m. |
OK |
C# 10 |
TESTS |
10 |
46 |
716800 |
|
|
234323285 |
Anastasiya_Andreevna |
B |
Nov. 25, 2023, 7:23 p.m. |
OK |
C# 10 |
TESTS |
10 |
46 |
716800 |
|
|
234299562 |
trubor |
B |
Nov. 25, 2023, 4:48 p.m. |
OK |
C# 10 |
TESTS |
9 |
61 |
1331200 |
|
|
234346079 |
bluemegane |
B |
Nov. 26, 2023, 2:32 a.m. |
OK |
C# 8 |
TESTS |
10 |
108 |
13619200 |
|
|
234346614 |
sunshne |
B |
Nov. 26, 2023, 2:43 a.m. |
OK |
Clang++20 Diagnostics |
TESTS |
10 |
171 |
204800 |
|
|
234330833 |
NenadDapic |
B |
Nov. 25, 2023, 9:01 p.m. |
OK |
FPC |
TESTS |
10 |
31 |
307200 |
|
|
234329465 |
NenadDapic |
B |
Nov. 25, 2023, 8:41 p.m. |
OK |
FPC |
TESTS |
10 |
31 |
307200 |
|
|
234299087 |
vaibhavsingh1108 |
B |
Nov. 25, 2023, 4:46 p.m. |
OK |
GNU C11 |
TESTS |
9 |
15 |
204800 |
|
|
234295532 |
Foxin_01 |
B |
Nov. 25, 2023, 4:34 p.m. |
OK |
GNU C11 |
TESTS |
9 |
15 |
204800 |
|
|
234326743 |
Sultan_Borhan |
B |
Nov. 25, 2023, 8:04 p.m. |
OK |
GNU C11 |
TESTS |
10 |
15 |
204800 |
|
|
234293948 |
Zummer |
B |
Nov. 25, 2023, 4:28 p.m. |
OK |
GNU C11 |
TESTS |
9 |
15 |
204800 |
|
|
234295628 |
Sanchit27 |
B |
Nov. 25, 2023, 4:34 p.m. |
OK |
GNU C11 |
TESTS |
9 |
15 |
1024000 |
|
|
234314519 |
saaad |
B |
Nov. 25, 2023, 5:59 p.m. |
OK |
GNU C11 |
TESTS |
9 |
15 |
1024000 |
|
|
234291432 |
John_Code |
B |
Nov. 25, 2023, 4:19 p.m. |
OK |
GNU C11 |
TESTS |
9 |
46 |
204800 |
|
|
234347446 |
Boimet |
B |
Nov. 26, 2023, 3 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
204800 |
|
|
234316797 |
a2954898606 |
B |
Nov. 25, 2023, 6:15 p.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
204800 |
|
|
234316634 |
NPC404 |
B |
Nov. 25, 2023, 6:14 p.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
204800 |
|
|
234295666 |
xiaci |
B |
Nov. 25, 2023, 4:34 p.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
204800 |
|
|
234346705 |
Avem |
B |
Nov. 26, 2023, 2:44 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
204800 |
|
|
234348800 |
Lyhhhh |
B |
Nov. 26, 2023, 3:25 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
307200 |
|
|
234298816 |
WBS123 |
B |
Nov. 25, 2023, 4:45 p.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
307200 |
|
|
234356921 |
ARFprince |
B |
Nov. 26, 2023, 5:39 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
512000 |
|
|
234354488 |
Konggee. |
B |
Nov. 26, 2023, 5:03 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
512000 |
|
|
234353599 |
bb_16 |
B |
Nov. 26, 2023, 4:49 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
512000 |
|
|
234355566 |
icchou233 |
B |
Nov. 26, 2023, 5:19 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
0 |
512000 |
|
|
234355574 |
Ah_naf |
B |
Nov. 26, 2023, 5:19 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
0 |
512000 |
|
|
234301581 |
Peroregomas |
B |
Nov. 25, 2023, 4:55 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
0 |
|
|
234291636 |
Connor-217 |
B |
Nov. 25, 2023, 4:20 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
0 |
|
|
234344397 |
Code937 |
B |
Nov. 26, 2023, 1:58 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
204800 |
|
|
234336705 |
Linneal |
B |
Nov. 25, 2023, 10:43 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
204800 |
|
|
234305309 |
nbz0210 |
B |
Nov. 25, 2023, 5:07 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
204800 |
|
|
234349826 |
JarryLi |
B |
Nov. 26, 2023, 3:44 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
204800 |
|
|
234351476 |
Tunggg |
B |
Nov. 26, 2023, 4:13 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
204800 |
|
|
234357796 |
pablo888 |
B |
Nov. 26, 2023, 5:52 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
204800 |
|
|
234338457 |
enslaved |
B |
Nov. 25, 2023, 11:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234353474 |
fclvbfm934 |
B |
Nov. 26, 2023, 4:46 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234349224 |
DrWolowitz |
B |
Nov. 26, 2023, 3:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234353586 |
iliyian |
B |
Nov. 26, 2023, 4:49 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234323220 |
RohanC |
B |
Nov. 25, 2023, 7:22 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
0 |
716800 |
|
|
234356121 |
iamcclocation |
B |
Nov. 26, 2023, 5:27 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
0 |
4505600 |
|
|
234342994 |
-Complex- |
B |
Nov. 26, 2023, 1:28 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
204800 |
|
|
234357646 |
Alfa |
B |
Nov. 26, 2023, 5:50 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
512000 |
|
|
234355479 |
alif_cse_ju |
B |
Nov. 26, 2023, 5:18 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
512000 |
|
|
234354635 |
_Kevin |
B |
Nov. 26, 2023, 5:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
512000 |
|
|
234347024 |
XeNAf_I |
B |
Nov. 26, 2023, 2:51 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
0 |
|
|
234342717 |
knifelumen |
B |
Nov. 26, 2023, 1:23 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
204800 |
|
|
234357344 |
Better.Call.Vee |
B |
Nov. 26, 2023, 5:45 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
204800 |
|
|
234355393 |
Elsaqqa |
B |
Nov. 26, 2023, 5:17 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234355662 |
LuSter_Maker |
B |
Nov. 26, 2023, 5:20 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234355325 |
luckmaster |
B |
Nov. 26, 2023, 5:16 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234358182 |
void_3 |
B |
Nov. 26, 2023, 5:57 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234357060 |
shyam_raval |
B |
Nov. 26, 2023, 5:41 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234355033 |
Plabs |
B |
Nov. 26, 2023, 5:11 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234354286 |
sutur |
B |
Nov. 26, 2023, 5 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
0 |
512000 |
|
|
234290922 |
just_noone_really |
B |
Nov. 25, 2023, 4:18 p.m. |
OK |
Haskell |
TESTS |
9 |
62 |
7372800 |
|
|
234349813 |
Hang_We_Hong |
B |
Nov. 26, 2023, 3:44 a.m. |
OK |
Java 11 |
TESTS |
10 |
186 |
7065600 |
|
|
234314348 |
emperor_r |
B |
Nov. 25, 2023, 5:58 p.m. |
OK |
Java 11 |
TESTS |
9 |
187 |
0 |
|
|
234294222 |
chemii |
B |
Nov. 25, 2023, 4:29 p.m. |
OK |
Java 11 |
TESTS |
9 |
218 |
0 |
|
|
234297940 |
pranshupareek |
B |
Nov. 25, 2023, 4:42 p.m. |
OK |
Java 11 |
TESTS |
9 |
233 |
0 |
|
|
234303774 |
uday_lathigara |
B |
Nov. 25, 2023, 5:02 p.m. |
OK |
Java 11 |
TESTS |
9 |
249 |
0 |
|
|
234316581 |
tirthgohil1410 |
B |
Nov. 25, 2023, 6:14 p.m. |
OK |
Java 17 |
TESTS |
9 |
186 |
409600 |
|
|
234305901 |
Kartik2005 |
B |
Nov. 25, 2023, 5:09 p.m. |
OK |
Java 17 |
TESTS |
9 |
202 |
409600 |
|
|
234302691 |
umeshverma07 |
B |
Nov. 25, 2023, 4:58 p.m. |
OK |
Java 17 |
TESTS |
9 |
202 |
614400 |
|
|
234323373 |
CutSandstone |
B |
Nov. 25, 2023, 7:24 p.m. |
OK |
Java 17 |
TESTS |
10 |
202 |
4710400 |
|
|
234346050 |
Xing_ke |
B |
Nov. 26, 2023, 2:31 a.m. |
OK |
Java 17 |
TESTS |
10 |
217 |
0 |
|
|
234313294 |
Nagendravarma |
B |
Nov. 25, 2023, 5:52 p.m. |
OK |
Java 17 |
TESTS |
9 |
218 |
409600 |
|
|
234304538 |
ZhannurM |
B |
Nov. 25, 2023, 5:05 p.m. |
OK |
Java 17 |
TESTS |
9 |
218 |
409600 |
|
|
234303762 |
cpxv |
B |
Nov. 25, 2023, 5:02 p.m. |
OK |
Java 17 |
TESTS |
9 |
218 |
614400 |
|
|
234350511 |
k.SUMANTH |
B |
Nov. 26, 2023, 3:56 a.m. |
OK |
Java 17 |
TESTS |
10 |
218 |
819200 |
|
|
234293271 |
samantamayuri |
B |
Nov. 25, 2023, 4:26 p.m. |
OK |
Java 17 |
TESTS |
9 |
218 |
17920000 |
|
|
234293739 |
Mr.Mittal |
B |
Nov. 25, 2023, 4:27 p.m. |
OK |
Java 21 |
TESTS |
9 |
295 |
102400 |
|
|
234299676 |
futuristic_coder |
B |
Nov. 25, 2023, 4:48 p.m. |
OK |
Java 21 |
TESTS |
9 |
296 |
102400 |
|
|
234329923 |
karanboi |
B |
Nov. 25, 2023, 8:47 p.m. |
OK |
Java 21 |
TESTS |
10 |
389 |
614400 |
|
|
234349848 |
aniket27 |
B |
Nov. 26, 2023, 3:44 a.m. |
OK |
Java 8 |
TESTS |
10 |
109 |
0 |
|
|
234346349 |
mohamedhassan_c |
B |
Nov. 26, 2023, 2:38 a.m. |
OK |
Java 8 |
TESTS |
10 |
109 |
5632000 |
|
|
234319822 |
Sumitsingh7 |
B |
Nov. 25, 2023, 6:44 p.m. |
OK |
Java 8 |
TESTS |
10 |
109 |
5836800 |
|
|
234293338 |
choudharyjitendra7989 |
B |
Nov. 25, 2023, 4:26 p.m. |
OK |
Java 8 |
TESTS |
9 |
124 |
15360000 |
|
|
234351545 |
priyaroy3370 |
B |
Nov. 26, 2023, 4:14 a.m. |
OK |
Java 8 |
TESTS |
10 |
139 |
0 |
|
|
234348267 |
priyaroy3370 |
B |
Nov. 26, 2023, 3:16 a.m. |
OK |
Java 8 |
TESTS |
10 |
155 |
0 |
|
|
234325433 |
arvindf232 |
B |
Nov. 25, 2023, 7:48 p.m. |
OK |
Kotlin 1.6 |
TESTS |
10 |
202 |
0 |
|
|
234342476 |
Clearskyy |
B |
Nov. 26, 2023, 1:18 a.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
30 |
2867200 |
|
|
234306551 |
Carni1 |
B |
Nov. 25, 2023, 5:12 p.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
31 |
204800 |
|
|
234354944 |
Ravitosh |
B |
Nov. 26, 2023, 5:10 a.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
31 |
409600 |
|
|
234290730 |
fizikst |
B |
Nov. 25, 2023, 4:17 p.m. |
OK |
Node.js |
TESTS |
9 |
77 |
2150400 |
|
|
234313242 |
emrakul |
B |
Nov. 25, 2023, 5:52 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
155 |
4710400 |
|
|
234306439 |
NetScoocKlim |
B |
Nov. 25, 2023, 5:11 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
186 |
5529600 |
|
|
234346826 |
tnv2004 |
B |
Nov. 26, 2023, 2:47 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
61 |
2150400 |
|
|
234322621 |
string_eureka |
B |
Nov. 25, 2023, 7:15 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
61 |
2355200 |
|
|
234324452 |
denilb |
B |
Nov. 25, 2023, 7:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
77 |
3072000 |
|
|
234336389 |
oneku16 |
B |
Nov. 25, 2023, 10:36 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
77 |
4505600 |
|
|
234294012 |
dacedev |
B |
Nov. 25, 2023, 4:28 p.m. |
OK |
PyPy 3-64 |
TESTS |
9 |
77 |
4505600 |
|
|
234345526 |
ra5anchor |
B |
Nov. 26, 2023, 2:22 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
92 |
4505600 |
|
|
234354733 |
nealzane |
B |
Nov. 26, 2023, 5:07 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
93 |
3788800 |
|
|
234354089 |
Ana_naS |
B |
Nov. 26, 2023, 4:57 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
93 |
4710400 |
|
|
234339144 |
RobinFromTheHood |
B |
Nov. 25, 2023, 11:41 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
93 |
5017600 |
|
|
234323612 |
parashar22475 |
B |
Nov. 25, 2023, 7:27 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
93 |
5324800 |
|
|
234314726 |
kulwantraj1997 |
B |
Nov. 25, 2023, 6 p.m. |
OK |
Python 3 |
TESTS |
9 |
31 |
512000 |
|
|
234314007 |
eugalt |
B |
Nov. 25, 2023, 5:56 p.m. |
OK |
Python 3 |
TESTS |
9 |
31 |
614400 |
|
|
234339244 |
Sparkle_Twilight |
B |
Nov. 25, 2023, 11:44 p.m. |
OK |
Python 3 |
TESTS |
10 |
31 |
819200 |
|
|
234332823 |
eugalt |
B |
Nov. 25, 2023, 9:31 p.m. |
OK |
Python 3 |
TESTS |
10 |
31 |
819200 |
|
|
234315396 |
eugalt |
B |
Nov. 25, 2023, 6:05 p.m. |
OK |
Python 3 |
TESTS |
9 |
46 |
819200 |
|
|
234314812 |
eugalt |
B |
Nov. 25, 2023, 6:01 p.m. |
OK |
Python 3 |
TESTS |
9 |
46 |
819200 |
|
|
234327429 |
edugong |
B |
Nov. 25, 2023, 8:13 p.m. |
OK |
Python 3 |
TESTS |
10 |
61 |
614400 |
|
|
234317502 |
Block_Cipher |
B |
Nov. 25, 2023, 6:22 p.m. |
OK |
Python 3 |
TESTS |
9 |
61 |
5324800 |
|
|
234303832 |
sonusharma390788 |
B |
Nov. 25, 2023, 5:02 p.m. |
OK |
Python 3 |
TESTS |
9 |
62 |
614400 |
|
|
234302339 |
Angle_Bisector |
B |
Nov. 25, 2023, 4:57 p.m. |
OK |
Python 3 |
TESTS |
9 |
62 |
614400 |
|
|
234294015 |
ReZero___ |
B |
Nov. 25, 2023, 4:28 p.m. |
OK |
Rust 2021 |
TESTS |
9 |
0 |
819200 |
|
|
234295318 |
vstiff |
B |
Nov. 25, 2023, 4:33 p.m. |
OK |
Rust 2021 |
TESTS |
9 |
15 |
819200 |
|
|
remove filters
Back to search problems