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 |
|---|---|---|---|---|---|---|
| 2032 | Codeforces Round 983 (Div. 2) | FINISHED | False | 7200 | 45933923 | Nov. 1, 2024, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 1389 ) | E | Balanced | PROGRAMMING | constructive algorithms data structures implementation math |
You are given a cyclic array (a) with (n) elements, where (n) is odd . In each operation, you can do the following: Choose an index (1 \le i \le n) and increase (a_{i - 1}) by (1), (a_i) by (2), and (a_{i + 1}) by (1). The element before the first element is the last element because this is a cyclic array. A cyclic array is called balanced if all its elements are equal to each other. Find any sequence of operations to make this cyclic array balanced or determine that it is impossible. Please note that you do not have to minimize the number of operations. Each test consists of multiple test cases. The first line contains a single integer (t) ((1 \le t \le 2 \cdot 10^5)) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer (n) ((1 \le n < 2 \cdot 10^5), (n) is odd ) — the length of the array (a). The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le 10^{6})) — the elements of the array (a). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case: If it is impossible to make the cyclic array balanced, output (-1). Otherwise, output (n) integers (v_1, v_2, \ldots, v_n) ((0 \leq v_i \leq 10^{18})) — where (v_i) denotes the number of operations applied to index (i). It can be proved that if any solution exists, then there exists a solution under the given constraints. If there are several solutions under the given constraints, output any of them. In the first test case: After (1) operation applied to index (i = 2), the array (a = 3, 3, 3). In the second test case: After (2) operations applied to index (i = 1), the array (a = 5, 4, 5). After (1) operation applied to index (i = 2), the array (a = 6, 6, 6). In the third test case: After (2) o |
| Codeforces Round 983 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 289357055 | chaemh2013 | E | Nov. 2, 2024, 5:18 a.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 155 | 2764800 | ||
| 289334599 | im.priyansh | E | Nov. 1, 2024, 10:34 p.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 307200 | ||
| 289299607 | jmyszka | E | Nov. 1, 2024, 6:04 p.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 307200 | ||
| 289357135 | xieyijie | E | Nov. 2, 2024, 5:19 a.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 3276800 | ||
| 289352042 | zac2010 | E | Nov. 2, 2024, 4:15 a.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 4812800 | ||
| 289312598 | dalgu | E | Nov. 1, 2024, 7:09 p.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 4812800 | ||
| 289333562 | Geoyster | E | Nov. 1, 2024, 10:14 p.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 4915200 | ||
| 289332884 | sillylittleidiot77 | E | Nov. 1, 2024, 10:02 p.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 4915200 | ||
| 289319901 | amcbn | E | Nov. 1, 2024, 7:52 p.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 6451200 | ||
| 289292111 | Goshgar_468 | E | Nov. 1, 2024, 5:26 p.m. | OK | C++17 (GCC 7-32) | TESTS | 35 | 171 | 8089600 | ||
| 289357758 | Hoks_ | E | Nov. 2, 2024, 5:25 a.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 77 | 15872000 | ||
| 289357153 | Hoks_ | E | Nov. 2, 2024, 5:19 a.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 77 | 15872000 | ||
| 289290934 | lrx___ | E | Nov. 1, 2024, 5:21 p.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 108 | 4915200 | ||
| 289346190 | BuzzyBeez | E | Nov. 2, 2024, 2:50 a.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 109 | 10444800 | ||
| 289348711 | DennisTran | E | Nov. 2, 2024, 3:30 a.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 109 | 28876800 | ||
| 289355081 | flyingkite | E | Nov. 2, 2024, 4:55 a.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 109 | 32153600 | ||
| 289337358 | woega | E | Nov. 1, 2024, 11:42 p.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 109 | 36147200 | ||
| 289290496 | 4977 | E | Nov. 1, 2024, 5:19 p.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 109 | 57753600 | ||
| 289344054 | cockatooo | E | Nov. 2, 2024, 2:15 a.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 124 | 1126400 | ||
| 289318347 | jackson.souza | E | Nov. 1, 2024, 7:42 p.m. | OK | C++20 (GCC 13-64) | TESTS | 35 | 124 | 2867200 | ||
| 289343175 | Marckess | E | Nov. 2, 2024, 1:59 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 109 | 7270400 | ||
| 289353746 | _Gawd_ | E | Nov. 2, 2024, 4:38 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 124 | 4403200 | ||
| 289342448 | scutsky | E | Nov. 2, 2024, 1:45 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 125 | 28160000 | ||
| 289302876 | hihihaha | E | Nov. 1, 2024, 6:19 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 139 | 3276800 | ||
| 289348358 | Diamondd | E | Nov. 2, 2024, 3:24 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 140 | 2867200 | ||
| 289339876 | Edeeva | E | Nov. 2, 2024, 12:49 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 140 | 2867200 | ||
| 289353819 | _Gawd_ | E | Nov. 2, 2024, 4:39 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 140 | 4403200 | ||
| 289352696 | koigy | E | Nov. 2, 2024, 4:24 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 140 | 5222400 | ||
| 289334054 | waipoli | E | Nov. 1, 2024, 10:24 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 140 | 6144000 | ||
| 289298093 | lrvideckis | E | Nov. 1, 2024, 5:56 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 35 | 140 | 7680000 | ||
| 289355430 | -dub-otrezkov- | E | Nov. 2, 2024, 4:59 a.m. | OK | Go | TESTS | 35 | 203 | 10137600 | ||
| 289349578 | lyongwolf | E | Nov. 2, 2024, 3:42 a.m. | OK | Java 21 | TESTS | 35 | 343 | 716800 | ||
| 289315080 | Sarvan_Yaduvanshi | E | Nov. 1, 2024, 7:23 p.m. | OK | Java 21 | TESTS | 35 | 671 | 103014400 | ||
| 289292357 | bnmanubharadwaj | E | Nov. 1, 2024, 5:27 p.m. | OK | Node.js | TESTS | 35 | 499 | 125952000 | ||
| 289334499 | OpKos | E | Nov. 1, 2024, 10:33 p.m. | OK | PyPy 3 | TESTS | 35 | 765 | 97792000 | ||
| 289291763 | fatalerror | E | Nov. 1, 2024, 5:24 p.m. | OK | PyPy 3-64 | TESTS | 35 | 327 | 27648000 | ||
| 289335505 | petamingks | E | Nov. 1, 2024, 10:56 p.m. | OK | PyPy 3-64 | TESTS | 35 | 359 | 30720000 | ||
| 289295608 | Mathwiz_on_AoPS | E | Nov. 1, 2024, 5:43 p.m. | OK | PyPy 3-64 | TESTS | 35 | 374 | 53452800 | ||
| 289289476 | PROELECTRO444 | E | Nov. 1, 2024, 5:15 p.m. | OK | PyPy 3-64 | TESTS | 35 | 390 | 53248000 | ||
| 289289897 | alexwice | E | Nov. 1, 2024, 5:16 p.m. | OK | PyPy 3-64 | TESTS | 35 | 468 | 30310400 | ||
| 289358710 | 1021839 | E | Nov. 2, 2024, 5:35 a.m. | OK | PyPy 3-64 | TESTS | 35 | 905 | 30208000 | ||
| 289286433 | Klass_Mars | E | Nov. 1, 2024, 4:34 p.m. | OK | PyPy 3-64 | TESTS | 35 | 1109 | 29388800 | ||
| 289297804 | alexwice | E | Nov. 1, 2024, 5:54 p.m. | OK | PyPy 3-64 | TESTS | 35 | 1358 | 74444800 | ||
| 289293299 | AkiLotus | E | Nov. 1, 2024, 5:32 p.m. | OK | Python 3 | TESTS | 35 | 921 | 42086400 | ||
| 289292598 | shade34 | E | Nov. 1, 2024, 5:28 p.m. | OK | Python 3 | TESTS | 35 | 1171 | 44748800 | ||
| 289351558 | tifv | E | Nov. 2, 2024, 4:09 a.m. | OK | Rust 2021 | TESTS | 35 | 390 | 204800 |
Back to search problems