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 |
|---|---|---|---|---|---|---|
| ( 183 ) | E2 | Determinant Construction (Hard Version) | PROGRAMMING | constructive algorithms matrices |
This is the hard version of the problem. The difference between the versions is that in this version, the constraints on the side length of (M) is smaller and the constraints on (t) is larger. You can hack only if you solved all versions of this problem. You are given a non-negative integer (x). Your task is to construct a square matrix (M) that satisfies all of the following conditions: The side length of (M) is at most (50). Each element of (M) is either (-1), (0), or (1). The determinant of (M) is equal to (x). Each row of (M) can have at most (3) non-zero positions, and each column of (M) can have at most (3) non-zero positions. It can be proven that such a matrix always exists. 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 and only line of each test case contains an integer (x) ((0 \le x \le 10^7)) — the target value of the determinant. For each test case, output a single integer (n) ((1\le n\le 50)) representing the side length of the square matrix (M). Then, output (n) lines, the (i)-th line containing (n) integers (M_{i, 1}, M_{i, 2}, \ldots, M_{i, n}) ((M_{i, j} \in \{-1, 0, 1\})), representing the elements of matrix (M). If there are multiple matrices (M) satisfying the conditions, you may output any of them. Note that in the third test case, the following solution: ()\begin{pmatrix} 1 & 1 & -1 & 1 \\ -1 & -1 & -1 & 1 \\ 1 & -1 & 0 & -1 \\ 1 & -1 & -1 & -1 \end{pmatrix}() is not valid as there are four non-zero positions in the first row of the matrix. |
| 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 337660028 | Arterm | E2 | Sept. 8, 2025, 5:33 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 280 | 0 | ||
| 337702810 | _lbw_ | E2 | Sept. 9, 2025, 5:27 a.m. | OK | C++20 (GCC 13-64) | TESTS | 25 | 280 | 102400 | ||
| 337630619 | Denisov | E2 | Sept. 8, 2025, 4:13 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 280 | 102400 | ||
| 337665794 | 0wuming0 | E2 | Sept. 8, 2025, 6:57 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 281 | 2662400 | ||
| 337689381 | tiger2005 | E2 | Sept. 9, 2025, 2:11 a.m. | OK | C++20 (GCC 13-64) | TESTS | 25 | 296 | 40140800 | ||
| 337704128 | amano_hina | E2 | Sept. 9, 2025, 5:44 a.m. | OK | C++20 (GCC 13-64) | TESTS | 25 | 327 | 102400 | ||
| 337666656 | gamegame | E2 | Sept. 8, 2025, 7:04 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 515 | 819200 | ||
| 337690023 | qiuzx | E2 | Sept. 9, 2025, 2:22 a.m. | OK | C++20 (GCC 13-64) | TESTS | 25 | 530 | 102400 | ||
| 337675217 | sevlll777 | E2 | Sept. 8, 2025, 8:39 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 827 | 0 | ||
| 337656226 | HaramuraNodoka | E2 | Sept. 8, 2025, 5:21 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 1108 | 102400 | ||
| 337683586 | Mamedov | E2 | Sept. 9, 2025, 12:10 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 25 | 124 | 0 | ||
| 337684821 | Mamedov | E2 | Sept. 9, 2025, 12:38 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 25 | 124 | 102400 | ||
| 337656326 | Nachia | E2 | Sept. 8, 2025, 5:21 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 155 | 102400 | ||
| 337633214 | maroonrk | E2 | Sept. 8, 2025, 4:19 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 265 | 42086400 | ||
| 337693320 | gyydp123_LIM | E2 | Sept. 9, 2025, 3:11 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 25 | 358 | 102400 | ||
| 337666498 | Time_Out_Soul | E2 | Sept. 8, 2025, 7:02 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 389 | 102400 | ||
| 337657644 | Ritwin | E2 | Sept. 8, 2025, 5:25 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 390 | 102400 | ||
| 337668614 | Ritwin | E2 | Sept. 8, 2025, 7:20 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 405 | 102400 | ||
| 337656875 | Su_Zipei | E2 | Sept. 8, 2025, 5:23 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 406 | 0 | ||
| 337635491 | antontrygubO_o | E2 | Sept. 8, 2025, 4:24 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 421 | 0 | ||
| 337675290 | Gassa | E2 | Sept. 8, 2025, 8:41 p.m. | OK | D | TESTS | 24 | 4937 | 102400 | ||
| 337666013 | rainboy | E2 | Sept. 8, 2025, 6:58 p.m. | OK | GNU C11 | TESTS | 24 | 4609 | 102400 | ||
| 337642866 | bribritt | E2 | Sept. 8, 2025, 4:42 p.m. | OK | PyPy 3-64 | TESTS | 24 | 265 | 9420800 | ||
| 337677003 | bronze_coder | E2 | Sept. 8, 2025, 9:10 p.m. | OK | PyPy 3-64 | TESTS | 24 | 702 | 10444800 | ||
| 337676412 | bronze_coder | E2 | Sept. 8, 2025, 8:59 p.m. | OK | PyPy 3-64 | TESTS | 24 | 1202 | 10752000 |
Back to search problems