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 |
|---|---|---|---|---|---|---|
| 2246 | Codeforces Round 1108 (Div. 2) | FINISHED | False | 8100 | 2733884 | July 12, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 226 ) | F | Whoname and Unsorted Array | PROGRAMMING | constructive algorithms |
Given a permutation(^{\text{∗}}) (p) of length (n), you may perform the following operation on it any number of times (possibly zero): Choose an index (i) where (1 \leq i \leq n-1), and move (p_i) to (p_1) (shifting everything in between to the right) and (p_{i+1}) to (p_n) (shifting everything in between to the left). Formally, you may transform (p = p_1, \ldots, p_n) into (p' = p_i, p_1, p_2, \ldots, p_{i-1}, p_{i+2}, p_{i+3}, \ldots, p_n, p_{i+1}.) Provide a valid sequence of operations of length at most (4n) to make (p_i = i) for all (i\,(1 \le i \le n)), or print (-1) if no sequence exists. It can be shown that if a valid sequence of operations exists, there is a valid sequence of length at most (4n) operations. (^{\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^3)). The description of the test cases follows. The first line contains an integer (n\,(2 \leq n \leq 5000)) — the length of the permutation. The second line contains (n) integers (p_1, p_2, \ldots, p_n \, (1 \le p_i \le n)). It is guaranteed that (p) is a permutation. It is guaranteed that the sum of (n) over all test cases does not exceed (5000). If there does not exist a valid sequence of operations, output (-1). Otherwise, on the first line, output (x\,(0 \leq x \leq 4n)), the number of operations needed to sort the permutation. On the second line, output (x) integers (i_1, \ldots, i_x) where (i_j) ((1 \leq i_j \leq n-1)) denotes the index corresponding t |
| Codeforces Round 1108 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 382298170 | aaraverma7 | F | July 12, 2026, 4:48 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 46 | 0 | ||
| 382289794 | tnecsed | F | July 12, 2026, 4:23 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 62 | 0 | ||
| 382293063 | potato167 | F | July 12, 2026, 4:34 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 109 | 0 | ||
| 382301741 | shadowDH | F | July 12, 2026, 5:12 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 109 | 102400 | ||
| 382288650 | qixiaojie123 | F | July 12, 2026, 4:19 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 109 | 102400 | ||
| 382295788 | REAL_DON_2027 | F | July 12, 2026, 4:42 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 125 | 102400 | ||
| 382297679 | tranducbaolam | F | July 12, 2026, 4:47 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 156 | 0 | ||
| 382303170 | dizang | F | July 12, 2026, 5:23 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 156 | 8089600 | ||
| 382329918 | Ermiooo159 | F | July 12, 2026, 11:44 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 406 | 3276800 | ||
| 382346495 | tentsyntax | F | July 13, 2026, 4:15 a.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 46 | 0 | ||
| 382343391 | CutSandstone | F | July 13, 2026, 3:47 a.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 46 | 0 | ||
| 382340856 | CutSandstone | F | July 13, 2026, 3:21 a.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 46 | 0 | ||
| 382297931 | sdfdsgrera | F | July 12, 2026, 4:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 46 | 0 | ||
| 382348983 | RiasGremory24 | F | July 13, 2026, 4:47 a.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 46 | 102400 | ||
| 382340431 | awwwyan | F | July 13, 2026, 3:17 a.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 62 | 0 | ||
| 382330417 | wildhonestfur | F | July 13, 2026, 12:06 a.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 62 | 0 | ||
| 382315188 | wuhudsm | F | July 12, 2026, 6:56 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 62 | 0 | ||
| 382301678 | Xerxes | F | July 12, 2026, 5:12 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 78 | 0 | ||
| 382316596 | arpittestprivate | F | July 12, 2026, 7:11 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 109 | 0 | ||
| 382294288 | Dhakshith1189 | F | July 12, 2026, 4:38 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 46 | 0 | ||
| 382348349 | thuhabong | F | July 13, 2026, 4:38 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 46 | 102400 | ||
| 382299942 | goldenutu | F | July 12, 2026, 5:01 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 46 | 102400 | ||
| 382301671 | 0mar_01 | F | July 12, 2026, 5:12 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 62 | 0 | ||
| 382295707 | Rayo | F | July 12, 2026, 4:42 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 62 | 0 | ||
| 382291837 | Sk1ua | F | July 12, 2026, 4:30 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 62 | 0 | ||
| 382335612 | Edu175 | F | July 13, 2026, 2:13 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 62 | 102400 | ||
| 382301566 | Lolicodedao | F | July 12, 2026, 5:12 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 62 | 102400 | ||
| 382297594 | AA-2007 | F | July 12, 2026, 4:47 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 62 | 16793600 | ||
| 382317546 | vangoat | F | July 12, 2026, 7:22 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 78 | 0 | ||
| 382289019 | d11maan | F | July 12, 2026, 4:20 p.m. | OK | Go | TESTS | 40 | 62 | 2764800 | ||
| 382293278 | Bitan1234 | F | July 12, 2026, 4:35 p.m. | OK | Java 21 | TESTS | 40 | 359 | 1945600 | ||
| 382339134 | vishu00 | F | July 13, 2026, 3:03 a.m. | OK | Java 21 | TESTS | 40 | 750 | 1843200 | ||
| 382340993 | Little_Sheep_Yawn | F | July 13, 2026, 3:22 a.m. | OK | PyPy 3-64 | TESTS | 40 | 437 | 8908800 | ||
| 382309492 | gausset | F | July 12, 2026, 6:15 p.m. | OK | PyPy 3-64 | TESTS | 40 | 1031 | 7680000 | ||
| 382301100 | VSS504327MuhammadI | F | July 12, 2026, 5:08 p.m. | OK | Python 3 | TESTS | 40 | 296 | 2048000 | ||
| 382298501 | Monish2000 | F | July 12, 2026, 4:49 p.m. | OK | Python 3 | TESTS | 40 | 328 | 1945600 | ||
| 382297461 | aduwahi | F | July 12, 2026, 4:47 p.m. | OK | Python 3 | TESTS | 40 | 812 | 3072000 |
Back to search problems