Educational Codeforces Round 183 (Rated for 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
2145 Educational Codeforces Round 183 (Rated for Div. 2) FINISHED False 7200 16644323 Oct. 6, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 15303 ) C Monocarp's String PROGRAMMING binary search greedy strings

Monocarp has a string (s) of length (n), consisting of the letters ' a ' and ' b '. He wants to remove some (possibly zero) number of consecutive letters from his string in such a way that the number of letters ' a ' and ' b ' in the resulting string becomes equal. Monocarp can start removing letters from any position in the string (s). Monocarp really likes his string (s), so he wants to remove as few consecutive letters from it as possible. Your task is to determine the minimum number of consecutive letters from the string (s) that need to be removed so that the number of letters ' a ' and ' b ' in the resulting string becomes equal. If it is necessary to remove all letters from the string (s) (i.e., make it empty), report this. The first line contains one integer (t) ((1 \le t \le 10^4)) — the number of test cases. Each test case consists of two lines: the first line contains one integer (n) ((2 \le n \le 2 \cdot 10^5)) — the number of characters in the string (s); the second line contains the string (s) of length (n), consisting of the letters ' a ' and/or ' b '. Additional constraint on the input: the sum of values of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, print the answer as follows: If in order to make the number of letters ' a ' and ' b ' equal, it is necessary to remove all letters from the string (s), output (-1). Otherwise, output the minimum number of consecutive letters that Monocarp needs to remove from his string (s) so that the number of letters ' a ' and ' b ' becomes equal. In the first example, Monocarp needs to remove the first three letters from his string. After that, his string will become " ab ". In this string, there is one letter ' a ' and one letter ' b '. In the second example, the given string has three letters ' a ' and three letters ' b ', so nothing needs to be removed. In the third example, all letters of the string

Tutorials

