Codeforces Round 1070 (Div. 2)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2176 Codeforces Round 1070 (Div. 2) FINISHED False 7200 10941923 Dec. 11, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 22733 ) B Optimal Shifts PROGRAMMING bitmasks greedy strings

You are given a binary string (s_1s_2 \ldots s_n), containing at least one 1 . You want to obtain a binary string of the same length, consisting only of 1 s. To do this, you can perform the following operation any number of times: Choose a number (d) ((1 \le d \le n)) and consider the string (t) as a cyclic right shift of the string (s) by (d), or, more formally, (t = s_{n - d + 1} \ldots s_{n}s_{1} \ldots s_{n - d}). After that, for all (j) for which (t_j = 1), perform (s_j := 1). The described operation costs (d) coins, where (d) is the chosen shift amount. Note that the positions (j) in the string (s), where initially (s_j=1), remain equal to (1) even if (t_j=0). You need to determine the minimum number of coins that can be spent so that the string (s) consists only of 1 s after all operations. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains the number (n) ((1 \le n \le 2 \cdot 10^5)) — the size of the given binary string. The second line of each test case contains a binary string of length (n), each element of which is either 0 or 1 . It is guaranteed that at least one character in each string is equal to 1 . It is guaranteed that the sum of (n) across all test cases does not exceed (2 \cdot 10^5). For each test case, output the answer to it — the minimum possible number of coins that you can spend to make all characters in the string equal to 1 . Consider the third example, where (s =) "0110". In this case, it is optimal to choose (d = 2), then (t =) "1001". After that, at positions (j = 1) and (j = 4), (s_j) will be replaced with 1, resulting in the string (s) consisting of all ones. Note that the cost of this operation is (d = 2).

Tutorials

