Codeforces Round 1052 (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
2146 Codeforces Round 1052 (Div. 2) FINISHED False 8100 17940323 Sept. 21, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 13232 ) C Wrong Binary Search PROGRAMMING binary search constructive algorithms

You are given an integer (n) and a binary string(^{\text{∗}}) (s) of length (n). For a permutation(^{\text{†}}) (p) of length (n) and an integer (x), we define (\text{find}(x)) as in the following pseudocode: We call an integer (x) ((1\le x\le n)) stable if and only if (\text{find}(x)) is always not undefined and (p_{\text{find}(x)}=x) always holds, no matter how the value of (m) is selected in the process of the pseudocode. You have to construct a permutation (p) of length (n), such that: For each (1\le i\le n), the integer (i) is stable if and only if (s_i=\mathtt{1}). Or determine that no such permutation exists. (^{\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 a single integer (n) ((2\le n \le 2\cdot 10^5)) — the length of the permutation. 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 no such permutation exists, print " NO " in the only line of output. Otherwise, print " YES " in the first line of output. Then output (n) distinct integers (p_1, p_2, \ldots, p_n) ((1\le p_i\le n)) in the second line — the permutation you constructed. You can output the t

Tutorials

Codeforces Round 1052 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
339770763 11Hemeda C Sept. 21, 2025, 4:11 p.m. OK C# 13 TESTS 12 452 6860800
339828525 roclee2692 C Sept. 22, 2025, 4:49 a.m. OK C++17 (GCC 7-32) TESTS 12 61 0
339812513 complexorigin C Sept. 22, 2025, 12:30 a.m. OK C++17 (GCC 7-32) TESTS 12 61 0
339799296 zaf_321 C Sept. 21, 2025, 7:11 p.m. OK C++17 (GCC 7-32) TESTS 12 61 0
339820114 square38 C Sept. 22, 2025, 2:47 a.m. OK C++17 (GCC 7-32) TESTS 12 61 819200
339833480 Valar_Codeghulis C Sept. 22, 2025, 5:45 a.m. OK C++17 (GCC 7-32) TESTS 12 62 0
339831563 Sarthakzzzzz C Sept. 22, 2025, 5:25 a.m. OK C++17 (GCC 7-32) TESTS 12 62 0
339828938 AsadGalib C Sept. 22, 2025, 4:55 a.m. OK C++17 (GCC 7-32) TESTS 12 62 0
339828504 roclee2692 C Sept. 22, 2025, 4:49 a.m. OK C++17 (GCC 7-32) TESTS 12 62 0
339826205 Liu_Rui C Sept. 22, 2025, 4:14 a.m. OK C++17 (GCC 7-32) TESTS 12 62 0
339825251 sai99klkk C Sept. 22, 2025, 4:02 a.m. OK C++17 (GCC 7-32) TESTS 12 62 0
339828470 aneee C Sept. 22, 2025, 4:48 a.m. OK C++20 (GCC 13-64) TESTS 12 46 0
339826681 xingsirumeng C Sept. 22, 2025, 4:21 a.m. OK C++20 (GCC 13-64) TESTS 12 46 0
339824773 Jiangnan111 C Sept. 22, 2025, 3:55 a.m. OK C++20 (GCC 13-64) TESTS 12 46 0
339820921 Na1L0ng C Sept. 22, 2025, 2:58 a.m. OK C++20 (GCC 13-64) TESTS 12 46 0
339826999 montasirfahim C Sept. 22, 2025, 4:25 a.m. OK C++20 (GCC 13-64) TESTS 12 46 2252800
339827537 AnshuYadav0212 C Sept. 22, 2025, 4:33 a.m. OK C++20 (GCC 13-64) TESTS 12 61 0
339824521 ZengZhaoGan_124 C Sept. 22, 2025, 3:52 a.m. OK C++20 (GCC 13-64) TESTS 12 61 0
339822286 Marisa0951 C Sept. 22, 2025, 3:18 a.m. OK C++20 (GCC 13-64) TESTS 12 61 0
339820795 evolfish C Sept. 22, 2025, 2:56 a.m. OK C++20 (GCC 13-64) TESTS 12 61 0
339813999 Wu_Xin_45 C Sept. 22, 2025, 1:13 a.m. OK C++20 (GCC 13-64) TESTS 12 61 0
339833994 Ansh_Mahajan C Sept. 22, 2025, 5:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 0
339824468 cmy666 C Sept. 22, 2025, 3:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 0
339820939 aks_22 C Sept. 22, 2025, 2:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 0
339816346 molongdadi C Sept. 22, 2025, 1:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 0
339810677 El-Mooo C Sept. 21, 2025, 11:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 0
339810590 f1_code C Sept. 21, 2025, 11:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 0
339805540 The_Last_Run C Sept. 21, 2025, 8:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 0
339828890 goddddgg C Sept. 22, 2025, 4:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 61 0
339828852 MaxDYF C Sept. 22, 2025, 4:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 61 0
339826706 bestprogrammer_no1 C Sept. 22, 2025, 4:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 61 0
339777038 sobertooth C Sept. 21, 2025, 4:28 p.m. OK GNU C11 TESTS 12 874 3481600
339773866 resonatingBose C Sept. 21, 2025, 4:19 p.m. OK GNU C11 TESTS 12 890 1945600
339809481 sohxm2k C Sept. 21, 2025, 10:39 p.m. OK Java 21 TESTS 12 249 512000
339807267 jacksparrow53536 C Sept. 21, 2025, 9:28 p.m. OK Java 21 TESTS 12 280 1331200
339798769 iamyash2004 C Sept. 21, 2025, 7:05 p.m. OK Java 21 TESTS 12 281 512000
339778736 iamyash2004 C Sept. 21, 2025, 4:33 p.m. OK Java 21 TESTS 12 296 1024000
339779691 mishraambar973 C Sept. 21, 2025, 4:35 p.m. OK Java 21 TESTS 12 296 1433600
339811343 vatsal_04 C Sept. 21, 2025, 11:48 p.m. OK Java 21 TESTS 12 312 1331200
339771935 Spencer1s C Sept. 21, 2025, 4:14 p.m. OK Java 21 TESTS 12 327 5734400
339774382 yuvrajye C Sept. 21, 2025, 4:21 p.m. OK Java 21 TESTS 12 328 16793600
339816544 Gitansh_shekhar C Sept. 22, 2025, 2:01 a.m. OK Java 21 TESTS 12 359 1843200
339794588 Saucyy C Sept. 21, 2025, 6:16 p.m. OK Java 21 TESTS 12 405 307200
339829162 jhemanth C Sept. 22, 2025, 4:58 a.m. OK Java 8 TESTS 12 186 9728000
339793030 multibagger C Sept. 21, 2025, 6:01 p.m. OK Java 8 TESTS 12 187 1126400
339773907 NeelmaniPandey09 C Sept. 21, 2025, 4:19 p.m. OK Java 8 TESTS 12 187 6963200
339777102 ashuramajestic C Sept. 21, 2025, 4:28 p.m. OK Java 8 TESTS 12 234 3788800
339774976 jatin310 C Sept. 21, 2025, 4:22 p.m. OK Java 8 TESTS 12 249 4300800
339781042 abhayrajnegi0416 C Sept. 21, 2025, 4:39 p.m. OK Java 8 TESTS 12 342 12185600
339806004 yashbansal99 C Sept. 21, 2025, 8:59 p.m. OK Java 8 TESTS 12 453 0
339800089 akki_code C Sept. 21, 2025, 7:21 p.m. OK Java 8 TESTS 12 499 17715200
339793278 saiashish9 C Sept. 21, 2025, 6:03 p.m. OK Java 8 TESTS 12 515 0
339784610 Saumya1708 C Sept. 21, 2025, 4:49 p.m. OK Java 8 TESTS 12 515 2867200
339801592 jagbarrameda C Sept. 21, 2025, 7:42 p.m. OK Kotlin 1.9 TESTS 12 187 6758400
339774199 mohitsharmakv05 C Sept. 21, 2025, 4:20 p.m. OK Node.js TESTS 12 186 33177600
339784491 practiceDaily2 C Sept. 21, 2025, 4:49 p.m. OK Node.js TESTS 12 218 32665600
339775550 beastneeraj C Sept. 21, 2025, 4:24 p.m. OK PyPy 3 TESTS 12 280 21913600
339778190 utsab77 C Sept. 21, 2025, 4:31 p.m. OK PyPy 3 TESTS 12 342 14745600
339773511 akshay_834 C Sept. 21, 2025, 4:18 p.m. OK PyPy 3 TESTS 12 343 12902400
339782811 AsianCoder01 C Sept. 21, 2025, 4:45 p.m. OK PyPy 3 TESTS 12 343 13516800
339797760 Ayushman_123 C Sept. 21, 2025, 6:53 p.m. OK PyPy 3 TESTS 12 374 14438400
339774224 quantiset C Sept. 21, 2025, 4:20 p.m. OK PyPy 3 TESTS 12 405 13107200
339770581 challavishweshwar C Sept. 21, 2025, 4:10 p.m. OK PyPy 3 TESTS 12 515 14745600
339783087 practiceDaily1 C Sept. 21, 2025, 4:45 p.m. OK PyPy 3-64 TESTS 12 124 7065600
339812158 _robosapiens_ C Sept. 22, 2025, 12:19 a.m. OK PyPy 3-64 TESTS 12 124 17715200
339804243 _robosapiens_ C Sept. 21, 2025, 8:25 p.m. OK PyPy 3-64 TESTS 12 124 17715200
339784120 R_A_Saha C Sept. 21, 2025, 4:48 p.m. OK PyPy 3-64 TESTS 12 139 14848000
339770901 rahulsamant0307 C Sept. 21, 2025, 4:11 p.m. OK PyPy 3-64 TESTS 12 155 7168000
339792776 Luciefer_x C Sept. 21, 2025, 5:58 p.m. OK PyPy 3-64 TESTS 12 155 13824000
339793784 kibr C Sept. 21, 2025, 6:08 p.m. OK PyPy 3-64 TESTS 12 156 15872000
339772228 inoxb911 C Sept. 21, 2025, 4:15 p.m. OK PyPy 3-64 TESTS 12 171 10649600
339799035 jvatsal0709 C Sept. 21, 2025, 7:08 p.m. OK PyPy 3-64 TESTS 12 171 13926400
339824870 Little_Sheep_Yawn C Sept. 22, 2025, 3:57 a.m. OK PyPy 3-64 TESTS 12 186 17100800
339813136 Taireyune C Sept. 22, 2025, 12:48 a.m. OK Python 3 TESTS 12 156 22835200
339772380 avdhoot001 C Sept. 21, 2025, 4:15 p.m. OK Python 3 TESTS 12 171 21299200
339805431 anura.mantri C Sept. 21, 2025, 8:47 p.m. OK Python 3 TESTS 12 171 24371200
339806414 ismai C Sept. 21, 2025, 9:07 p.m. OK Python 3 TESTS 12 187 26419200
339812570 lovya_006 C Sept. 22, 2025, 12:32 a.m. OK Python 3 TESTS 12 218 42188800
339782888 dpaladiyaa C Sept. 21, 2025, 4:45 p.m. OK Python 3 TESTS 12 265 11980800
339784160 aviralsingh487 C Sept. 21, 2025, 4:48 p.m. OK Python 3 TESTS 12 296 17510400
339770939 parteekmalik5 C Sept. 21, 2025, 4:11 p.m. OK Python 3 TESTS 12 296 21708800
339781091 chavix C Sept. 21, 2025, 4:40 p.m. OK Python 3 TESTS 12 296 23142400
339827417 skyoceanland C Sept. 22, 2025, 4:32 a.m. OK Python 3 TESTS 12 311 11878400

remove filters

Back to search problems