Educational Codeforces Round 183 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
342359645 doola C Oct. 6, 2025, 8:55 p.m. OK C# 10 TESTS 24 265 9932800
342513844 mahmudur9 C Oct. 7, 2025, 10:36 p.m. OK C# 13 TESTS 24 124 14233600
342511440 mahmudur9 C Oct. 7, 2025, 9:35 p.m. OK C# 13 TESTS 24 124 14233600
342510792 mahmudur9 C Oct. 7, 2025, 9:22 p.m. OK C# 13 TESTS 24 155 14233600
342520980 phuongnghi lkt C Oct. 8, 2025, 1:42 a.m. OK C++17 (GCC 7-32) TESTS 24 46 204800
342421920 verma_aakash C Oct. 7, 2025, 10:35 a.m. OK C++17 (GCC 7-32) TESTS 24 61 0
342472483 handzhao2318593985 C Oct. 7, 2025, 4:10 p.m. OK C++17 (GCC 7-32) TESTS 24 62 0
342436743 handzhao2318593985 C Oct. 7, 2025, 12:30 p.m. OK C++17 (GCC 7-32) TESTS 24 62 0
342409467 ankitkr0004 C Oct. 7, 2025, 8:53 a.m. OK C++17 (GCC 7-32) TESTS 24 62 102400
342419701 Radhe_Radhe07 C Oct. 7, 2025, 10:17 a.m. OK C++17 (GCC 7-32) TESTS 24 62 204800
342404835 ahonmilestone C Oct. 7, 2025, 8:17 a.m. OK C++17 (GCC 7-32) TESTS 24 62 204800
342484868 PRIDE_ C Oct. 7, 2025, 5:27 p.m. OK C++17 (GCC 7-32) TESTS 24 62 614400
342347131 c0mm4nd C Oct. 6, 2025, 6:42 p.m. OK C++17 (GCC 7-32) TESTS 24 62 614400
342371053 Adarsh_Jupudi C Oct. 7, 2025, 1:27 a.m. OK C++17 (GCC 7-32) TESTS 24 62 1433600
342534068 PREMM_DESAI C Oct. 8, 2025, 5:01 a.m. OK C++20 (GCC 13-64) TESTS 24 46 0
342428537 TimoFace C Oct. 7, 2025, 11:26 a.m. OK C++20 (GCC 13-64) TESTS 24 46 0
342421837 anik114911 C Oct. 7, 2025, 10:34 a.m. OK C++20 (GCC 13-64) TESTS 24 46 102400
342383414 Wu_Xin_45 C Oct. 7, 2025, 4:38 a.m. OK C++20 (GCC 13-64) TESTS 24 46 102400
342537276 asdfghqwert C Oct. 8, 2025, 5:35 a.m. OK C++20 (GCC 13-64) TESTS 24 46 921600
342340852 MonHamed C Oct. 6, 2025, 5:57 p.m. OK C++20 (GCC 13-64) TESTS 24 61 102400
342497899 Kr.omniscient C Oct. 7, 2025, 6:55 p.m. OK C++20 (GCC 13-64) TESTS 24 61 4812800
342368997 Siyam_Talukder C Oct. 7, 2025, 12:45 a.m. OK C++20 (GCC 13-64) TESTS 24 61 4812800
342491376 ali43 C Oct. 7, 2025, 6:09 p.m. OK C++20 (GCC 13-64) TESTS 24 62 0
342507119 nwblanton C Oct. 7, 2025, 8:26 p.m. OK C++20 (GCC 13-64) TESTS 24 62 102400
342528183 rdcamelot C Oct. 8, 2025, 3:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 46 0
342528572 wuyuqian C Oct. 8, 2025, 3:48 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 46 10854400
342482166 saketkumar3245 C Oct. 7, 2025, 5:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 61 0
342505124 sandeepk775775 C Oct. 7, 2025, 8:02 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 61 102400
342463634 NayemVai C Oct. 7, 2025, 3:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 61 102400
342439441 Thirstarfish C Oct. 7, 2025, 12:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 61 102400
342371919 zzh.free C Oct. 7, 2025, 1:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 61 102400
342525101 Bramer_x C Oct. 8, 2025, 2:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 61 1536000
342406192 manideepanasuri C Oct. 7, 2025, 8:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 61 1638400
342387175 deepbuha06 C Oct. 7, 2025, 5:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 61 1740800
342352509 NenadDapic C Oct. 6, 2025, 7:29 p.m. OK FPC TESTS 24 77 2457600
342508628 dzhabrailovhuseyn C Oct. 7, 2025, 8:47 p.m. OK Go TESTS 24 78 13414400
342406490 amit_roy C Oct. 7, 2025, 8:30 a.m. OK Java 21 TESTS 24 281 6656000
342504841 LordKRiS C Oct. 7, 2025, 7:58 p.m. OK Java 21 TESTS 24 296 6348800
342412018 EreNYeaGeR1 C Oct. 7, 2025, 9:15 a.m. OK Java 21 TESTS 24 296 7065600
342362420 vineetiwari C Oct. 6, 2025, 9:42 p.m. OK Java 21 TESTS 24 296 14438400
342539029 AKhacks C Oct. 8, 2025, 5:51 a.m. OK Java 21 TESTS 24 296 17612800
342490140 keshav14 C Oct. 7, 2025, 6:01 p.m. OK Java 21 TESTS 24 311 15667200
342443124 kartik__sethi C Oct. 7, 2025, 1:23 p.m. OK Java 21 TESTS 24 311 17920000
342490467 Harsh_rajak12 C Oct. 7, 2025, 6:03 p.m. OK Java 21 TESTS 24 312 5222400
342347461 vellacoder1 C Oct. 6, 2025, 6:44 p.m. OK Java 21 TESTS 24 312 7372800
342502231 NischayCodes C Oct. 7, 2025, 7:32 p.m. OK Java 21 TESTS 24 312 14336000
342432010 lupunish C Oct. 7, 2025, 11:51 a.m. OK Java 8 TESTS 24 187 13209600
342401937 shikharsinha117 C Oct. 7, 2025, 7:52 a.m. OK Java 8 TESTS 24 202 14540800
342402046 suntansoker C Oct. 7, 2025, 7:53 a.m. OK Java 8 TESTS 24 217 15872000
342492656 harshchhallani3 C Oct. 7, 2025, 6:18 p.m. OK Java 8 TESTS 24 218 12390400
342381180 prime29 C Oct. 7, 2025, 4:07 a.m. OK Java 8 TESTS 24 218 12492800
342386195 adibhai0845R C Oct. 7, 2025, 5:11 a.m. OK Java 8 TESTS 24 218 13107200
342453101 sarthaKKharKa_18 C Oct. 7, 2025, 2:24 p.m. OK Java 8 TESTS 24 218 14438400
342356240 yashvardhan3 C Oct. 6, 2025, 8:10 p.m. OK Java 8 TESTS 24 233 15769600
342494891 dbasu03 C Oct. 7, 2025, 6:33 p.m. OK Java 8 TESTS 24 234 15769600
342374891 kevin_0911 C Oct. 7, 2025, 2:36 a.m. OK Java 8 TESTS 24 234 17612800
342421517 malikquasran C Oct. 7, 2025, 10:32 a.m. OK Kotlin 2.2 TESTS 24 218 16588800
342348552 L-S-S C Oct. 6, 2025, 6:53 p.m. OK Kotlin 2.2 TESTS 24 249 7884800
342361269 Stormywarm C Oct. 6, 2025, 9:21 p.m. OK OCaml TESTS 24 156 3072000
342497543 andrewliu10523 C Oct. 7, 2025, 6:53 p.m. OK PyPy 3 TESTS 24 186 14950400
342363725 VivekWarkad C Oct. 6, 2025, 10:14 p.m. OK PyPy 3-64 TESTS 24 109 17817600
342531055 eugalt C Oct. 8, 2025, 4:22 a.m. OK PyPy 3-64 TESTS 24 109 21401600
342343358 gabri1135 C Oct. 6, 2025, 6:15 p.m. OK PyPy 3-64 TESTS 24 124 18227200
342502938 eugalt C Oct. 7, 2025, 7:39 p.m. OK PyPy 3-64 TESTS 24 124 20889600
342408641 smilences C Oct. 7, 2025, 8:47 a.m. OK PyPy 3-64 TESTS 24 124 21811200
342359234 kazumaa16 C Oct. 6, 2025, 8:48 p.m. OK PyPy 3-64 TESTS 24 139 18432000
342360977 minuki646 C Oct. 6, 2025, 9:16 p.m. OK PyPy 3-64 TESTS 24 139 22528000
342374589 kamio-misuzu C Oct. 7, 2025, 2:29 a.m. OK PyPy 3-64 TESTS 24 140 20992000
342439640 gardengnome C Oct. 7, 2025, 12:56 p.m. OK PyPy 3-64 TESTS 24 140 21196800
342528576 Reddi-twelve C Oct. 8, 2025, 3:48 a.m. OK PyPy 3-64 TESTS 24 140 21708800
342385534 Soyipov0512 C Oct. 7, 2025, 5:04 a.m. OK Python 3 TESTS 24 109 14438400
342503718 Shivam_Chagotra C Oct. 7, 2025, 7:46 p.m. OK Python 3 TESTS 24 139 28979200
342408814 IustinFrateanu C Oct. 7, 2025, 8:48 a.m. OK Python 3 TESTS 24 140 27750400
342480716 XGptw C Oct. 7, 2025, 5:01 p.m. OK Python 3 TESTS 24 140 29388800
342466204 tahseen123456 C Oct. 7, 2025, 3:34 p.m. OK Python 3 TESTS 24 140 31232000
342489126 PoorAcid C Oct. 7, 2025, 5:55 p.m. OK Python 3 TESTS 24 156 28057600
342446129 tah23seen C Oct. 7, 2025, 1:44 p.m. OK Python 3 TESTS 24 156 30412800
342405318 aaditya.samadhiya11 C Oct. 7, 2025, 8:21 a.m. OK Python 3 TESTS 24 171 14438400
342384747 Soyipov0512 C Oct. 7, 2025, 4:55 a.m. OK Python 3 TESTS 24 171 14438400
342385475 Soyipov0512 C Oct. 7, 2025, 5:03 a.m. OK Python 3 TESTS 24 171 14848000
342385166 silicalet C Oct. 7, 2025, 5 a.m. OK Rust 2024 TESTS 24 108 16179200
342363701 taneshqGupta C Oct. 6, 2025, 10:14 p.m. OK Rust 2024 TESTS 24 124 14131200
342363444 Singu_Larity C Oct. 6, 2025, 10:07 p.m. OK Rust 2024 TESTS 24 124 17305600

remove filters

Back to search problems