Codeforces Round 1070 (Div.2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
353148669 devks B Dec. 12, 2025, 6:09 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353148497 aashraykhairnar1 B Dec. 12, 2025, 6:07 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353147759 sid_choudhary B Dec. 12, 2025, 5:59 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353145162 Ahmed_Crusader B Dec. 12, 2025, 5:31 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353143411 SudBegula007 B Dec. 12, 2025, 5:22 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353143313 Sekiro337 B Dec. 12, 2025, 5:21 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353143128 smurfg B Dec. 12, 2025, 5:18 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353140277 pratyay_garg B Dec. 12, 2025, 4:44 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353139917 Ritesh369369 B Dec. 12, 2025, 4:40 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353137214 aksh.maheshwari05 B Dec. 12, 2025, 4:02 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
353105422 zeel_2002 B Dec. 11, 2025, 6:20 p.m. OK C++20 (GCC 13-64) TESTS 10 15 3276800
353148375 panduwapanda B Dec. 12, 2025, 6:06 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353146128 prateekbhaisora B Dec. 12, 2025, 5:41 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353146009 ps0111 B Dec. 12, 2025, 5:40 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353145414 Pranav-Bhat B Dec. 12, 2025, 5:34 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353142440 MCG_24115 B Dec. 12, 2025, 5:11 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353142141 inv1s1ble1 B Dec. 12, 2025, 5:08 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353141755 Faizal B Dec. 12, 2025, 5:03 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353141507 _UnstoppableCoder_ B Dec. 12, 2025, 5 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353141251 natkuru22 B Dec. 12, 2025, 4:57 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
353144993 Silent1314 B Dec. 12, 2025, 5:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 15 0
353139095 wavefunction B Dec. 12, 2025, 4:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 15 0
353137404 pratyakshrai01 B Dec. 12, 2025, 4:05 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 15 0
353103448 gs008 B Dec. 11, 2025, 6:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 15 0
353089532 timubhaitimubhai B Dec. 11, 2025, 4:28 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 15 0
353084892 abhaysingh14434 B Dec. 11, 2025, 4:17 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 15 102400
353148724 Feliks_Zem B Dec. 12, 2025, 6:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
353147708 Shyamuraicoder B Dec. 12, 2025, 5:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
353147548 ElectroBoy B Dec. 12, 2025, 5:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
353147272 second_acc B Dec. 12, 2025, 5:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
353089396 revanth66 B Dec. 11, 2025, 4:27 p.m. OK GNU C11 TESTS 10 31 102400
353118390 shanda394 B Dec. 11, 2025, 8:27 p.m. OK GNU C11 TESTS 10 31 204800
353088943 EkinIOT B Dec. 11, 2025, 4:26 p.m. OK GNU C11 TESTS 10 31 204800
353091680 Sayantan_Hazra B Dec. 11, 2025, 4:32 p.m. OK GNU C11 TESTS 10 46 102400
353133695 mijaso B Dec. 12, 2025, 2:56 a.m. OK GNU C11 TESTS 10 46 204800
353091982 naman_15 B Dec. 11, 2025, 4:33 p.m. OK GNU C11 TESTS 10 46 204800
353082979 Gourav314 B Dec. 11, 2025, 4:13 p.m. OK GNU C11 TESTS 10 46 204800
353082834 magniquick B Dec. 11, 2025, 4:13 p.m. OK GNU C11 TESTS 10 46 204800
353105091 abhi070907 B Dec. 11, 2025, 6:18 p.m. OK GNU C11 TESTS 10 46 307200
353092322 anakhveer B Dec. 11, 2025, 4:33 p.m. OK GNU C11 TESTS 10 46 716800
353122275 bailimice B Dec. 11, 2025, 9:28 p.m. OK Go TESTS 10 31 5017600
353089976 FREDDY_HERE B Dec. 11, 2025, 4:29 p.m. OK Java 21 TESTS 10 171 409600
353125100 Asmitzzz B Dec. 11, 2025, 10:32 p.m. OK Java 21 TESTS 10 187 0
353104960 sakshams7778 B Dec. 11, 2025, 6:17 p.m. OK Java 21 TESTS 10 187 1638400
353147202 NpHardcore_05 B Dec. 12, 2025, 5:53 a.m. OK Java 21 TESTS 10 187 3993600
353128951 sathwikhbhat B Dec. 12, 2025, 12:45 a.m. OK Java 21 TESTS 10 203 409600
353109566 vineetiwari B Dec. 11, 2025, 6:52 p.m. OK Java 21 TESTS 10 203 409600
353088695 keerthan1428 B Dec. 11, 2025, 4:26 p.m. OK Java 21 TESTS 10 203 1126400
353102671 Tania_Nawyaj B Dec. 11, 2025, 6:01 p.m. OK Java 21 TESTS 10 203 1740800
353129571 bianchengcaiji B Dec. 12, 2025, 1:07 a.m. OK Java 21 TESTS 10 218 1228800
353090948 manya__1323 B Dec. 11, 2025, 4:31 p.m. OK Java 21 TESTS 10 218 1536000
353084470 aditya_0013 B Dec. 11, 2025, 4:16 p.m. OK Java 8 TESTS 10 109 0
353120825 akki_code B Dec. 11, 2025, 9:05 p.m. OK Java 8 TESTS 10 125 0
353089403 hanjxnny B Dec. 11, 2025, 4:28 p.m. OK Java 8 TESTS 10 125 0
353101155 Extradict B Dec. 11, 2025, 5:52 p.m. OK Java 8 TESTS 10 125 6451200
353146385 krishnandu01 B Dec. 12, 2025, 5:44 a.m. OK Java 8 TESTS 10 140 0
353130602 vijesh123 B Dec. 12, 2025, 1:38 a.m. OK Java 8 TESTS 10 140 0
353090156 levi-003 B Dec. 11, 2025, 4:29 p.m. OK Java 8 TESTS 10 140 0
353088383 sriharidharun2005 B Dec. 11, 2025, 4:25 p.m. OK Java 8 TESTS 10 140 0
353083022 traybug B Dec. 11, 2025, 4:13 p.m. OK Java 8 TESTS 10 140 0
353088072 dhruvv.j B Dec. 11, 2025, 4:24 p.m. OK Java 8 TESTS 10 156 0
353092551 Homka_666 B Dec. 11, 2025, 4:33 p.m. OK Node.js TESTS 10 234 8089600
353087685 SalicylicAcid B Dec. 11, 2025, 4:24 p.m. OK PyPy 3 TESTS 10 93 7680000
353085905 Asterix22 B Dec. 11, 2025, 4:20 p.m. OK PyPy 3-64 TESTS 10 62 12492800
353138529 bradyji2006 B Dec. 12, 2025, 4:21 a.m. OK PyPy 3-64 TESTS 10 78 2969600
353084325 Adilet_Azo B Dec. 11, 2025, 4:16 p.m. OK PyPy 3-64 TESTS 10 78 3174400
353092288 Avinash_Babu B Dec. 11, 2025, 4:33 p.m. OK PyPy 3-64 TESTS 10 78 4403200
353088369 anandchirag31 B Dec. 11, 2025, 4:25 p.m. OK PyPy 3-64 TESTS 10 78 12492800
353104554 elferjani B Dec. 11, 2025, 6:14 p.m. OK PyPy 3-64 TESTS 10 93 3788800
353108037 TruthSeekerGT B Dec. 11, 2025, 6:39 p.m. OK PyPy 3-64 TESTS 10 93 3891200
353124995 whizzingpig B Dec. 11, 2025, 10:30 p.m. OK PyPy 3-64 TESTS 10 93 4608000
353098612 AAE B Dec. 11, 2025, 5:38 p.m. OK PyPy 3-64 TESTS 10 93 5427200
353114963 PseudoSol B Dec. 11, 2025, 7:45 p.m. OK PyPy 3-64 TESTS 10 93 8601600
353111203 vedjaw B Dec. 11, 2025, 7:07 p.m. OK Python 2 TESTS 10 78 2867200
353085219 FerryMan27 B Dec. 11, 2025, 4:18 p.m. OK Python 3 TESTS 10 62 3276800
353087444 c.jsanchez220 B Dec. 11, 2025, 4:23 p.m. OK Python 3 TESTS 10 78 2355200
353084680 celestial_ash B Dec. 11, 2025, 4:17 p.m. OK Python 3 TESTS 10 78 3276800
353089069 satwiksps B Dec. 11, 2025, 4:27 p.m. OK Python 3 TESTS 10 78 4812800
353087914 proust_38 B Dec. 11, 2025, 4:24 p.m. OK Python 3 TESTS 10 78 5427200
353084472 _sreedevesh B Dec. 11, 2025, 4:16 p.m. OK Python 3 TESTS 10 78 5427200
353124244 neelkamalkumar230 B Dec. 11, 2025, 10:09 p.m. OK Python 3 TESTS 10 93 716800
353090224 tamayanb B Dec. 11, 2025, 4:29 p.m. OK Python 3 TESTS 10 93 716800
353084736 sujalsom22 B Dec. 11, 2025, 4:17 p.m. OK Python 3 TESTS 10 93 716800
353145282 5thClassWasGood B Dec. 12, 2025, 5:32 a.m. OK Python 3 TESTS 10 93 819200
353128677 macaroni5708 B Dec. 12, 2025, 12:36 a.m. OK Rust 2021 TESTS 10 46 1843200

remove filters

Back to search problems