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 |
|---|---|---|---|---|---|---|
| 2138 | Codeforces Round 1048 (Div. 1) | FINISHED | False | 10800 | 19063523 | Sept. 8, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 16914 ) | A | Cake Assignment | PROGRAMMING | bitmasks constructive algorithms |
Chocola and Vanilla love cakes. Today, the manager of a cake shop gave them a total of (2^{k+1}) cakes. The cakes were distributed evenly, so each of them initially received (2^k) cakes. However, Chocola and Vanilla now want to redistribute the cakes such that Chocola ends up with exactly (x) cakes and Vanilla gets the remaining (2^{k+1}-x) cakes. In one step, they can perform exactly one of the following two operations: Chocola gives half of her cakes to Vanilla. This operation is only allowed if Chocola currently has an even number of cakes. Vanilla gives half of her cakes to Chocola. This operation is only allowed if Vanilla currently has an even number of cakes. Your task is to determine the minimum number of steps required to reach the target distribution and to output any valid sequence of operations achieving that minimum. It can be proven that, under the given constraints, a valid solution always exists, and the minimum number of steps required is at most (120). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 1000)). The description of the test cases follows. The first line of each test case contains two integers (k) and (x) ((1 \le k \le 60), (1 \le x \le 2^{k+1}-1)) — each person initially received (2^k) cakes, and (x) is the number of cakes Chocola should have after redistribution. For each test case, output a single integer (n) ((0\le n\le 120)) representing the minimum number of steps required for them to redistribute the cakes accordingly. On the next line, output (n) integers (o_1, o_2, \ldots, o_n) ((o_i = \mathtt{1}) or (o_i = \mathtt{2})), where (o_i = \mathtt{1}) means that in the (i)-th step, Chocola gave half of her cakes to Vanilla (operation 1), and (o_i = \mathtt{2}) means that Vanilla gave half of her cakes to Chocola (operation 2). In the first test case, they can use the following step |
| Codeforces Round 1048 (Div. 1, Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 337569944 | mban259 | A | Sept. 8, 2025, 2:44 p.m. | OK | C# 13 | TESTS | 20 | 93 | 1126400 | ||
| 337694296 | Evil_Hunter | A | Sept. 9, 2025, 3:24 a.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 46 | 0 | ||
| 337686141 | wifiiii | A | Sept. 9, 2025, 1:08 a.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 46 | 0 | ||
| 337682408 | chenyuyang0225 | A | Sept. 8, 2025, 11:33 p.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 46 | 0 | ||
| 337682274 | nealzane | A | Sept. 8, 2025, 11:30 p.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 46 | 0 | ||
| 337685824 | RightTwix | A | Sept. 9, 2025, 1 a.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 46 | 4812800 | ||
| 337700429 | AKAMAN | A | Sept. 9, 2025, 4:56 a.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 61 | 0 | ||
| 337696447 | Leavin | A | Sept. 9, 2025, 3:56 a.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 61 | 0 | ||
| 337692010 | sunchaoyi | A | Sept. 9, 2025, 2:52 a.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 61 | 0 | ||
| 337680136 | popoliku | A | Sept. 8, 2025, 10:25 p.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 61 | 0 | ||
| 337599520 | nhonyc | A | Sept. 8, 2025, 3:18 p.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 61 | 0 | ||
| 337705903 | HarshSingh_24 | A | Sept. 9, 2025, 6:05 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337698584 | geetanjali55 | A | Sept. 9, 2025, 4:30 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337697385 | Exceptional_handling18 | A | Sept. 9, 2025, 4:11 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337694739 | shivansh_green | A | Sept. 9, 2025, 3:30 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337692943 | Btech_Griever | A | Sept. 9, 2025, 3:06 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337685187 | wangyizhi | A | Sept. 9, 2025, 12:45 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337684162 | StayAlone | A | Sept. 9, 2025, 12:24 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337684014 | GroupMatrix | A | Sept. 9, 2025, 12:21 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337683084 | zjdl | A | Sept. 8, 2025, 11:54 p.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 0 | ||
| 337699046 | anirudharoyarcho | A | Sept. 9, 2025, 4:37 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 46 | 102400 | ||
| 337695936 | Andrew_sun | A | Sept. 9, 2025, 3:47 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337692684 | comalonwizme | A | Sept. 9, 2025, 3:02 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337692536 | SadArtira | A | Sept. 9, 2025, 3 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337691604 | crocell001 | A | Sept. 9, 2025, 2:46 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337689403 | LUVK | A | Sept. 9, 2025, 2:11 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337684168 | Mitsukasa_Ayase | A | Sept. 9, 2025, 12:24 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337680242 | B_3 | A | Sept. 8, 2025, 10:28 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337680183 | B_3 | A | Sept. 8, 2025, 10:26 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337680019 | B_3 | A | Sept. 8, 2025, 10:21 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 0 | ||
| 337701731 | MermaidMolester | A | Sept. 9, 2025, 5:13 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 46 | 102400 | ||
| 337559072 | hos.lyric | A | Sept. 8, 2025, 2:37 p.m. | OK | D | TESTS | 20 | 108 | 0 | ||
| 337577691 | pengin_2000 | A | Sept. 8, 2025, 2:50 p.m. | OK | GNU C11 | TESTS | 20 | 77 | 102400 | ||
| 337687630 | Rajat633 | A | Sept. 9, 2025, 1:38 a.m. | OK | Java 21 | TESTS | 20 | 281 | 1126400 | ||
| 337575424 | MaxBuzz | A | Sept. 8, 2025, 2:48 p.m. | OK | Java 21 | TESTS | 20 | 312 | 716800 | ||
| 337700943 | goalboy | A | Sept. 9, 2025, 5:04 a.m. | OK | Java 21 | TESTS | 20 | 375 | 1331200 | ||
| 337568090 | sunnydev | A | Sept. 8, 2025, 2:42 p.m. | OK | Java 8 | TESTS | 20 | 186 | 0 | ||
| 337605506 | omdeshmukh1906 | A | Sept. 8, 2025, 3:27 p.m. | OK | Java 8 | TESTS | 20 | 187 | 0 | ||
| 337583671 | golions | A | Sept. 8, 2025, 2:56 p.m. | OK | Java 8 | TESTS | 20 | 187 | 0 | ||
| 337570289 | Tlatoani | A | Sept. 8, 2025, 2:44 p.m. | OK | Kotlin 2.2 | TESTS | 20 | 234 | 102400 | ||
| 337685431 | FernandoC01 | A | Sept. 9, 2025, 12:51 a.m. | OK | PHP | TESTS | 20 | 77 | 102400 | ||
| 337685611 | FernandoC01 | A | Sept. 9, 2025, 12:55 a.m. | OK | PHP | TESTS | 20 | 78 | 102400 | ||
| 337685377 | FernandoC01 | A | Sept. 9, 2025, 12:50 a.m. | OK | PHP | TESTS | 20 | 93 | 102400 | ||
| 337685118 | FernandoC01 | A | Sept. 9, 2025, 12:44 a.m. | OK | PyPy 3 | TESTS | 20 | 139 | 3174400 | ||
| 337585586 | SPD_9X2 | A | Sept. 8, 2025, 2:58 p.m. | OK | PyPy 3 | TESTS | 20 | 234 | 8089600 | ||
| 337685289 | FernandoC01 | A | Sept. 9, 2025, 12:48 a.m. | OK | PyPy 3-64 | TESTS | 20 | 93 | 2252800 | ||
| 337685173 | FernandoC01 | A | Sept. 9, 2025, 12:45 a.m. | OK | PyPy 3-64 | TESTS | 20 | 109 | 2355200 | ||
| 337684069 | alexwice | A | Sept. 9, 2025, 12:22 a.m. | OK | PyPy 3-64 | TESTS | 20 | 124 | 6246400 | ||
| 337685137 | FernandoC01 | A | Sept. 9, 2025, 12:44 a.m. | OK | PyPy 3-64 | TESTS | 20 | 139 | 2867200 | ||
| 337567312 | bcollet | A | Sept. 8, 2025, 2:42 p.m. | OK | PyPy 3-64 | TESTS | 20 | 140 | 2457600 | ||
| 337678507 | sohamgupta.1515 | A | Sept. 8, 2025, 9:43 p.m. | OK | PyPy 3-64 | TESTS | 20 | 140 | 4403200 | ||
| 337566661 | 987 | A | Sept. 8, 2025, 2:41 p.m. | OK | PyPy 3-64 | TESTS | 20 | 140 | 6041600 | ||
| 337564810 | mj1000j | A | Sept. 8, 2025, 2:40 p.m. | OK | PyPy 3-64 | TESTS | 20 | 140 | 6041600 | ||
| 337567781 | eepsilon | A | Sept. 8, 2025, 2:42 p.m. | OK | PyPy 3-64 | TESTS | 20 | 140 | 6144000 | ||
| 337566125 | smilences | A | Sept. 8, 2025, 2:41 p.m. | OK | PyPy 3-64 | TESTS | 20 | 140 | 6246400 | ||
| 337565289 | Sugar_fan | A | Sept. 8, 2025, 2:40 p.m. | OK | Rust 2021 | TESTS | 20 | 77 | 102400 | ||
| 337571574 | sansen | A | Sept. 8, 2025, 2:45 p.m. | OK | Rust 2021 | TESTS | 20 | 93 | 102400 | ||
| 337571946 | WaterColor2037 | A | Sept. 8, 2025, 2:45 p.m. | OK | Rust 2024 | TESTS | 20 | 62 | 0 | ||
| 337646656 | Ming_Xu | A | Sept. 8, 2025, 4:52 p.m. | OK | Rust 2024 | TESTS | 20 | 77 | 0 |
Back to search problems