Codeforces Round 1046 (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
2136 Codeforces Round 1046 (Div. 2) FINISHED False 10800 20013923 Aug. 28, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 20822 ) B Like the Bitset PROGRAMMING constructive algorithms greedy two pointers

You are given a binary string(^{\text{∗}}) (s) of length (n), as well as an integer (k). Aquawave wants to construct a permutation(^{\text{†}}) (p) of length (n), so that for each (1\le i\le n), where (s_i=\mathtt{1}), the following holds: For each interval (l, r) ((1\le l\le r\le n)) whose length is at least (k) (i.e. (r - l + 1 \geq k)), if it covers position (i) (i.e. (l \leq i \leq r)), then the maximum element among (p_l, p_{l+1}, \ldots, p_r) is not (p_i). Note that there are no such constraints on indices with (s_i = \mathtt{0}). You have to find such a permutation, or determine that such permutations do not exist. (^{\text{∗}})A binary string is a string where each character is either (\mathtt{0}) or (\mathtt{1}). (^{\text{†}})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). 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 two integers (n) and (k) ((1 \leq n \leq 2 \cdot 10^5), (1 \leq k \leq n)) — the length of (s) and the integer in the statements. The second line contains the binary string (s) of length (n) ((s_i = \mathtt{0}) or (\mathtt{1})). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case: If there is at least one possible permutation: Print " YES " in the first line of output; Then, print (n) integers (p_1, p_2, \ldots, p_n) ((1 \leq p_i \leq n), all (p_i)-s are distinct) in the second lin

Tutorials

