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 even length n . String s is binary, in other words, consists only of 0's and 1's. String s has exactly frac{n}{2} zeroes and frac{n}{2} ones ( n is even). In one operation you can reverse any substring of s . A substring of a string is a contiguous subsequence of that string. What is the minimum number of operations you need to make string s alternating? A string is alternating if s_i neq s_{i + 1} for all i . There are two types of alternating strings in general: 01010101... or 10101010... The first line contains a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. The first line of each test case contains a single integer n ( 2 <= n <= 10^5 ; n is even) -- the length of string s . The second line of each test case contains a binary string s of length n ( s_i in {0, 1}). String s has exactly frac{n}{2} zeroes and frac{n}{2} ones. It's guaranteed that the total sum of n over test cases doesn't exceed 10^5 . For each test case, print the minimum number of operations to make s alternating. In the first test case, string 10 is already alternating. In the second test case, we can, for example, reverse the last two elements of s and get: 0110 rightarrow 0101. In the third test case, we can, for example, make the following two operations: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
96920001 |
nikkonphy |
B |
Oct. 27, 2020, 4:23 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
102400 |
|
|
96933625 |
adityasaha39 |
B |
Oct. 27, 2020, 6 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
102400 |
|
|
96953065 |
scheung |
B |
Oct. 28, 2020, 3:30 a.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
102400 |
|
|
96922175 |
flayer_hunter |
B |
Oct. 27, 2020, 4:29 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
409600 |
|
|
96959195 |
samari06 |
B |
Oct. 28, 2020, 5:40 a.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
1024000 |
|
|
96921779 |
Akila_Nipo |
B |
Oct. 27, 2020, 4:28 p.m. |
OK |
GNU C11 |
TESTS |
4 |
30 |
102400 |
|
|
96948974 |
BugLeave |
B |
Oct. 28, 2020, 1:42 a.m. |
OK |
GNU C11 |
TESTS |
5 |
31 |
102400 |
|
|
96919306 |
1435730 |
B |
Oct. 27, 2020, 4:22 p.m. |
OK |
GNU C11 |
TESTS |
4 |
31 |
102400 |
|
|
96945513 |
rcxkk |
B |
Oct. 27, 2020, 11:18 p.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
96925299 |
Superbia-zyb |
B |
Oct. 27, 2020, 4:37 p.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
96920661 |
Blade_owo |
B |
Oct. 27, 2020, 4:25 p.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
96956159 |
vjudge3 |
B |
Oct. 28, 2020, 4:38 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
96956153 |
Tom66 |
B |
Oct. 28, 2020, 4:38 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
96946239 |
zqyyy |
B |
Oct. 27, 2020, 11:50 p.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
96952396 |
guanhuai04 |
B |
Oct. 28, 2020, 3:13 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
102400 |
|
|
96950244 |
Quick_Kk |
B |
Oct. 28, 2020, 2:22 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
102400 |
|
|
96957140 |
LHRG |
B |
Oct. 28, 2020, 4:58 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
102400 |
|
|
96957538 |
Hamsterw |
B |
Oct. 28, 2020, 5:06 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
102400 |
|
|
96919122 |
tzxydby |
B |
Oct. 27, 2020, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
102400 |
|
|
96950540 |
aya_uchida |
B |
Oct. 28, 2020, 2:30 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
204800 |
|
|
96949865 |
bingqian_li |
B |
Oct. 28, 2020, 2:10 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
204800 |
|
|
96960069 |
ajinkya1p3 |
B |
Oct. 28, 2020, 5:55 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
307200 |
|
|
96959726 |
alexashu |
B |
Oct. 28, 2020, 5:49 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
307200 |
|
|
96957527 |
1412neerujjain |
B |
Oct. 28, 2020, 5:06 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
307200 |
|
|
96954173 |
iamskk |
B |
Oct. 28, 2020, 3:54 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
307200 |
|
|
96953515 |
Habib_Assoev |
B |
Oct. 28, 2020, 3:40 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
307200 |
|
|
96952917 |
sh3rlock |
B |
Oct. 28, 2020, 3:26 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
307200 |
|
|
96951785 |
adityarajiv |
B |
Oct. 28, 2020, 3 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
307200 |
|
|
96920938 |
Karim_Symon |
B |
Oct. 27, 2020, 4:26 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
307200 |
|
|
96947396 |
motorcycle |
B |
Oct. 28, 2020, 12:41 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
0 |
307200 |
|
|
96936073 |
gabrielwu |
B |
Oct. 27, 2020, 6:42 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
102400 |
|
|
96950201 |
muoshuo |
B |
Oct. 28, 2020, 2:21 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
102400 |
|
|
96956677 |
anhacker |
B |
Oct. 28, 2020, 4:48 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
204800 |
|
|
96927618 |
zlt1117 |
B |
Oct. 27, 2020, 4:52 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
204800 |
|
|
96925974 |
Falcon__ |
B |
Oct. 27, 2020, 4:41 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
204800 |
|
|
96960274 |
tuknait_akshat |
B |
Oct. 28, 2020, 5:59 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
307200 |
|
|
96960016 |
sachin0102 |
B |
Oct. 28, 2020, 5:54 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
307200 |
|
|
96959743 |
_Sachin_S |
B |
Oct. 28, 2020, 5:49 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
307200 |
|
|
96931359 |
razvanperial |
B |
Oct. 27, 2020, 5:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
102400 |
|
|
96949367 |
wlzhouzhuan |
B |
Oct. 28, 2020, 1:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
102400 |
|
|
96935125 |
smurfer |
B |
Oct. 27, 2020, 6:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
102400 |
|
|
96926680 |
chain_coder |
B |
Oct. 27, 2020, 4:45 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
204800 |
|
|
96930686 |
Tanbin_Hasan |
B |
Oct. 27, 2020, 5:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
204800 |
|
|
96950671 |
pkp100 |
B |
Oct. 28, 2020, 2:34 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
307200 |
|
|
96953439 |
Night_Lord |
B |
Oct. 28, 2020, 3:38 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
307200 |
|
|
96955884 |
Abhi1303 |
B |
Oct. 28, 2020, 4:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
307200 |
|
|
96956768 |
devillove084 |
B |
Oct. 28, 2020, 4:50 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
307200 |
|
|
96959475 |
sanjeev007 |
B |
Oct. 28, 2020, 5:45 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
307200 |
|
|
96938484 |
eR6 |
B |
Oct. 27, 2020, 7:27 p.m. |
OK |
Go |
TESTS |
5 |
30 |
102400 |
|
|
96943979 |
yesbutno1685 |
B |
Oct. 27, 2020, 10:05 p.m. |
OK |
Java 11 |
TESTS |
5 |
155 |
0 |
|
|
96926366 |
TenseGor1lla |
B |
Oct. 27, 2020, 4:43 p.m. |
OK |
Java 11 |
TESTS |
4 |
170 |
0 |
|
|
96955171 |
the_royal_raj |
B |
Oct. 28, 2020, 4:17 a.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
96959441 |
KoustavBeginner |
B |
Oct. 28, 2020, 5:44 a.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
96958424 |
the_royal_raj |
B |
Oct. 28, 2020, 5:24 a.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
96952437 |
sam_code |
B |
Oct. 28, 2020, 3:14 a.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
96945765 |
Apass.Jack |
B |
Oct. 27, 2020, 11:30 p.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
96943651 |
yesbutno1685 |
B |
Oct. 27, 2020, 9:52 p.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
96940223 |
shankha123 |
B |
Oct. 27, 2020, 8:05 p.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
96938144 |
vineet_001 |
B |
Oct. 27, 2020, 7:20 p.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
96948526 |
Foenic |
B |
Oct. 28, 2020, 1:28 a.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
96942320 |
harshitContest |
B |
Oct. 27, 2020, 9:03 p.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
96935193 |
obsessed_titan |
B |
Oct. 27, 2020, 6:26 p.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
96925750 |
blackmamba23 |
B |
Oct. 27, 2020, 4:39 p.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
96936717 |
RichardBot7000 |
B |
Oct. 27, 2020, 6:53 p.m. |
OK |
Java 8 |
TESTS |
4 |
108 |
0 |
|
|
96926006 |
Pranay2516 |
B |
Oct. 27, 2020, 4:41 p.m. |
OK |
Java 8 |
TESTS |
4 |
109 |
0 |
|
|
96954075 |
amansingh-52 |
B |
Oct. 28, 2020, 3:52 a.m. |
OK |
Java 8 |
TESTS |
5 |
109 |
0 |
|
|
96938307 |
deepaksach |
B |
Oct. 27, 2020, 7:24 p.m. |
OK |
Java 8 |
TESTS |
5 |
109 |
0 |
|
|
96936532 |
G.A.T.C |
B |
Oct. 27, 2020, 6:50 p.m. |
OK |
Java 8 |
TESTS |
4 |
109 |
0 |
|
|
96959188 |
obsessed_titan |
B |
Oct. 28, 2020, 5:40 a.m. |
OK |
Java 8 |
TESTS |
5 |
124 |
0 |
|
|
96929758 |
nuralamcse024 |
B |
Oct. 27, 2020, 5:13 p.m. |
OK |
JavaScript |
TESTS |
4 |
31 |
102400 |
|
|
96955193 |
kabden.a |
B |
Oct. 28, 2020, 4:17 a.m. |
OK |
JavaScript |
TESTS |
5 |
31 |
409600 |
|
|
96932688 |
rupesh.thakur |
B |
Oct. 27, 2020, 5:46 p.m. |
OK |
Kotlin |
TESTS |
4 |
124 |
0 |
|
|
96922667 |
AliceNCsyuk |
B |
Oct. 27, 2020, 4:30 p.m. |
OK |
MS C++ |
TESTS |
4 |
31 |
307200 |
|
|
96948285 |
rishikeshjoshi123 |
B |
Oct. 28, 2020, 1:18 a.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
15 |
204800 |
|
|
96923464 |
dbsthdud918 |
B |
Oct. 27, 2020, 4:32 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
102400 |
|
|
96921729 |
ZiweiMo |
B |
Oct. 27, 2020, 4:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
204800 |
|
|
96931540 |
666EGOR777 |
B |
Oct. 27, 2020, 5:31 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
204800 |
|
|
96929667 |
xcv |
B |
Oct. 27, 2020, 5:12 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
204800 |
|
|
96927196 |
semihpirpir |
B |
Oct. 27, 2020, 4:49 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
204800 |
|
|
96924956 |
nekr137 |
B |
Oct. 27, 2020, 4:34 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
204800 |
|
|
96937671 |
xsc |
B |
Oct. 27, 2020, 7:10 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
31 |
307200 |
|
|
96931586 |
666EGOR777 |
B |
Oct. 27, 2020, 5:32 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
46 |
204800 |
|
|
96942177 |
ustaritz |
B |
Oct. 27, 2020, 8:58 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
46 |
204800 |
|
|
96937003 |
nayk.sky |
B |
Oct. 27, 2020, 6:59 p.m. |
OK |
.NET Core C# |
TESTS |
5 |
93 |
204800 |
|
|
96941277 |
henrychenOutlook |
B |
Oct. 27, 2020, 8:31 p.m. |
OK |
Node.js |
TESTS |
5 |
77 |
1843200 |
|
|
96956581 |
hxu10 |
B |
Oct. 28, 2020, 4:46 a.m. |
OK |
PyPy 2 |
TESTS |
5 |
171 |
3072000 |
|
|
96927614 |
mo-hit |
B |
Oct. 27, 2020, 4:52 p.m. |
OK |
PyPy 2 |
TESTS |
4 |
187 |
9113600 |
|
|
96925444 |
Scopula |
B |
Oct. 27, 2020, 4:38 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
2457600 |
|
|
96936290 |
vvedant99 |
B |
Oct. 27, 2020, 6:46 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
2867200 |
|
|
96932417 |
PratyaydeepG |
B |
Oct. 27, 2020, 5:43 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
155 |
2048000 |
|
|
96933334 |
AggarwalRaghav |
B |
Oct. 27, 2020, 5:56 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
155 |
2355200 |
|
|
96932358 |
silvertint |
B |
Oct. 27, 2020, 5:42 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
155 |
2457600 |
|
|
96932571 |
nocreative1 |
B |
Oct. 27, 2020, 5:45 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
155 |
2867200 |
|
|
96924438 |
raj1307 |
B |
Oct. 27, 2020, 4:34 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
155 |
2867200 |
|
|
96948570 |
gintoki_s |
B |
Oct. 28, 2020, 1:29 a.m. |
OK |
PyPy 3 |
TESTS |
5 |
170 |
2560000 |
|
|
96956420 |
Anuranjan_Pandey |
B |
Oct. 28, 2020, 4:43 a.m. |
OK |
PyPy 3 |
TESTS |
5 |
170 |
4198400 |
|
|
96929701 |
Shankhadeep |
B |
Oct. 27, 2020, 5:12 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
171 |
921600 |
|
|
96934319 |
saini.mn23 |
B |
Oct. 27, 2020, 6:11 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
204800 |
|
|
96930395 |
sh1194 |
B |
Oct. 27, 2020, 5:20 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
204800 |
|
|
96929079 |
bug_eater |
B |
Oct. 27, 2020, 5:06 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
204800 |
|
|
96928989 |
bug_eater |
B |
Oct. 27, 2020, 5:05 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
204800 |
|
|
96957072 |
Sam_v |
B |
Oct. 28, 2020, 4:56 a.m. |
OK |
Python 3 |
TESTS |
5 |
93 |
307200 |
|
|
96926737 |
_unstable_atom |
B |
Oct. 27, 2020, 4:46 p.m. |
OK |
Python 3 |
TESTS |
4 |
108 |
204800 |
|
|
96931872 |
jpa |
B |
Oct. 27, 2020, 5:35 p.m. |
OK |
Python 3 |
TESTS |
4 |
108 |
1126400 |
|
|
96942179 |
Ravi_ISI |
B |
Oct. 27, 2020, 8:58 p.m. |
OK |
Python 3 |
TESTS |
5 |
109 |
204800 |
|
|
96938252 |
skate1512 |
B |
Oct. 27, 2020, 7:22 p.m. |
OK |
Python 3 |
TESTS |
5 |
109 |
204800 |
|
|
96927486 |
skate1512 |
B |
Oct. 27, 2020, 4:51 p.m. |
OK |
Python 3 |
TESTS |
4 |
109 |
204800 |
|
|
96927555 |
masa0216masa0216masa0216 |
B |
Oct. 27, 2020, 4:52 p.m. |
OK |
Ruby |
TESTS |
4 |
576 |
6041600 |
|
|
96918862 |
pandrei |
B |
Oct. 27, 2020, 4:20 p.m. |
OK |
Rust |
TESTS |
4 |
31 |
409600 |
|
|
remove filters
Back to search problems