Codeforces Round 1027 (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
2114 Codeforces Round 1027 (Div. 3) FINISHED False 8100 28135523 May 26, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 30400 ) B Not Quite a Palindromic String PROGRAMMING greedy greedy math math

Vlad found a binary string(^{\text{∗}}) (s) of even length (n). He considers a pair of indices ((i, n - i + 1)), where (1 \le i < n - i + 1), to be good if (s_i = s_{n - i + 1}) holds true. For example, in the string ' 010001 ' there is only (1) good pair, since (s_1 \ne s_6), (s_2 \ne s_5), and (s_3=s_4). In the string ' 0101 ' there are no good pairs. Vlad loves palindromes, but not too much, so he wants to rearrange some characters of the string so that there are exactly (k) good pairs of indices. Determine whether it is possible to rearrange the characters in the given string so that there are exactly (k) good pairs of indices ((i, n - i + 1)). (^{\text{∗}})A string (s) is called binary if it consists only of the characters ' 0 ' and ' 1 ' The first line contains an integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains two integers (n) and (k) ((2 \le n \le 2 \cdot 10^5), (0 \le k \le \frac{n}{2}), (n) is even) — the length of the string and the required number of good pairs. The second line of each test case contains a binary string (s) of length (n). It is guaranteed that the sum of (n) across all test cases does not exceed (2 \cdot 10^5). For each test case, output " YES " if there is a way to rearrange the characters of the string so that there are exactly (k) good pairs, otherwise output " NO ". You may output each letter in any case (lowercase or uppercase). For example, the strings " yEs ", " yes ", " Yes ", and " YES " will be accepted as a positive answer.

Tutorials

