Codeforces Round 1032 (Div. 3)

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
2121 Codeforces Round 1032 (Div. 3) FINISHED False 8100 26234723 June 17, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 5331 ) G Gangsta PROGRAMMING data structures divide and conquer math sortings

You are given a binary string (s_1s_2 \ldots s_n) of length (n). A string (s) is called binary if it consists only of zeros and ones. For a string (p), we define the function (f(p)) as the maximum number of occurrences of any character in the string (p). For example, (f(00110) = 3), (f(01) = 1). You need to find the sum (f(s_ls_{l+1} \ldots s_r)) for all pairs (1 \leq l \leq r \leq n). Each test consists of multiple test cases. The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. Then follows their descriptions. The first line of each test case contains a single integer (n) ((1 \le n \le 2 \cdot 10^5)) — the length of the binary string. The second line of each test case contains a string of length (n), consisting of (0)s and (1)s — the binary string (s). 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 sum (f(s_ls_{l+1} \ldots s_r)) for all pairs (1 \leq l \leq r \leq n). In the first test case, the string (s) has one substring, and the value (f(0) = 1). In the second test case, all substrings of the string (s) are (0), (01), (1). And the answer is (1 + 1 + 1 = 3), respectively. In the third test case, all substrings of the string (s) are (0), (01), (011), (0110), (1), (11), (110), (1), (10), (0). And the answer is (1 + 1 + 2 + 2 + 1 + 2 + 2 + 1 + 1 + 1 = 14), respectively.

Tutorials

