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"A binary string s of length n is given. A binary string is a string consisting only of the characters '1' and '0'. You can choose an integer k ( 1 <= k <= n ) and then apply the following operation any number of times: choose k consecutive characters of the string and invert them, i.e., replace all '0' with '1' and vice versa. Using these operations, you need to make all the characters in the string equal to '1'. For example, if n=5 , s=00100 , you can choose k=3 and proceed as follows: Find the maximum value of k for which it is possible to make all the characters in the string equal to '1' using the described operations. Note that the number of operations required to achieve this is not important. The first line contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The first line of each test case contains an integer n ( 1 <= n <= 5000 ) -- the length of the string s . The second line of each test case contains a string s of length n , consisting of the characters '1' and '0'. It is guaranteed that the sum of the values n^2 over all test cases in the test does not exceed 25 cdot 10^6 . For each test case, output the maximum integer k ( 1 <= k <= n ) for which it is possible to obtain a string s consisting only of the characters '1' using the described operations. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
255801266 |
karamkontar |
E |
April 9, 2024, 12:52 a.m. |
OK |
C# 10 |
TESTS |
12 |
124 |
2969600 |
|
|
255791163 |
tellowart |
E |
April 8, 2024, 9:42 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
93 |
0 |
|
|
255805112 |
Bree_Cui |
E |
April 9, 2024, 1:58 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
93 |
102400 |
|
|
255809984 |
zheng00 |
E |
April 9, 2024, 3:06 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
93 |
1843200 |
|
|
255769643 |
ADS2K |
E |
April 8, 2024, 6:01 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
109 |
0 |
|
|
255811622 |
xyacaaa |
E |
April 9, 2024, 3:26 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
109 |
102400 |
|
|
255799440 |
KhanhTP165 |
E |
April 9, 2024, 12:20 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
124 |
0 |
|
|
255771639 |
anu82sharma12 |
E |
April 8, 2024, 6:16 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
124 |
102400 |
|
|
255811214 |
suzukasan |
E |
April 9, 2024, 3:21 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
124 |
409600 |
|
|
255809961 |
idontknow233 |
E |
April 9, 2024, 3:06 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
125 |
102400 |
|
|
255813054 |
Rating_10101010 |
E |
April 9, 2024, 3:44 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
12 |
140 |
102400 |
|
|
255800453 |
buzhii_ |
E |
April 9, 2024, 12:37 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
61 |
0 |
|
|
255814501 |
Actium |
E |
April 9, 2024, 4:02 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
77 |
0 |
|
|
255811358 |
AlexaV |
E |
April 9, 2024, 3:23 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
78 |
0 |
|
|
255809373 |
NXDXML |
E |
April 9, 2024, 2:58 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
93 |
0 |
|
|
255800207 |
18982913323 |
E |
April 9, 2024, 12:33 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
93 |
0 |
|
|
255824615 |
goat07 |
E |
April 9, 2024, 5:52 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
93 |
102400 |
|
|
255821048 |
Gen1us_1 |
E |
April 9, 2024, 5:18 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
93 |
102400 |
|
|
255819555 |
Atishay_23 |
E |
April 9, 2024, 5:03 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
93 |
102400 |
|
|
255816495 |
tcdthz |
E |
April 9, 2024, 4:28 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
93 |
102400 |
|
|
255815144 |
CuteJerry |
E |
April 9, 2024, 4:10 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
12 |
93 |
102400 |
|
|
255812309 |
HWJHWJ |
E |
April 9, 2024, 3:35 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
46 |
0 |
|
|
255798869 |
enslaved |
E |
April 9, 2024, 12:09 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
61 |
0 |
|
|
255789844 |
el_tunel |
E |
April 8, 2024, 9:23 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
77 |
0 |
|
|
255800937 |
CarlosS48 |
E |
April 9, 2024, 12:47 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
77 |
102400 |
|
|
255775181 |
415411 |
E |
April 8, 2024, 6:45 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
77 |
102400 |
|
|
255772461 |
tih-a |
E |
April 8, 2024, 6:23 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
77 |
204800 |
|
|
255797473 |
TheRedStone |
E |
April 8, 2024, 11:38 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
78 |
102400 |
|
|
255766663 |
manishjha91 |
E |
April 8, 2024, 5:42 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
78 |
102400 |
|
|
255800033 |
Rainer1116 |
E |
April 9, 2024, 12:30 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
78 |
9113600 |
|
|
255819769 |
coderstack |
E |
April 9, 2024, 5:06 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
12 |
92 |
102400 |
|
|
255809878 |
ruban |
E |
April 9, 2024, 3:05 a.m. |
OK |
Delphi |
TESTS |
12 |
281 |
9216000 |
|
|
255767487 |
leoncn |
E |
April 8, 2024, 5:47 p.m. |
OK |
Java 21 |
TESTS |
12 |
280 |
716800 |
|
|
255768485 |
coder0687 |
E |
April 8, 2024, 5:53 p.m. |
OK |
Java 21 |
TESTS |
12 |
296 |
716800 |
|
|
255815812 |
neilchetty |
E |
April 9, 2024, 4:19 a.m. |
OK |
Java 21 |
TESTS |
12 |
359 |
716800 |
|
|
255819736 |
arnav_gupta |
E |
April 9, 2024, 5:05 a.m. |
OK |
Java 21 |
TESTS |
12 |
374 |
716800 |
|
|
255777578 |
himneesh9 |
E |
April 8, 2024, 7:06 p.m. |
OK |
Java 21 |
TESTS |
12 |
656 |
921600 |
|
|
255788618 |
polsage |
E |
April 8, 2024, 9:07 p.m. |
OK |
Java 21 |
TESTS |
12 |
874 |
716800 |
|
|
255786311 |
codeWithDarshan |
E |
April 8, 2024, 8:39 p.m. |
OK |
Java 21 |
TESTS |
12 |
952 |
307200 |
|
|
255807834 |
df08.22_ |
E |
April 9, 2024, 2:37 a.m. |
OK |
Java 21 |
TESTS |
12 |
1093 |
819200 |
|
|
255821521 |
Nagendravarma |
E |
April 9, 2024, 5:23 a.m. |
OK |
Java 8 |
TESTS |
12 |
264 |
0 |
|
|
255778020 |
Freedom_lifelong |
E |
April 8, 2024, 7:11 p.m. |
OK |
Java 8 |
TESTS |
12 |
280 |
0 |
|
|
255789182 |
Sumitsingh7 |
E |
April 8, 2024, 9:14 p.m. |
OK |
Java 8 |
TESTS |
12 |
312 |
6758400 |
|
|
255824635 |
Sumitsingh7 |
E |
April 9, 2024, 5:52 a.m. |
OK |
Java 8 |
TESTS |
12 |
514 |
6758400 |
|
|
255776875 |
Yousef_Badr |
E |
April 8, 2024, 7 p.m. |
OK |
Java 8 |
TESTS |
12 |
827 |
0 |
|
|
255773504 |
formidablechief27 |
E |
April 8, 2024, 6:31 p.m. |
OK |
Java 8 |
TESTS |
12 |
1234 |
39526400 |
|
|
255781324 |
Lakshay429 |
E |
April 8, 2024, 7:44 p.m. |
OK |
Java 8 |
TESTS |
12 |
2187 |
0 |
|
|
255780176 |
Crazy67 |
E |
April 8, 2024, 7:32 p.m. |
OK |
Kotlin 1.9 |
TESTS |
12 |
233 |
0 |
|
|
255810867 |
YMSeah |
E |
April 9, 2024, 3:16 a.m. |
OK |
PyPy 3 |
TESTS |
12 |
468 |
9113600 |
|
|
255767914 |
torqueaj |
E |
April 8, 2024, 5:50 p.m. |
OK |
PyPy 3 |
TESTS |
12 |
1593 |
10649600 |
|
|
255808919 |
ankan2526 |
E |
April 9, 2024, 2:52 a.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
233 |
139366400 |
|
|
255804978 |
RobinFromTheHood |
E |
April 9, 2024, 1:56 a.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
250 |
8806400 |
|
|
255782167 |
SoleProprietor |
E |
April 8, 2024, 7:53 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
265 |
8601600 |
|
|
255808286 |
smilences |
E |
April 9, 2024, 2:44 a.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
265 |
9011200 |
|
|
255768626 |
nonam33 |
E |
April 8, 2024, 5:54 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
280 |
9728000 |
|
|
255768721 |
blue_clay |
E |
April 8, 2024, 5:55 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
281 |
8806400 |
|
|
255773684 |
edgerunner |
E |
April 8, 2024, 6:32 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
311 |
9728000 |
|
|
255807951 |
JinYuManTang |
E |
April 9, 2024, 2:39 a.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
327 |
9216000 |
|
|
255809930 |
whatCanISay-ggl |
E |
April 9, 2024, 3:05 a.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
327 |
9420800 |
|
|
255805442 |
AldyDPP |
E |
April 9, 2024, 2:03 a.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
327 |
9728000 |
|
|
255766513 |
isakovii |
E |
April 8, 2024, 5:41 p.m. |
OK |
Python 3 |
TESTS |
12 |
2389 |
307200 |
|
|
255797821 |
ZarthaxX |
E |
April 8, 2024, 11:46 p.m. |
OK |
Python 3 |
TESTS |
12 |
2718 |
102400 |
|
|
255808444 |
winter_l |
E |
April 9, 2024, 2:46 a.m. |
OK |
Rust 2021 |
TESTS |
12 |
327 |
102400 |
|
|
remove filters
Back to search problems