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 |
|---|---|---|---|---|---|---|
| 2239 | Codeforces Round 1105 (Div. 1) | FINISHED | False | 9000 | 2906698 | June 27, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 1267 ) | C | Revival | PROGRAMMING | binary search constructive algorithms data structures math two pointers |
Consider a permutation (p) of (1, 2, \ldots, n). Let (s_i) denote the number of inversions in the entire prefix (p_1, p_2, \ldots, p_i), defined as: () s_i = \sum_{1 \le x \lt y \le i} p_x \gt p_y, () where the square parantheses denote the Iverson bracket notation. For each position (i) ((1 \le i \le n)), you are given a condition in the form of either (p_i = x) or (s_i = x). Your task is to reconstruct the original permutation (p). 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. For each test case: The first line contains a single integer (n) ((1 \le n \le 2\cdot 10^5)). Each of the following (n) lines contains a character (c) ((c \in \{\text{'p'}, \text{'s'}\})) and an integer (x): If (c = \text{'p'}), it denotes that (p_i = x), where (1 \le x \le n). If (c = \text{'s'}), it denotes that (s_i = x), where (0 \le x \le \frac{i(i-1)}{2}). The sum of (n) over all test cases does not exceed (2\cdot 10^5). It is guaranteed that a valid permutation always exists. For each test case, output (n) integers representing the permutation (p). If there are multiple valid permutations, you can output any of them. In the first test case, the values of all elements are explicitly given, so the unique valid permutation is (\{1, 2, 3\}). In the second test case, we need to reconstruct the permutation from the prefix inversion counts: For position (2), the number of inversions increases by (s_2 - s_1 = 1 - 0 = 1). This means (p_2) must be smaller than exactly one element before it, so (p_1 \gt p_2). For position (3), the number of inversions increases by (s_3 - s_2 = 2 - 1 = 1). This means (p_3) is smaller than exactly one element before it. In the third test case, we are given (p_1 = 1) and (p_3 = 2). The only |
| Codeforces Round 1105 (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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 380357546 | -firefly- | C | June 27, 2026, 4:03 p.m. | OK | C# 13 | TESTS | 18 | 2234 | 33587200 | ||
| 380412608 | sunchenyu2012 | C | June 28, 2026, 4:28 a.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 140 | 0 | ||
| 380341002 | _annhien_ruby22 | C | June 27, 2026, 3:14 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 171 | 1331200 | ||
| 380352666 | dyzets | C | June 27, 2026, 3:46 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 187 | 2457600 | ||
| 380361470 | frznhc | C | June 27, 2026, 4:19 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 187 | 9625600 | ||
| 380357520 | tianbincheng | C | June 27, 2026, 4:03 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 187 | 33075200 | ||
| 380360338 | Tony_Tung | C | June 27, 2026, 4:14 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 234 | 3276800 | ||
| 380342208 | qwef_ | C | June 27, 2026, 3:17 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 234 | 33075200 | ||
| 380368089 | songzhixin | C | June 27, 2026, 4:51 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 234 | 41062400 | ||
| 380366149 | dang3r | C | June 27, 2026, 4:41 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 250 | 5427200 | ||
| 380365460 | JaeminPark | C | June 27, 2026, 4:37 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 265 | 3993600 | ||
| 380409329 | Milkcat2009 | C | June 28, 2026, 3:17 a.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 62 | 23142400 | ||
| 380377323 | Top12 | C | June 27, 2026, 6:14 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 93 | 1740800 | ||
| 380386955 | CutSandstone | C | June 27, 2026, 8:04 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 109 | 0 | ||
| 380358574 | everflame | C | June 27, 2026, 4:07 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 109 | 1024000 | ||
| 380367624 | swehoneycodes | C | June 27, 2026, 4:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 109 | 6963200 | ||
| 380340787 | Survivor_winner | C | June 27, 2026, 3:14 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 109 | 8294400 | ||
| 380407315 | iloveMT | C | June 28, 2026, 2:26 a.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 109 | 12595200 | ||
| 380362506 | superguymj | C | June 27, 2026, 4:23 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 125 | 0 | ||
| 380353582 | Kherkani_36 | C | June 27, 2026, 3:49 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 125 | 1843200 | ||
| 380345834 | yeminghan | C | June 27, 2026, 3:26 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 125 | 3481600 | ||
| 380414844 | jtrh | C | June 28, 2026, 5:12 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 93 | 1024000 | ||
| 380351917 | orange_man | C | June 27, 2026, 3:44 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 93 | 2355200 | ||
| 380380137 | shristi36 | C | June 27, 2026, 6:51 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 93 | 3481600 | ||
| 380364059 | Wael_Zaiback | C | June 27, 2026, 4:30 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 109 | 102400 | ||
| 380335877 | jiangly | C | June 27, 2026, 3:03 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 109 | 102400 | ||
| 380363247 | Noobish_Monk | C | June 27, 2026, 4:27 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 109 | 307200 | ||
| 380404522 | dooglius | C | June 28, 2026, 12:59 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 109 | 2048000 | ||
| 380410956 | fantasy05 | C | June 28, 2026, 3:53 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 109 | 2355200 | ||
| 380354442 | Boboge | C | June 27, 2026, 3:52 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 109 | 2355200 | ||
| 380368708 | teekaytai | C | June 27, 2026, 4:54 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 109 | 3891200 | ||
| 380388858 | Gassa | C | June 27, 2026, 8:20 p.m. | OK | D | TESTS | 18 | 468 | 3174400 | ||
| 380366606 | Gassa | C | June 27, 2026, 4:43 p.m. | OK | D | TESTS | 18 | 484 | 3174400 | ||
| 380387988 | Gassa | C | June 27, 2026, 8:14 p.m. | OK | D | TESTS | 18 | 531 | 3174400 | ||
| 380343802 | gofrozen21 | C | June 27, 2026, 3:21 p.m. | OK | Java 21 | TESTS | 18 | 671 | 6246400 | ||
| 380351855 | LT1 | C | June 27, 2026, 3:43 p.m. | OK | Java 21 | TESTS | 18 | 1187 | 921600 | ||
| 380350668 | hardgonnapass | C | June 27, 2026, 3:40 p.m. | OK | Java 8 | TESTS | 18 | 234 | 3379200 | ||
| 380364283 | malachi_toney_goat | C | June 27, 2026, 4:31 p.m. | OK | Java 8 | TESTS | 18 | 1531 | 18329600 | ||
| 380341400 | arvindf232 | C | June 27, 2026, 3:15 p.m. | OK | Kotlin 2.2 | TESTS | 18 | 921 | 13004800 | ||
| 380351914 | bitplease_ | C | June 27, 2026, 3:44 p.m. | OK | Node.js | TESTS | 18 | 281 | 72294400 | ||
| 380386911 | golomb | C | June 27, 2026, 8:03 p.m. | OK | PyPy 3-64 | TESTS | 18 | 484 | 21196800 | ||
| 380351066 | harurun4635 | C | June 27, 2026, 3:41 p.m. | OK | PyPy 3-64 | TESTS | 18 | 718 | 25395200 | ||
| 380362109 | mikelou | C | June 27, 2026, 4:21 p.m. | OK | PyPy 3-64 | TESTS | 18 | 734 | 26419200 | ||
| 380350572 | toam | C | June 27, 2026, 3:39 p.m. | OK | PyPy 3-64 | TESTS | 18 | 1906 | 39219200 | ||
| 380351842 | Z_actuary | C | June 27, 2026, 3:43 p.m. | OK | PyPy 3-64 | TESTS | 18 | 2359 | 33177600 | ||
| 380349758 | maworkin | C | June 27, 2026, 3:37 p.m. | OK | Python 3 | TESTS | 18 | 1187 | 54169600 | ||
| 380367445 | Midhilesh | C | June 27, 2026, 4:47 p.m. | OK | Python 3 | TESTS | 18 | 1843 | 80588800 | ||
| 380348167 | sansen | C | June 27, 2026, 3:32 p.m. | OK | Rust 2021 | TESTS | 18 | 140 | 15155200 | ||
| 380367306 | cvs-650 | C | June 27, 2026, 4:47 p.m. | OK | Rust 2024 | TESTS | 18 | 171 | 19558400 | ||
| 380349835 | DanielAnker | C | June 27, 2026, 3:37 p.m. | OK | Rust 2024 | TESTS | 18 | 500 | 19456000 | ||
| 380365973 | Solalyth | C | June 27, 2026, 4:40 p.m. | OK | Rust 2024 | TESTS | 18 | 546 | 47104000 |
Back to search problems