Codeforces Round 1032 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
324980021 KrishnaSh1355 G June 18, 2025, 5:11 a.m. OK C++17 (GCC 7-32) TESTS 20 61 0
324978219 yashgo9878 G June 18, 2025, 4:52 a.m. OK C++17 (GCC 7-32) TESTS 20 61 102400
324982128 NXDXML G June 18, 2025, 5:33 a.m. OK C++17 (GCC 7-32) TESTS 20 62 0
324978466 el-platano G June 18, 2025, 4:54 a.m. OK C++17 (GCC 7-32) TESTS 20 62 0
324977879 lcs2021033 G June 18, 2025, 4:48 a.m. OK C++17 (GCC 7-32) TESTS 20 62 0
324963687 orange_trie G June 18, 2025, 1:42 a.m. OK C++17 (GCC 7-32) TESTS 20 62 0
324973886 Jes124 G June 18, 2025, 4:04 a.m. OK C++17 (GCC 7-32) TESTS 20 62 102400
324958080 Marco__Reus G June 17, 2025, 11:05 p.m. OK C++17 (GCC 7-32) TESTS 20 62 102400
324948231 G1e61k G June 17, 2025, 7:38 p.m. OK C++17 (GCC 7-32) TESTS 20 62 102400
324945373 Hasanv G June 17, 2025, 7:03 p.m. OK C++17 (GCC 7-32) TESTS 20 62 102400
324960558 lei123456 G June 18, 2025, 12:35 a.m. OK C++20 (GCC 13-64) TESTS 20 46 0
324980364 pugaz2006 G June 18, 2025, 5:15 a.m. OK C++20 (GCC 13-64) TESTS 20 46 102400
324943934 Nxxlt G June 17, 2025, 6:46 p.m. OK C++20 (GCC 13-64) TESTS 20 46 102400
324940095 Kanishqq_3eye2 G June 17, 2025, 6:09 p.m. OK C++20 (GCC 13-64) TESTS 20 46 102400
324947014 Guanexxx G June 17, 2025, 7:23 p.m. OK C++20 (GCC 13-64) TESTS 20 46 3276800
324948819 Layla_Abdalla G June 17, 2025, 7:46 p.m. OK C++20 (GCC 13-64) TESTS 20 61 0
324938609 sunny-Pro G June 17, 2025, 5:56 p.m. OK C++20 (GCC 13-64) TESTS 20 61 102400
324925328 StarNightSnow G June 17, 2025, 5:05 p.m. OK C++20 (GCC 13-64) TESTS 20 61 102400
324922766 fanhuaxingyu G June 17, 2025, 4:53 p.m. OK C++20 (GCC 13-64) TESTS 20 61 102400
324921743 GENERATIONAL_TALENT G June 17, 2025, 4:49 p.m. OK C++20 (GCC 13-64) TESTS 20 61 102400
324966240 msp_008987 G June 18, 2025, 2:25 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 0
324983566 zeemanz G June 18, 2025, 5:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 102400
324972116 fishcathu G June 18, 2025, 3:44 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 102400
324966046 nhirsama G June 18, 2025, 2:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 102400
324959654 _MANS0UR_ G June 18, 2025, 12:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 102400
324956234 Kener_Castillo G June 17, 2025, 10:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 102400
324943691 ravich_0395 G June 17, 2025, 6:44 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 102400
324942249 king2008 G June 17, 2025, 6:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 102400
324960574 bangan G June 18, 2025, 12:35 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 512000
324979031 Srginit286 G June 18, 2025, 5:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 46 819200
324923254 pengin_2000 G June 17, 2025, 4:54 p.m. OK GNU C11 TESTS 20 62 3481600
324920622 kprateek302 G June 17, 2025, 4:48 p.m. OK GNU C11 TESTS 20 77 14745600
324920620 _ironman_3000 G June 17, 2025, 4:48 p.m. OK Go TESTS 20 77 4915200
324921510 yuvrajye G June 17, 2025, 4:49 p.m. OK Java 21 TESTS 20 296 716800
324920360 vive02-xo G June 17, 2025, 4:48 p.m. OK Java 21 TESTS 20 374 1228800
324968532 man-ray G June 18, 2025, 2:58 a.m. OK Java 21 TESTS 20 436 41984000
324929006 Shashi_Prakash_R_S G June 17, 2025, 5:31 p.m. OK Java 21 TESTS 20 531 30822400
324965397 268555 G June 18, 2025, 2:12 a.m. OK Java 21 TESTS 20 686 6348800
324939718 kasiru_69 G June 17, 2025, 6:06 p.m. OK Java 8 TESTS 20 187 0
324926171 abhijeet29102004 G June 17, 2025, 5:11 p.m. OK Java 8 TESTS 20 265 0
324928775 tough_kenya G June 17, 2025, 5:29 p.m. OK Mono C# TESTS 20 109 9420800
324979829 gardengnome G June 18, 2025, 5:09 a.m. OK PyPy 3-64 TESTS 20 108 5734400
324965907 gardengnome G June 18, 2025, 2:20 a.m. OK PyPy 3-64 TESTS 20 109 5632000
324944097 siuhou G June 17, 2025, 6:48 p.m. OK PyPy 3-64 TESTS 20 109 5836800
324950099 crystal_castles G June 17, 2025, 8:03 p.m. OK PyPy 3-64 TESTS 20 124 5222400
324929814 smz.26 G June 17, 2025, 5:37 p.m. OK PyPy 3-64 TESTS 20 124 7372800
324979631 kamio-misuzu G June 18, 2025, 5:07 a.m. OK PyPy 3-64 TESTS 20 124 9420800
324980157 kamio-misuzu G June 18, 2025, 5:12 a.m. OK PyPy 3-64 TESTS 20 139 5734400
324979956 kamio-misuzu G June 18, 2025, 5:10 a.m. OK PyPy 3-64 TESTS 20 140 12902400
324920862 shrmx G June 17, 2025, 4:49 p.m. OK PyPy 3-64 TESTS 20 155 8908800
324943627 KAMITO G June 17, 2025, 6:43 p.m. OK PyPy 3-64 TESTS 20 155 9318400
324925689 mhzprnc G June 17, 2025, 5:07 p.m. OK Python 2 TESTS 20 1906 11673600
324920970 jaikanthkamisetti001 G June 17, 2025, 4:49 p.m. OK Python 3 TESTS 20 140 10956800
324921234 Akshat_Lakhera G June 17, 2025, 4:49 p.m. OK Python 3 TESTS 20 999 32358400
324921099 immortal2121 G June 17, 2025, 4:49 p.m. OK Python 3 TESTS 20 1530 22118400
324921236 Akash_Baidya2005 G June 17, 2025, 4:49 p.m. OK Python 3 TESTS 20 1531 30720000
324919343 dkasfs2234 G June 17, 2025, 4:47 p.m. OK Python 3 TESTS 20 1531 30720000

remove filters

Back to search problems