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 |
|---|---|---|---|---|---|---|
| 2268 | Codeforces Round 1124 (Div. 1) | FINISHED | False | 9000 | 746666 | Sept. 26, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 169 ) | F | Deglado | PROGRAMMING | constructive algorithms |
You are given a (2n \times 2n) grid (a) where each column is a permutation(^{\text{∗}}) of length (2n). We want to sort all columns in ascending order from top to bottom by performing the following operation: Choose a (2 \times 2) subgrid and swap the two top elements with the two bottom elements. More formally, you can choose two integers (i) and (j) ((1 \leq i, j \lt 2n)), then swap (a_{i,j}) with (a_{i+1,j}) and swap (a_{i,j+1}) with (a_{i+1,j+1}). More formally, you can choose two integers (i) and (j) ((1 \leq i, j \lt 2n)), then swap (a_{i,j}) with (a_{i+1,j}) and swap (a_{i,j+1}) with (a_{i+1,j+1}). You have to sort all columns using at most (n \cdot \binom{2n}{2} + 9n) operations, or determine that it is impossible. Note that you do not need to minimize the number of operations. (^{\text{∗}})A permutation of length (m) is an array consisting of (m) distinct integers from (1) to (m) 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 ((m=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 500)). The description of the test cases follows. The first line of each test contains a single integer (n) ((1 \leq n \leq 80)). The (i)-th line of the next (2n) lines contains (2n) integers (a_{i,1},a_{i,2},\ldots,a_{i,2n}) ((1 \leq a_{i,j} \leq 2n)) — the elements of the (i)-th row of the grid. It is guaranteed that every column in the grid forms a permutation of length (2n). It is guaranteed that the sum of (n^3) over all test cases does not exceed (80^3). For each test case, if it is impossible to sort all columns in at most (n \cdot \binom{2n}{2} + 9n) operations, print $$$-1 |
| 157140 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 392258807 | rnzhemvhtm | F | Sept. 26, 2026, 10:52 p.m. | OK | C++17 (GCC 7-32) | TESTS | 170 | 93 | 0 | ||
| 392240267 | David-M | F | Sept. 26, 2026, 5:53 p.m. | OK | C++17 (GCC 7-32) | TESTS | 169 | 1234 | 13312000 | ||
| 392260036 | Ormlis | F | Sept. 26, 2026, 11:39 p.m. | OK | C++20 (GCC 13-64) | TESTS | 170 | 156 | 10035200 | ||
| 392239690 | 123456789010111213141516 | F | Sept. 26, 2026, 5:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 169 | 171 | 9420800 | ||
| 392231833 | Ormlis | F | Sept. 26, 2026, 4:55 p.m. | OK | C++20 (GCC 13-64) | TESTS | 169 | 171 | 10035200 | ||
| 392235881 | 17326020824 | F | Sept. 26, 2026, 5:19 p.m. | OK | C++20 (GCC 13-64) | TESTS | 169 | 187 | 10035200 | ||
| 392244867 | AlefHeKaaf | F | Sept. 26, 2026, 6:35 p.m. | OK | C++20 (GCC 13-64) | TESTS | 170 | 187 | 22118400 | ||
| 392282363 | macepag726 | F | Sept. 27, 2026, 4:46 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 170 | 156 | 10137600 | ||
| 392281442 | mhb2010 | F | Sept. 27, 2026, 4:28 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 170 | 156 | 10137600 | ||
| 392262408 | azizs | F | Sept. 27, 2026, 1:06 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 170 | 171 | 10137600 | ||
| 392286606 | xxxzenu | F | Sept. 27, 2026, 5:43 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 170 | 187 | 10035200 | ||
| 392233530 | idontwannadothisanymore | F | Sept. 26, 2026, 5:02 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 169 | 187 | 10240000 | ||
| 392278035 | ShangshangZhang | F | Sept. 27, 2026, 3:22 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 170 | 187 | 22937600 | ||
| 392253620 | RecurseKing | F | Sept. 26, 2026, 8:36 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 170 | 1500 | 10547200 | ||
| 392253950 | XXJACK | F | Sept. 26, 2026, 8:42 p.m. | OK | Java 21 | TESTS | 170 | 625 | 63488000 | ||
| 392286734 | xxxzenu | F | Sept. 27, 2026, 5:44 a.m. | OK | PyPy 3-64 | TESTS | 170 | 500 | 30822400 |
Back to search problems