Codeforces Round 1046 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
336086805 AlfredGit B Aug. 29, 2025, 5:35 a.m. OK C++17 (GCC 7-32) TESTS 10 46 0
336078201 YuJun1024 B Aug. 29, 2025, 3:40 a.m. OK C++17 (GCC 7-32) TESTS 10 61 0
336089006 lalit_karthik B Aug. 29, 2025, 5:59 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
336088855 bkdn25.Kira B Aug. 29, 2025, 5:57 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
336088756 bkdn25.Kira B Aug. 29, 2025, 5:56 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
336087182 muntakim_lamim B Aug. 29, 2025, 5:39 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
336085487 AlfredGit B Aug. 29, 2025, 5:23 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
336084028 bansalram5903 B Aug. 29, 2025, 5:06 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
336083059 hardik_75 B Aug. 29, 2025, 4:53 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
336083034 Gononajontro_Biggani B Aug. 29, 2025, 4:53 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
336088327 GraphPoolDP_42 B Aug. 29, 2025, 5:52 a.m. OK C++20 (GCC 13-64) TESTS 10 46 0
336086290 mhr_emon B Aug. 29, 2025, 5:30 a.m. OK C++20 (GCC 13-64) TESTS 10 46 0
336085728 saurabh111 B Aug. 29, 2025, 5:25 a.m. OK C++20 (GCC 13-64) TESTS 10 46 0
336083674 Ankita_13 B Aug. 29, 2025, 5:02 a.m. OK C++20 (GCC 13-64) TESTS 10 46 0
336079402 bao_ling B Aug. 29, 2025, 3:59 a.m. OK C++20 (GCC 13-64) TESTS 10 46 0
336078355 Mayur_30 B Aug. 29, 2025, 3:43 a.m. OK C++20 (GCC 13-64) TESTS 10 46 0
336089516 akib_ B Aug. 29, 2025, 6:04 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
336082687 anik114911 B Aug. 29, 2025, 4:48 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
336074857 RPSS B Aug. 29, 2025, 2:51 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
336066138 shoharab512 B Aug. 28, 2025, 11:43 p.m. OK C++20 (GCC 13-64) TESTS 10 61 0
336080294 TaufiQ B Aug. 29, 2025, 4:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336080132 arshad739811 B Aug. 29, 2025, 4:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336077292 BongCloud1 B Aug. 29, 2025, 3:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336076007 sun-goku B Aug. 29, 2025, 3:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336074064 niloy654 B Aug. 29, 2025, 2:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336072724 yangzw B Aug. 29, 2025, 2:17 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336070828 yuexiabanye B Aug. 29, 2025, 1:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336069552 gurjot008 B Aug. 29, 2025, 1:19 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336068466 El-Shamy B Aug. 29, 2025, 12:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
336087002 link1k B Aug. 29, 2025, 5:37 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 102400
336036954 bkdn25.195 B Aug. 28, 2025, 5:15 p.m. OK GNU C11 TESTS 10 77 6041600
336060665 sahithi_0220 B Aug. 28, 2025, 9:24 p.m. OK GNU C11 TESTS 10 827 1024000
336079913 yt.armagidon.mc B Aug. 29, 2025, 4:07 a.m. OK GNU C11 TESTS 10 843 1126400
336079152 yt.armagidon.mc B Aug. 29, 2025, 3:56 a.m. OK GNU C11 TESTS 10 843 1126400
336029688 FAILURENO.1 B Aug. 28, 2025, 4:54 p.m. OK GNU C11 TESTS 10 858 1024000
336087918 krishnajaj_24 B Aug. 29, 2025, 5:47 a.m. OK GNU C11 TESTS 10 874 1024000
336026361 tonmoy_25 B Aug. 28, 2025, 4:46 p.m. OK GNU C11 TESTS 10 874 1126400
336032933 aayushkanade29 B Aug. 28, 2025, 5:03 p.m. OK GNU C11 TESTS 10 921 1024000
336058441 uffhottie B Aug. 28, 2025, 8:44 p.m. OK Go TESTS 10 77 5836800
336067164 Ramm_Lakshmanan B Aug. 29, 2025, 12:17 a.m. OK Java 21 TESTS 10 264 1433600
336040526 Shrovitz B Aug. 28, 2025, 5:25 p.m. OK Java 21 TESTS 10 265 102400
336038498 sidd_shukla B Aug. 28, 2025, 5:19 p.m. OK Java 21 TESTS 10 280 716800
336029632 RAJADABALA B Aug. 28, 2025, 4:54 p.m. OK Java 21 TESTS 10 296 0
336043591 Ragavendhiran_S B Aug. 28, 2025, 5:33 p.m. OK Java 21 TESTS 10 296 102400
336086842 NpHardcore_05 B Aug. 29, 2025, 5:35 a.m. OK Java 21 TESTS 10 296 716800
336038962 pranavarora724 B Aug. 28, 2025, 5:21 p.m. OK Java 21 TESTS 10 312 2048000
336034955 nishanth50 B Aug. 28, 2025, 5:09 p.m. OK Java 21 TESTS 10 328 1024000
336073284 UlaanBatat B Aug. 29, 2025, 2:27 a.m. OK Java 21 TESTS 10 328 1740800
336051824 amansheo B Aug. 28, 2025, 7:29 p.m. OK Java 21 TESTS 10 343 102400
336080848 BrutHawk B Aug. 29, 2025, 4:22 a.m. OK Java 8 TESTS 10 156 0
336031172 dhanrajsingh2911 B Aug. 28, 2025, 4:59 p.m. OK Java 8 TESTS 10 171 3276800
336032866 Evan887788 B Aug. 28, 2025, 5:03 p.m. OK Java 8 TESTS 10 202 0
336084143 adibhai0845R B Aug. 29, 2025, 5:07 a.m. OK Java 8 TESTS 10 436 0
336063372 vootkuriakshayreddy B Aug. 28, 2025, 10:24 p.m. OK Java 8 TESTS 10 467 0
336056613 Shafat04 B Aug. 28, 2025, 8:21 p.m. OK Java 8 TESTS 10 468 0
336039353 ananyajain B Aug. 28, 2025, 5:22 p.m. OK Java 8 TESTS 10 468 3788800
336034006 Dev_Udit B Aug. 28, 2025, 5:06 p.m. OK Java 8 TESTS 10 500 3686400
336038672 sy17012002 B Aug. 28, 2025, 5:20 p.m. OK Java 8 TESTS 10 515 3686400
336077387 ujwalcoderhunter B Aug. 29, 2025, 3:29 a.m. OK Java 8 TESTS 10 702 3686400
336040146 zeninlock B Aug. 28, 2025, 5:24 p.m. OK PyPy 3 TESTS 10 265 13516800
336026531 Narendra_311 B Aug. 28, 2025, 4:46 p.m. OK PyPy 3 TESTS 10 280 19660800
336086776 Prathmesh_H B Aug. 29, 2025, 5:34 a.m. OK PyPy 3 TESTS 10 327 12697600
336028337 _PD_ B Aug. 28, 2025, 4:51 p.m. OK PyPy 3 TESTS 10 390 14336000
336035725 Srivissy B Aug. 28, 2025, 5:11 p.m. OK PyPy 3 TESTS 10 405 13619200
336031992 developermohammed01 B Aug. 28, 2025, 5:01 p.m. OK PyPy 3-64 TESTS 10 140 9011200
336038795 viosta B Aug. 28, 2025, 5:20 p.m. OK PyPy 3-64 TESTS 10 140 13004800
336037451 ihsanul.huq.25 B Aug. 28, 2025, 5:16 p.m. OK PyPy 3-64 TESTS 10 155 8396800
336082960 Rudra_Dudhat B Aug. 29, 2025, 4:52 a.m. OK PyPy 3-64 TESTS 10 155 14131200
336043957 blitzbyte07 B Aug. 28, 2025, 5:33 p.m. OK PyPy 3-64 TESTS 10 156 7680000
336029076 bkdn25.robo B Aug. 28, 2025, 4:53 p.m. OK PyPy 3-64 TESTS 10 156 12083200
336088351 Om_Singh_ B Aug. 29, 2025, 5:52 a.m. OK PyPy 3-64 TESTS 10 171 11571200
336043608 cute_c B Aug. 28, 2025, 5:33 p.m. OK PyPy 3-64 TESTS 10 171 17305600
336076927 HelloGoodbye B Aug. 29, 2025, 3:23 a.m. OK PyPy 3-64 TESTS 10 186 19456000
336033934 cool_codeslinger_raghav B Aug. 28, 2025, 5:06 p.m. OK PyPy 3-64 TESTS 10 187 8499200
336036398 akhilbalusani1 B Aug. 28, 2025, 5:13 p.m. OK Python 3 TESTS 10 139 29696000
336034410 TasfiulMostafa B Aug. 28, 2025, 5:07 p.m. OK Python 3 TESTS 10 140 21299200
336069567 .K.Hemanth B Aug. 29, 2025, 1:20 a.m. OK Python 3 TESTS 10 156 16384000
336031930 kenley B Aug. 28, 2025, 5:01 p.m. OK Python 3 TESTS 10 171 23756800
336036518 Soyipov0512 B Aug. 28, 2025, 5:13 p.m. OK Python 3 TESTS 10 187 30822400
336035534 gdbs_ai B Aug. 28, 2025, 5:11 p.m. OK Python 3 TESTS 10 202 21094400
336066794 Miguerraga B Aug. 29, 2025, 12:06 a.m. OK Python 3 TESTS 10 218 11776000
336041128 ruslan.khayretd1nov B Aug. 28, 2025, 5:27 p.m. OK Python 3 TESTS 10 233 16384000
336035017 Aditya_8hardwaj B Aug. 28, 2025, 5:09 p.m. OK Python 3 TESTS 10 233 20992000
336029655 Harv314 B Aug. 28, 2025, 4:54 p.m. OK Python 3 TESTS 10 233 23859200
336070076 lyteabovenyte B Aug. 29, 2025, 1:31 a.m. OK Rust 2021 TESTS 10 77 1331200
336031757 flinnthebin B Aug. 28, 2025, 5 p.m. OK Rust 2024 TESTS 10 109 2048000

remove filters

Back to search problems