143268

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
321694347 algorhtym B May 27, 2025, 6:48 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
321722720 tdmhk9 B May 28, 2025, 4:13 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321706079 Warrior_1506 B May 27, 2025, 9:41 p.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321673657 Error_404--_-- B May 27, 2025, 3:50 p.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321640178 SherlockHolmes221B B May 27, 2025, 11:54 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321636756 xiaozhao2002 B May 27, 2025, 11:33 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321626275 forrealtho B May 27, 2025, 10:15 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321616665 cuizhenjia B May 27, 2025, 9:09 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321587753 cp_first B May 27, 2025, 5:17 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321591843 vamsee_dhar B May 27, 2025, 5:53 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
321586414 nitishkumarnh451 B May 27, 2025, 5:04 a.m. OK C++20 (GCC 13-64) TESTS 4 30 0
321719858 Pika B May 28, 2025, 3:28 a.m. OK C++20 (GCC 13-64) TESTS 4 30 0
321717951 vpvpvpvvp B May 28, 2025, 2:57 a.m. OK C++20 (GCC 13-64) TESTS 4 30 0
321719573 yanghongyan B May 28, 2025, 3:23 a.m. OK C++20 (GCC 13-64) TESTS 4 30 8089600
321648610 As1236 B May 27, 2025, 12:51 p.m. OK C++20 (GCC 13-64) TESTS 4 31 0
321588143 Narendrashakyajnv B May 27, 2025, 5:20 a.m. OK C++20 (GCC 13-64) TESTS 4 31 0
321721321 prince.chovatiya01 B May 28, 2025, 3:52 a.m. OK C++20 (GCC 13-64) TESTS 4 31 102400
321735784 sahaun B May 28, 2025, 5:44 a.m. OK C++20 (GCC 13-64) TESTS 4 31 102400
321735601 C.Corrales B May 28, 2025, 5:43 a.m. OK C++20 (GCC 13-64) TESTS 4 31 102400
321724464 Zhenis1337 B May 28, 2025, 4:38 a.m. OK C++20 (GCC 13-64) TESTS 4 31 102400
321617961 Testcase1 B May 27, 2025, 9:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
321588755 kowalsci B May 27, 2025, 5:25 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 102400
321665585 Abdallah_Yousry B May 27, 2025, 2:50 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 102400
321617712 _twi_nami B May 27, 2025, 9:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 102400
321586120 Love_bansal B May 27, 2025, 5:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 102400
321643814 zjhhhzj B May 27, 2025, 12:19 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 3276800
321599332 It_is_time B May 27, 2025, 6:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 14438400
321698769 Wedka B May 27, 2025, 7:39 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 31 0
321737508 ahmed_sheerif B May 28, 2025, 6:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 31 0
321714028 pwk B May 28, 2025, 1:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 31 0
321710833 bluemegane B May 28, 2025, 12:10 a.m. OK C# 8 TESTS 4 109 2252800
321697724 zerojanuary B May 27, 2025, 7:26 p.m. OK GNU C11 TESTS 4 31 307200
321677246 shakibpatoary34 B May 27, 2025, 4:19 p.m. OK GNU C11 TESTS 4 61 307200
321669140 shisanzerotwo B May 27, 2025, 3:16 p.m. OK GNU C11 TESTS 4 61 307200
321669088 Mridul_Garg B May 27, 2025, 3:16 p.m. OK GNU C11 TESTS 4 62 204800
321670789 rainycold B May 27, 2025, 3:29 p.m. OK GNU C11 TESTS 4 77 102400
321718579 ysmsy B May 28, 2025, 3:07 a.m. OK GNU C11 TESTS 4 77 204800
321633883 Sar_thak79 B May 27, 2025, 11:13 a.m. OK GNU C11 TESTS 4 77 307200
321589863 aaryanp1980 B May 27, 2025, 5:34 a.m. OK GNU C11 TESTS 4 77 307200
321697999 alicia33 B May 27, 2025, 7:29 p.m. OK GNU C11 TESTS 4 108 307200
321638781 Sar_thak79 B May 27, 2025, 11:46 a.m. OK GNU C11 TESTS 4 124 307200
321660560 conglingkaishi B May 27, 2025, 2:13 p.m. OK Go TESTS 4 265 1536000
321672675 lyongwolf B May 27, 2025, 3:43 p.m. OK Java 21 TESTS 4 203 819200
321581062 deepu4477 B May 27, 2025, 4:07 a.m. OK Java 21 TESTS 4 218 0
321583601 Ronit0211 B May 27, 2025, 4:35 a.m. OK Java 21 TESTS 4 233 0
321696103 jsonier B May 27, 2025, 7:06 p.m. OK Java 21 TESTS 4 233 512000
321582383 HarhsSoni B May 27, 2025, 4:22 a.m. OK Java 21 TESTS 4 234 307200
321661387 venkatesh7779 B May 27, 2025, 2:19 p.m. OK Java 21 TESTS 4 234 512000
321721232 rajasomeshwar_bitla B May 28, 2025, 3:50 a.m. OK Java 21 TESTS 4 234 614400
321671769 patrickjane79 B May 27, 2025, 3:36 p.m. OK Java 21 TESTS 4 249 204800
321719790 moonkight11 B May 28, 2025, 3:27 a.m. OK Java 21 TESTS 4 249 409600
321659462 shivashish B May 27, 2025, 2:05 p.m. OK Java 21 TESTS 4 249 409600
321685188 Eslam_Ahmed B May 27, 2025, 5:22 p.m. OK Java 8 TESTS 4 124 0
321617314 Purav_Shah07 B May 27, 2025, 9:13 a.m. OK Java 8 TESTS 4 124 0
321664521 Pranav_45 B May 27, 2025, 2:43 p.m. OK Java 8 TESTS 4 140 0
321709645 Destroyer0069 B May 27, 2025, 11:27 p.m. OK Java 8 TESTS 4 156 0
321694098 abhayrajnegi0416 B May 27, 2025, 6:45 p.m. OK Java 8 TESTS 4 156 0
321690200 zhai123 B May 27, 2025, 6:05 p.m. OK Java 8 TESTS 4 171 0
321667168 Sumitsingh7 B May 27, 2025, 3:02 p.m. OK Java 8 TESTS 4 171 6656000
321658263 satyams_9001 B May 27, 2025, 1:57 p.m. OK Java 8 TESTS 4 171 6656000
321695900 krishnandu01 B May 27, 2025, 7:04 p.m. OK Java 8 TESTS 4 202 0
321654672 jroy.karnati B May 27, 2025, 1:32 p.m. OK Java 8 TESTS 4 218 0
321632328 shakil_21_ B May 27, 2025, 11:01 a.m. OK Kotlin 1.9 TESTS 4 202 307200
321716013 graceoflives B May 28, 2025, 2:25 a.m. OK Node.js TESTS 4 233 9830400
321600169 Calculuslove B May 27, 2025, 7 a.m. OK PyPy 3 TESTS 4 296 7782400
321618772 idk404 B May 27, 2025, 9:23 a.m. OK PyPy 3 TESTS 4 312 9830400
321705219 khaoula-km B May 27, 2025, 9:20 p.m. OK PyPy 3 TESTS 4 327 8499200
321704736 oleviaaa B May 27, 2025, 9:10 p.m. OK PyPy 3 TESTS 4 342 9523200
321680712 codsila B May 27, 2025, 4:46 p.m. OK PyPy 3 TESTS 4 359 9728000
321629908 vermakunal088 B May 27, 2025, 10:42 a.m. OK PyPy 3 TESTS 4 452 9830400
321634566 Tz1934 B May 27, 2025, 11:18 a.m. OK PyPy 3-64 TESTS 4 109 4915200
321584910 Baichuan B May 27, 2025, 4:48 a.m. OK PyPy 3-64 TESTS 4 124 5017600
321645397 vinogpetnik B May 27, 2025, 12:30 p.m. OK PyPy 3-64 TESTS 4 124 5120000
321708990 monocrap B May 27, 2025, 11:03 p.m. OK PyPy 3-64 TESTS 4 124 5939200
321700220 emnado B May 27, 2025, 7:58 p.m. OK PyPy 3-64 TESTS 4 124 6041600
321643437 mamine27 B May 27, 2025, 12:17 p.m. OK PyPy 3-64 TESTS 4 139 6246400
321641386 find B May 27, 2025, 12:02 p.m. OK PyPy 3-64 TESTS 4 155 6758400
321643358 huqingchang B May 27, 2025, 12:16 p.m. OK PyPy 3-64 TESTS 4 155 8089600
321587478 Arya_Abhinav B May 27, 2025, 5:15 a.m. OK PyPy 3-64 TESTS 4 171 6348800
321643977 yashhh250 B May 27, 2025, 12:20 p.m. OK PyPy 3-64 TESTS 4 171 6860800
321712509 jayeuclid897 B May 28, 2025, 1:06 a.m. OK Python 3 TESTS 4 62 2048000
321703009 B4BY_Y0D4 B May 27, 2025, 8:39 p.m. OK Python 3 TESTS 4 77 614400
321630077 kaizerfsixteen B May 27, 2025, 10:44 a.m. OK Python 3 TESTS 4 77 921600
321621787 dipak12.11 B May 27, 2025, 9:44 a.m. OK Python 3 TESTS 4 78 921600
321588134 kridant_kumar B May 27, 2025, 5:20 a.m. OK Python 3 TESTS 4 93 716800
321686818 mintu_007 B May 27, 2025, 5:36 p.m. OK Python 3 TESTS 4 93 921600
321656108 cmath11 B May 27, 2025, 1:42 p.m. OK Python 3 TESTS 4 93 921600
321661015 utkarsh_shandilya B May 27, 2025, 2:17 p.m. OK Python 3 TESTS 4 93 2355200
321678213 elistark B May 27, 2025, 4:26 p.m. OK Python 3 TESTS 4 108 819200
321677672 tumoyakov B May 27, 2025, 4:22 p.m. OK Python 3 TESTS 4 108 819200
321722929 axerel B May 28, 2025, 4:16 a.m. OK Rust 2021 TESTS 4 61 0
321667349 fujishu B May 27, 2025, 3:03 p.m. OK Rust 2021 TESTS 4 61 0
321659752 UltramanDecker B May 27, 2025, 2:08 p.m. OK Rust 2021 TESTS 4 61 0
321657935 Ming_Xu B May 27, 2025, 1:54 p.m. OK Rust 2021 TESTS 4 77 0
321635871 cinkozzz B May 27, 2025, 11:27 a.m. OK Rust 2021 TESTS 4 77 0
321638546 DanielAnker B May 27, 2025, 11:44 a.m. OK Rust 2021 TESTS 4 77 102400

remove filters

Back to search problems