Codeforces Round 754 (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
1605 Codeforces Round 754 (Div. 2) FINISHED False 7200 100452263 Nov. 12, 2021, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 17292 ) C Dominant Character PROGRAMMING brute force implementation strings 1400

B'Ashish has a string s of length n containing only characters 'a ', 'b ' and 'c '. He wants to find the length of the smallest substring, which satisfies the following conditions: Ashish is busy planning his next Codeforces round. Help him solve the problem. A string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end. The first line contains a single integer t (1 <= t <= 10^{5}) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n (2 <= n <= 10^{6}) -- the length of the string s . The second line of each test case contains a string s consisting only of characters 'a ', 'b ' and 'c '. It is guaranteed that the sum of n over all test cases does not exceed 10^{6} . For each test case, output the length of the smallest substring which satisfies the given conditions or print -1 if there is no such substring. Consider the first test case. In the substring "aa", 'a ' occurs twice, while 'b ' and 'c ' occur zero times. Since 'a ' occurs strictly more times than 'b ' and 'c ', the substring "aa" satisfies the condition and the answer is 2 . The substring "a" also satisfies this condition, however its length is not at least 2 . In the second test case, it can be shown that in none of the substrings of "cbabb" does 'a ' occur strictly more times than 'b ' and 'c ' each. In the third test case, "cacabccc", the length of the smallest substring that satisfies the conditions is 3 . '...

Tutorials

tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
135169892 1435730 C Nov. 12, 2021, 4:33 p.m. OK GNU C11 TESTS 29 46 4710400 1400
135192474 Mrgglock C Nov. 12, 2021, 8:02 p.m. OK GNU C11 TESTS 29 62 4710400 1400
135221277 bhminh322 C Nov. 13, 2021, 5:55 a.m. OK GNU C11 TESTS 29 374 4710400 1400
135202343 cunzai_zsy0531 C Nov. 13, 2021, 12:01 a.m. OK GNU C++14 TESTS 29 30 2355200 1400
135166983 peiwenjun C Nov. 12, 2021, 4:27 p.m. OK GNU C++14 TESTS 29 46 2048000 1400
135164893 zyf1002 C Nov. 12, 2021, 4:22 p.m. OK GNU C++14 TESTS 29 46 2048000 1400
135167125 KongJohnny C Nov. 12, 2021, 4:27 p.m. OK GNU C++14 TESTS 29 46 2048000 1400
135173007 weak_child1 C Nov. 12, 2021, 5 p.m. OK GNU C++14 TESTS 29 46 2048000 1400
135211232 lavkush_1976 C Nov. 13, 2021, 3:29 a.m. OK GNU C++14 TESTS 29 46 3174400 1400
135209715 imitate20021 C Nov. 13, 2021, 3:01 a.m. OK GNU C++14 TESTS 29 46 3174400 1400
135196811 _Nox C Nov. 12, 2021, 9:18 p.m. OK GNU C++14 TESTS 29 46 3174400 1400
135180783 shubhankarrr C Nov. 12, 2021, 5:53 p.m. OK GNU C++14 TESTS 29 46 3174400 1400
135214214 ninja_456 C Nov. 13, 2021, 4:20 a.m. OK GNU C++14 TESTS 29 46 3174400 1400
135218141 xingzhi C Nov. 13, 2021, 5:19 a.m. OK GNU C++17 TESTS 29 46 2048000 1400
135208498 xhlong C Nov. 13, 2021, 2:40 a.m. OK GNU C++17 TESTS 29 46 2048000 1400
135205791 chendalao C Nov. 13, 2021, 1:43 a.m. OK GNU C++17 TESTS 29 46 2048000 1400
135205744 one_top_three C Nov. 13, 2021, 1:42 a.m. OK GNU C++17 TESTS 29 46 2048000 1400
135188215 lcaonmst C Nov. 12, 2021, 7:05 p.m. OK GNU C++17 TESTS 29 46 2048000 1400
135181377 nandini091 C Nov. 12, 2021, 5:58 p.m. OK GNU C++17 TESTS 29 46 2048000 1400
135175265 w-- C Nov. 12, 2021, 5:13 p.m. OK GNU C++17 TESTS 29 46 2048000 1400
135169606 08kevin C Nov. 12, 2021, 4:32 p.m. OK GNU C++17 TESTS 29 46 2048000 1400
135167196 113113113aaasssddd C Nov. 12, 2021, 4:27 p.m. OK GNU C++17 TESTS 29 46 2048000 1400
135213149 wrzwrzwrz C Nov. 13, 2021, 4:02 a.m. OK GNU C++17 TESTS 29 46 2048000 1400
135170439 Tatsuyaaaa C Nov. 12, 2021, 4:34 p.m. OK GNU C++17 (64) TESTS 29 31 3276800 1400
135214459 Myaljk C Nov. 13, 2021, 4:24 a.m. OK GNU C++17 (64) TESTS 29 31 3276800 1400
135218988 czswez C Nov. 13, 2021, 5:29 a.m. OK GNU C++17 (64) TESTS 29 46 2252800 1400
135213416 CODERGARV C Nov. 13, 2021, 4:06 a.m. OK GNU C++17 (64) TESTS 29 46 3276800 1400
135221610 Ch_Harsha C Nov. 13, 2021, 5:58 a.m. OK GNU C++17 (64) TESTS 29 46 3276800 1400
135214826 Asterix_29 C Nov. 13, 2021, 4:31 a.m. OK GNU C++17 (64) TESTS 29 46 3276800 1400
135205913 harshavardhan0512 C Nov. 13, 2021, 1:46 a.m. OK GNU C++17 (64) TESTS 29 46 3276800 1400
135202986 tienthinh13022005 C Nov. 13, 2021, 12:23 a.m. OK GNU C++17 (64) TESTS 29 46 3276800 1400
135196588 jesse_pinkman_619 C Nov. 12, 2021, 9:14 p.m. OK GNU C++17 (64) TESTS 29 46 3276800 1400
135192801 keijak C Nov. 12, 2021, 8:06 p.m. OK GNU C++17 (64) TESTS 29 46 3276800 1400
135165350 Mihnea_Info C Nov. 12, 2021, 4:23 p.m. OK GNU C++20 (64) TESTS 29 31 2252800 1400
135195863 bratezz C Nov. 12, 2021, 8:59 p.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135192184 vishwasmodi C Nov. 12, 2021, 7:58 p.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135187859 adit_g_kul18 C Nov. 12, 2021, 7:01 p.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135183212 Farhan20 C Nov. 12, 2021, 6:14 p.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135208087 uttammittal02 C Nov. 13, 2021, 2:32 a.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135173265 Kiraashado C Nov. 12, 2021, 5:02 p.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135172775 koderchit C Nov. 12, 2021, 4:59 p.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135170638 HaibaraAirrr C Nov. 12, 2021, 4:34 p.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135174201 tankala.msk C Nov. 12, 2021, 5:06 p.m. OK GNU C++20 (64) TESTS 29 31 3379200 1400
135194185 Fiooora C Nov. 12, 2021, 8:28 p.m. OK Go TESTS 29 405 13721600 1400
135185868 codelegend C Nov. 12, 2021, 6:39 p.m. OK Haskell TESTS 29 420 48947200 1400
135205125 the_unseen C Nov. 13, 2021, 1:26 a.m. OK Java 11 TESTS 29 217 24678400 1400
135166829 prituladima C Nov. 12, 2021, 4:27 p.m. OK Java 11 TESTS 29 217 24678400 1400
135186127 MrOtter C Nov. 12, 2021, 6:41 p.m. OK Java 11 TESTS 29 218 24576000 1400
135173513 ryanranaut C Nov. 12, 2021, 5:03 p.m. OK Java 11 TESTS 29 218 24678400 1400
135216763 himanshu_0624 C Nov. 13, 2021, 5:01 a.m. OK Java 11 TESTS 29 218 24678400 1400
135179149 nitin23329 C Nov. 12, 2021, 5:41 p.m. OK Java 11 TESTS 29 218 24780800 1400
135178809 Abhishek_patel_ C Nov. 12, 2021, 5:38 p.m. OK Java 11 TESTS 29 218 24780800 1400
135190445 moto_18 C Nov. 12, 2021, 7:34 p.m. OK Java 11 TESTS 29 233 24576000 1400
135203423 Sandy_coder2001 C Nov. 13, 2021, 12:37 a.m. OK Java 11 TESTS 29 233 24780800 1400
135178466 nitin23329 C Nov. 12, 2021, 5:35 p.m. OK Java 11 TESTS 29 248 24780800 1400
135192601 viniichuk C Nov. 12, 2021, 8:03 p.m. OK Java 8 TESTS 29 124 18944000 1400
135198474 smahajan54842 C Nov. 12, 2021, 9:54 p.m. OK Java 8 TESTS 29 139 19046400 1400
135188444 RonWonWon C Nov. 12, 2021, 7:07 p.m. OK Java 8 TESTS 29 140 18944000 1400
135187307 Hasib_Ullah C Nov. 12, 2021, 6:54 p.m. OK Java 8 TESTS 29 140 18944000 1400
135163199 Misha_Top4ik C Nov. 12, 2021, 4:18 p.m. OK Java 8 TESTS 29 140 19251200 1400
135175259 sanjayram21 C Nov. 12, 2021, 5:13 p.m. OK Java 8 TESTS 29 155 18944000 1400
135176047 jakejase2 C Nov. 12, 2021, 5:18 p.m. OK Java 8 TESTS 29 155 18944000 1400
135175667 ZiadASadek C Nov. 12, 2021, 5:15 p.m. OK Java 8 TESTS 29 155 19046400 1400
135166900 Khaled57 C Nov. 12, 2021, 4:27 p.m. OK Java 8 TESTS 29 171 25907200 1400
135175336 NerfThis C Nov. 12, 2021, 5:13 p.m. OK Java 8 TESTS 29 187 41779200 1400
135172360 Koo_Pung-Kei C Nov. 12, 2021, 4:58 p.m. OK Kotlin 1.5 TESTS 29 857 24883200 1400
135180612 huy.caohuyhuy123 C Nov. 12, 2021, 5:52 p.m. OK Kotlin 1.5 TESTS 29 919 24883200 1400
135206713 ComPhyPark C Nov. 13, 2021, 2:04 a.m. OK MS C++ 2017 TESTS 29 78 2150400 1400
135173343 Tangerine C Nov. 12, 2021, 5:02 p.m. OK MS C++ 2017 TESTS 29 124 3072000 1400
135172521 DarkSun C Nov. 12, 2021, 4:58 p.m. OK MS C++ 2017 TESTS 29 155 3072000 1400
135208940 cmj0922 C Nov. 13, 2021, 2:47 a.m. OK MS C++ 2017 TESTS 29 171 21401600 1400
135170831 gleb32 C Nov. 12, 2021, 4:34 p.m. OK MS C++ 2017 TESTS 29 202 3072000 1400
135170326 Yinch C Nov. 12, 2021, 4:34 p.m. OK MS C++ 2017 TESTS 29 420 2150400 1400
135212711 start666 C Nov. 13, 2021, 3:55 a.m. OK MS C++ 2017 TESTS 29 421 6144000 1400
135168114 Touristinya C Nov. 12, 2021, 4:29 p.m. OK MS C++ 2017 TESTS 29 436 3072000 1400
135168291 WUT_ZJL C Nov. 12, 2021, 4:30 p.m. OK MS C++ 2017 TESTS 29 451 3072000 1400
135221589 thonns178 C Nov. 13, 2021, 5:58 a.m. OK MS C++ 2017 TESTS 29 452 3072000 1400
135168143 NorbertG C Nov. 12, 2021, 4:29 p.m. OK .NET Core C# TESTS 29 467 17510400 1400
135166028 reosfire C Nov. 12, 2021, 4:25 p.m. OK .NET Core C# TESTS 29 670 27852800 1400
135212441 chinesedfan C Nov. 13, 2021, 3:51 a.m. OK Node.js TESTS 29 170 27955200 1400
135172473 1_2_3_4_5_9 C Nov. 12, 2021, 4:58 p.m. OK PyPy 2 TESTS 29 202 28160000 1400
135168267 NecroSean38 C Nov. 12, 2021, 4:30 p.m. OK PyPy 3 TESTS 29 249 26828800 1400
135187351 28th C Nov. 12, 2021, 6:55 p.m. OK PyPy 3 TESTS 29 280 29081600 1400
135187928 sw_enthusiast C Nov. 12, 2021, 7:01 p.m. OK PyPy 3 TESTS 29 296 91750400 1400
135184039 StillMortal C Nov. 12, 2021, 6:21 p.m. OK PyPy 3 TESTS 29 311 27955200 1400
135164733 mnkp C Nov. 12, 2021, 4:22 p.m. OK PyPy 3 TESTS 29 343 26828800 1400
135172214 vdh_123 C Nov. 12, 2021, 4:57 p.m. OK PyPy 3 TESTS 29 343 27340800 1400
135215726 mmooyyii C Nov. 13, 2021, 4:46 a.m. OK PyPy 3 TESTS 29 358 28160000 1400
135167405 Arki_0807 C Nov. 12, 2021, 4:28 p.m. OK PyPy 3 TESTS 29 358 28467200 1400
135183949 shubh67678 C Nov. 12, 2021, 6:20 p.m. OK PyPy 3 TESTS 29 358 46796800 1400
135221659 Sujith_ C Nov. 13, 2021, 5:59 a.m. OK PyPy 3 TESTS 29 374 33689600 1400
135177908 mayank35 C Nov. 12, 2021, 5:32 p.m. OK PyPy 3-64 TESTS 29 187 38297600 1400
135210485 epoweripi C Nov. 13, 2021, 3:14 a.m. OK PyPy 3-64 TESTS 29 264 39014400 1400
135184524 DAMPER C Nov. 12, 2021, 6:26 p.m. OK PyPy 3-64 TESTS 29 326 39526400 1400
135165976 innocent_SINNER C Nov. 12, 2021, 4:25 p.m. OK PyPy 3-64 TESTS 29 343 39526400 1400
135190800 raj1307 C Nov. 12, 2021, 7:39 p.m. OK PyPy 3-64 TESTS 29 389 38809600 1400
135162745 KA_Rma C Nov. 12, 2021, 4:17 p.m. OK PyPy 3-64 TESTS 29 420 39731200 1400
135174744 ctt312000 C Nov. 12, 2021, 5:09 p.m. OK PyPy 3-64 TESTS 29 436 109977600 1400
135162885 prackode C Nov. 12, 2021, 4:17 p.m. OK PyPy 3-64 TESTS 29 483 42598400 1400
135164749 FrozenKandy C Nov. 12, 2021, 4:22 p.m. OK PyPy 3-64 TESTS 29 561 90316800 1400
135166873 hsh8086 C Nov. 12, 2021, 4:27 p.m. OK PyPy 3-64 TESTS 29 670 179814400 1400
135172961 OLOGY C Nov. 12, 2021, 5 p.m. OK Python 2 TESTS 29 561 6144000 1400
135194783 neel0086 C Nov. 12, 2021, 8:39 p.m. OK Python 3 TESTS 29 265 14336000 1400
135184563 hoyyang22 C Nov. 12, 2021, 6:26 p.m. OK Python 3 TESTS 29 280 7782400 1400
135184560 DAMPER C Nov. 12, 2021, 6:26 p.m. OK Python 3 TESTS 29 280 7782400 1400
135179091 navdeep_k19 C Nov. 12, 2021, 5:40 p.m. OK Python 3 TESTS 29 295 7884800 1400
135174602 ayush_345 C Nov. 12, 2021, 5:08 p.m. OK Python 3 TESTS 29 717 15052800 1400
135181607 shikhabhat16 C Nov. 12, 2021, 6 p.m. OK Python 3 TESTS 29 795 8294400 1400
135173504 maxrage C Nov. 12, 2021, 5:03 p.m. OK Python 3 TESTS 29 826 7782400 1400
135173096 akshaywairagade2 C Nov. 12, 2021, 5:01 p.m. OK Python 3 TESTS 29 841 7884800 1400
135186615 meet2008 C Nov. 12, 2021, 6:47 p.m. OK Python 3 TESTS 29 857 7782400 1400
135208115 paradoxxd C Nov. 13, 2021, 2:32 a.m. OK Python 3 TESTS 29 872 7884800 1400
135202923 Spheniscine C Nov. 13, 2021, 12:21 a.m. OK Rust TESTS 29 46 5427200 1400
135163316 orz_liuwei C Nov. 12, 2021, 4:18 p.m. OK Rust TESTS 29 1013 4403200 1400
135207954 pili C Nov. 13, 2021, 2:29 a.m. OK Rust TESTS 29 1325 8294400 1400

remove filters

Back to search problems