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"Let's call a binary string T of length m indexed from 1 to m paranoid if we can obtain a string of length 1 by performing the following two kinds of operations m-1 times in any order : For example, if T = 001, we can select the substring [T_2T_3] and perform the first operation. So we obtain T = 01. You are given a binary string S of length n indexed from 1 to n . Find the number of pairs of integers (l, r) 1 <= l <= r <= n such that S[l ldots r] (the substring of S from l to r ) is a paranoid string. The first line contains an integer t ( 1 <= t <= 1000 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 2 cdot 10^5 ) -- the size of S . The second line of each test case contains a binary string S of n characters S_1S_2 ldots S_n . ( S_i = 0 or S_i = 1 for each 1 <= i <= n ) It is guaranteed that the sum of n over all test cases doesn't exceed 2 cdot 10^5 . For each test case, output the number of pairs of integers (l, r) 1 <= l <= r <= n such that S[l ldots r] (the substring of S from l to r ) is a paranoid string. In the first sample, S already has length 1 and doesn't need any operations. In the second sample, all substrings of S are paranoid. For the entire string, it's enough to perform the first operation. In the third sample, all substrings of S are paranoid except [S_2S_3] , because we can't perform any operations on it, and [S_1S_2S_3] (the entire string). "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
160878370 |
TheILICH |
B |
June 16, 2022, 4:18 p.m. |
OK |
C# 8 |
TESTS |
8 |
77 |
3686400 |
|
1200 |
160913698 |
chinawcp |
B |
June 17, 2022, 2:14 a.m. |
OK |
GNU C11 |
TESTS |
8 |
15 |
1024000 |
|
1200 |
160888518 |
ducnhan84 |
B |
June 16, 2022, 5:04 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160881194 |
ayaan26 |
B |
June 16, 2022, 4:25 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160914368 |
bipinjadav |
B |
June 17, 2022, 2:34 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160879552 |
algobb |
B |
June 16, 2022, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160893866 |
abdallahmontaser |
B |
June 16, 2022, 5:45 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160893260 |
cod_shiven2001 |
B |
June 16, 2022, 5:40 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160880705 |
jayrajsinh3195 |
B |
June 16, 2022, 4:23 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
15 |
0 |
|
1200 |
160883180 |
VLapytskyi |
B |
June 16, 2022, 4:29 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
15 |
0 |
|
1200 |
160915698 |
202003012001 |
B |
June 17, 2022, 3:08 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
15 |
204800 |
|
1200 |
160915787 |
yaoking123 |
B |
June 17, 2022, 3:11 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
15 |
204800 |
|
1200 |
160907424 |
Hasan0540 |
B |
June 16, 2022, 9:42 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
204800 |
|
1200 |
160918060 |
onandon |
B |
June 17, 2022, 4:03 a.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160917953 |
patilc125 |
B |
June 17, 2022, 4 a.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160912225 |
kesihai |
B |
June 17, 2022, 1:25 a.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160906968 |
Zaman_R |
B |
June 16, 2022, 9:26 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160918632 |
IftekharMd.Shishir |
B |
June 17, 2022, 4:16 a.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160904876 |
ashish.rrs |
B |
June 16, 2022, 8:32 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160895851 |
prathamjainyt |
B |
June 16, 2022, 6:07 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160894634 |
introart |
B |
June 16, 2022, 5:53 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160905624 |
Fa_HD |
B |
June 16, 2022, 8:49 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
0 |
512000 |
|
1200 |
160913376 |
Einstein1234 |
B |
June 17, 2022, 2:04 a.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
204800 |
|
1200 |
160884684 |
Samy_0202 |
B |
June 16, 2022, 4:32 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160915304 |
aryan57 |
B |
June 17, 2022, 2:58 a.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160910430 |
Coder_A007 |
B |
June 17, 2022, 12:03 a.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160904679 |
errorgorn |
B |
June 16, 2022, 8:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160891656 |
Axiomatic008 |
B |
June 16, 2022, 5:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160887347 |
TokieSan |
B |
June 16, 2022, 4:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160884196 |
noob_coder_29 |
B |
June 16, 2022, 4:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160879392 |
leo-sis |
B |
June 16, 2022, 4:20 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160890794 |
izumiQR |
B |
June 16, 2022, 5:19 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
204800 |
|
1200 |
160909137 |
xiaoru |
B |
June 16, 2022, 10:51 p.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
204800 |
|
1200 |
160923733 |
Ballutech |
B |
June 17, 2022, 5:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160923695 |
lm666 |
B |
June 17, 2022, 5:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160924293 |
Buri_Buri_Zaemon |
B |
June 17, 2022, 5:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160923144 |
Naveen264 |
B |
June 17, 2022, 5:37 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160923063 |
luminous123 |
B |
June 17, 2022, 5:35 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160922926 |
tanmay_212 |
B |
June 17, 2022, 5:33 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160922069 |
jenish_k |
B |
June 17, 2022, 5:17 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160923656 |
__wizard_of_oz__ |
B |
June 17, 2022, 5:45 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160924187 |
Kevin_5997 |
B |
June 17, 2022, 5:53 a.m. |
OK |
GNU C++20 (64) |
TESTS |
8 |
0 |
512000 |
|
1200 |
160897107 |
dagnaf |
B |
June 16, 2022, 6:20 p.m. |
OK |
Go |
TESTS |
8 |
30 |
1536000 |
|
1200 |
160913018 |
nguyenkimphuongtrang |
B |
June 17, 2022, 1:53 a.m. |
OK |
Go |
TESTS |
8 |
30 |
1536000 |
|
1200 |
160888305 |
koqo |
B |
June 16, 2022, 5:02 p.m. |
OK |
Go |
TESTS |
8 |
31 |
1638400 |
|
1200 |
160895666 |
MunirKP |
B |
June 16, 2022, 6:04 p.m. |
OK |
Java 11 |
TESTS |
8 |
156 |
0 |
|
1200 |
160893291 |
goyalronak3 |
B |
June 16, 2022, 5:40 p.m. |
OK |
Java 11 |
TESTS |
8 |
156 |
0 |
|
1200 |
160902328 |
amanpatel23 |
B |
June 16, 2022, 7:39 p.m. |
OK |
Java 11 |
TESTS |
8 |
170 |
0 |
|
1200 |
160924551 |
laukik.shelke |
B |
June 17, 2022, 5:58 a.m. |
OK |
Java 11 |
TESTS |
8 |
171 |
0 |
|
1200 |
160923713 |
Yash9890 |
B |
June 17, 2022, 5:46 a.m. |
OK |
Java 11 |
TESTS |
8 |
171 |
0 |
|
1200 |
160919175 |
unfixedbug |
B |
June 17, 2022, 4:28 a.m. |
OK |
Java 11 |
TESTS |
8 |
171 |
0 |
|
1200 |
160918230 |
arthuryuan15g |
B |
June 17, 2022, 4:07 a.m. |
OK |
Java 11 |
TESTS |
8 |
171 |
0 |
|
1200 |
160918058 |
souvik2000 |
B |
June 17, 2022, 4:03 a.m. |
OK |
Java 11 |
TESTS |
8 |
171 |
0 |
|
1200 |
160917337 |
crazycoder143 |
B |
June 17, 2022, 3:47 a.m. |
OK |
Java 11 |
TESTS |
8 |
171 |
0 |
|
1200 |
160916721 |
ketangupta12 |
B |
June 17, 2022, 3:32 a.m. |
OK |
Java 11 |
TESTS |
8 |
171 |
0 |
|
1200 |
160911999 |
DylanSmith |
B |
June 17, 2022, 1:16 a.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
1200 |
160924058 |
Shantanu1058 |
B |
June 17, 2022, 5:51 a.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
1200 |
160922914 |
fengyu1 |
B |
June 17, 2022, 5:33 a.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
1200 |
160906714 |
ayafayed |
B |
June 16, 2022, 9:18 p.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
1200 |
160899338 |
aryaman_571 |
B |
June 16, 2022, 6:52 p.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
1200 |
160888814 |
andar_se_toot_chuka_hu |
B |
June 16, 2022, 5:05 p.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
1200 |
160888536 |
EndlessVoid |
B |
June 16, 2022, 5:04 p.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
1200 |
160883170 |
vaibhav_1710 |
B |
June 16, 2022, 4:29 p.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
1200 |
160917866 |
dkj |
B |
June 17, 2022, 3:59 a.m. |
OK |
Java 8 |
TESTS |
8 |
108 |
0 |
|
1200 |
160899306 |
aryaman_571 |
B |
June 16, 2022, 6:52 p.m. |
OK |
Java 8 |
TESTS |
8 |
108 |
0 |
|
1200 |
160888642 |
serg_alb |
B |
June 16, 2022, 5:04 p.m. |
OK |
Kotlin 1.5 |
TESTS |
8 |
186 |
0 |
|
1200 |
160884759 |
serg_alb |
B |
June 16, 2022, 4:33 p.m. |
OK |
Kotlin 1.5 |
TESTS |
8 |
187 |
0 |
|
1200 |
160897011 |
Nizomidin |
B |
June 16, 2022, 6:20 p.m. |
OK |
Kotlin 1.6 |
TESTS |
8 |
186 |
0 |
|
1200 |
160881455 |
alitest |
B |
June 16, 2022, 4:25 p.m. |
OK |
Mono C# |
TESTS |
8 |
46 |
921600 |
|
1200 |
160881853 |
mohamedbakr |
B |
June 16, 2022, 4:26 p.m. |
OK |
Mono C# |
TESTS |
8 |
46 |
921600 |
|
1200 |
160917047 |
touxinzei |
B |
June 17, 2022, 3:40 a.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
15 |
204800 |
|
1200 |
160924574 |
sombitgupta |
B |
June 17, 2022, 5:59 a.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
15 |
204800 |
|
1200 |
160915319 |
Scvprogram |
B |
June 17, 2022, 2:58 a.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
15 |
307200 |
|
1200 |
160923655 |
justaguyalways |
B |
June 17, 2022, 5:45 a.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
15 |
512000 |
|
1200 |
160893860 |
Nosov_Vovanus2022 |
B |
June 16, 2022, 5:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
15 |
512000 |
|
1200 |
160897478 |
BalaluevEgor |
B |
June 16, 2022, 6:25 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
15 |
614400 |
|
1200 |
160897166 |
OptimuS99 |
B |
June 16, 2022, 6:21 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
31 |
614400 |
|
1200 |
160913129 |
qiaoqiaodaima |
B |
June 17, 2022, 1:56 a.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
31 |
614400 |
|
1200 |
160887214 |
coicy |
B |
June 16, 2022, 4:58 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
46 |
0 |
|
1200 |
160888314 |
yoralbayev |
B |
June 16, 2022, 5:03 p.m. |
OK |
PHP |
TESTS |
8 |
61 |
0 |
|
1200 |
160887997 |
sushmanth.dampur8780 |
B |
June 16, 2022, 5:01 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
108 |
2764800 |
|
1200 |
160902185 |
Anti-Neutrino |
B |
June 16, 2022, 7:37 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
109 |
2969600 |
|
1200 |
160917985 |
grininja |
B |
June 17, 2022, 4:01 a.m. |
OK |
PyPy 3 |
TESTS |
8 |
109 |
3276800 |
|
1200 |
160909940 |
danielrousseaug |
B |
June 16, 2022, 11:39 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
124 |
4915200 |
|
1200 |
160924054 |
ludwings0330 |
B |
June 17, 2022, 5:51 a.m. |
OK |
PyPy 3 |
TESTS |
8 |
124 |
7680000 |
|
1200 |
160896469 |
hxu10 |
B |
June 16, 2022, 6:13 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
139 |
4300800 |
|
1200 |
160890315 |
a_vantik_a |
B |
June 16, 2022, 5:15 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
140 |
5324800 |
|
1200 |
160890738 |
abhijeet.panihar.cse20 |
B |
June 16, 2022, 5:18 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
140 |
7065600 |
|
1200 |
160883598 |
sahil329 |
B |
June 16, 2022, 4:30 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
155 |
5836800 |
|
1200 |
160890497 |
raideva |
B |
June 16, 2022, 5:16 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
202 |
11059200 |
|
1200 |
160883885 |
iron_nicko |
B |
June 16, 2022, 4:31 p.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
62 |
3481600 |
|
1200 |
160888356 |
fefefefta |
B |
June 16, 2022, 5:03 p.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
77 |
3379200 |
|
1200 |
160911227 |
majay1638 |
B |
June 17, 2022, 12:43 a.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
77 |
4096000 |
|
1200 |
160890744 |
gesuta |
B |
June 16, 2022, 5:18 p.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
77 |
4198400 |
|
1200 |
160883435 |
govindp47 |
B |
June 16, 2022, 4:30 p.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
77 |
4198400 |
|
1200 |
160890013 |
Shirotsume |
B |
June 16, 2022, 5:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
78 |
14438400 |
|
1200 |
160879504 |
3juhwan |
B |
June 16, 2022, 4:20 p.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
92 |
4915200 |
|
1200 |
160880028 |
Aksnov |
B |
June 16, 2022, 4:22 p.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
92 |
14131200 |
|
1200 |
160922426 |
summertony717 |
B |
June 17, 2022, 5:24 a.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
93 |
3584000 |
|
1200 |
160888676 |
okbuddy |
B |
June 16, 2022, 5:04 p.m. |
OK |
PyPy 3-64 |
TESTS |
8 |
93 |
4096000 |
|
1200 |
160914801 |
CodyTheWolf |
B |
June 17, 2022, 2:46 a.m. |
OK |
Python 3 |
TESTS |
8 |
62 |
409600 |
|
1200 |
160890997 |
MananJain_2002 |
B |
June 16, 2022, 5:20 p.m. |
OK |
Python 3 |
TESTS |
8 |
62 |
409600 |
|
1200 |
160878801 |
_N_0_0_B_ |
B |
June 16, 2022, 4:19 p.m. |
OK |
Python 3 |
TESTS |
8 |
92 |
614400 |
|
1200 |
160921543 |
rvranjan99 |
B |
June 17, 2022, 5:09 a.m. |
OK |
Python 3 |
TESTS |
8 |
93 |
204800 |
|
1200 |
160920536 |
MuhammadAMMAR |
B |
June 17, 2022, 4:52 a.m. |
OK |
Python 3 |
TESTS |
8 |
93 |
204800 |
|
1200 |
160917895 |
aravind21 |
B |
June 17, 2022, 3:59 a.m. |
OK |
Python 3 |
TESTS |
8 |
93 |
204800 |
|
1200 |
160905100 |
gotcoding124 |
B |
June 16, 2022, 8:37 p.m. |
OK |
Python 3 |
TESTS |
8 |
93 |
204800 |
|
1200 |
160897957 |
fhhuo |
B |
June 16, 2022, 6:32 p.m. |
OK |
Python 3 |
TESTS |
8 |
93 |
204800 |
|
1200 |
160888923 |
mj_oppo |
B |
June 16, 2022, 5:06 p.m. |
OK |
Python 3 |
TESTS |
8 |
93 |
204800 |
|
1200 |
160882983 |
srikanthreddy691 |
B |
June 16, 2022, 4:29 p.m. |
OK |
Python 3 |
TESTS |
8 |
93 |
204800 |
|
1200 |
160899435 |
kokkuri |
B |
June 16, 2022, 6:53 p.m. |
OK |
Ruby 3 |
TESTS |
8 |
265 |
14848000 |
|
1200 |
160899178 |
utkarsh |
B |
June 16, 2022, 6:50 p.m. |
OK |
Ruby 3 |
TESTS |
8 |
296 |
819200 |
|
1200 |
160910537 |
magnus.hegdahl |
B |
June 17, 2022, 12:09 a.m. |
OK |
Rust 2021 |
TESTS |
8 |
15 |
1740800 |
|
1200 |
160901987 |
cottoncotton |
B |
June 16, 2022, 7:33 p.m. |
OK |
Rust 2021 |
TESTS |
8 |
31 |
67481600 |
|
1200 |
remove filters
Back to search problems