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 |
|---|---|---|---|---|---|---|
| 2190 | Codeforces Round 1073 (Div. 1) | FINISHED | False | 10800 | 7745123 | Jan. 17, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 226 ) | E | Median Permutation | PROGRAMMING | combinatorics |
For a permutation(^{\text{∗}}) (q) of size (m \ge 3), define (f(q)) to be a sequence (b) of size (m - 2) such that (b_i = \operatorname{med}(q_i, q_{i + 1}, q_{i + 2})) for all (1 \le i \le m - 2). Here, (\operatorname{med}(x, y, z)) denotes the second smallest element among (\{x, y, z\}). You are given an array (a) of size (n), where some elements may be (0). It is guaranteed that (a) contains the values (1) and (n) (that is, there exist indices (i, j) such that (a_i = 1) and (a_j = n)). Find the number of permutations (p) of size (n) satisfying the following conditions: (p) is consistent with (a): for all (1 \le i \le n), if (a_i \neq 0), then (p_i = a_i). All elements of (f(p)) are distinct . Since the answer can be large, print it modulo (998\,244\,353). (^{\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^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((3 \le n \le 2 \cdot 10^5)) — the size of the array. The second line contains (n) integers (a_1, a_2, \ldots, a_n) ((0 \le a_i \le n)). It is guaranteed that all non-zero elements of (a) are pairwise distinct. It is also guaranteed that (a) contains the values (1) and (n). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, print a single integer — the number of permutations (p) satisfying the conditions, mod |
| Codeforces Round 1073 (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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 358363044 | JDScript0117 | E | Jan. 17, 2026, 5:16 p.m. | OK | C++17 (GCC 7-32) | TESTS | 46 | 109 | 4096000 | ||
| 358368717 | potato167 | E | Jan. 17, 2026, 5:33 p.m. | OK | C++17 (GCC 7-32) | TESTS | 46 | 109 | 5324800 | ||
| 358377171 | ArturSmolenski | E | Jan. 17, 2026, 6:54 p.m. | OK | C++17 (GCC 7-32) | TESTS | 46 | 328 | 15667200 | ||
| 358378965 | ltyhanser | E | Jan. 17, 2026, 7:09 p.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 78 | 8806400 | ||
| 358402874 | lhy123 | E | Jan. 18, 2026, 3:51 a.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 78 | 10444800 | ||
| 358356493 | StarSilk | E | Jan. 17, 2026, 4:56 p.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 93 | 5632000 | ||
| 358390071 | 244mhq | E | Jan. 17, 2026, 9:24 p.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 93 | 10752000 | ||
| 358367515 | kotatsugame | E | Jan. 17, 2026, 5:30 p.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 109 | 4608000 | ||
| 358351274 | tourist | E | Jan. 17, 2026, 4:42 p.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 109 | 5324800 | ||
| 358367105 | Kasane_Teto | E | Jan. 17, 2026, 5:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 109 | 10649600 | ||
| 358400265 | qiuzx | E | Jan. 18, 2026, 2:55 a.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 171 | 4096000 | ||
| 358351776 | strapple | E | Jan. 17, 2026, 4:43 p.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 171 | 5632000 | ||
| 358363364 | PCTprobability | E | Jan. 17, 2026, 5:17 p.m. | OK | C++20 (GCC 13-64) | TESTS | 46 | 203 | 37990400 | ||
| 358343490 | Petr | E | Jan. 17, 2026, 4:24 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 78 | 1740800 | ||
| 358381639 | DimaN | E | Jan. 17, 2026, 7:35 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 78 | 1843200 | ||
| 358349219 | jiangly | E | Jan. 17, 2026, 4:37 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 78 | 4710400 | ||
| 358402498 | sunrise1024 | E | Jan. 18, 2026, 3:44 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 78 | 6451200 | ||
| 358406920 | lyh3.14 | E | Jan. 18, 2026, 5:02 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 78 | 6656000 | ||
| 358385014 | Benq | E | Jan. 17, 2026, 8:10 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 93 | 3379200 | ||
| 358376074 | catgirl | E | Jan. 17, 2026, 6:46 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 93 | 10547200 | ||
| 358400397 | lyh3.14 | E | Jan. 18, 2026, 2:58 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 93 | 21504000 | ||
| 358374757 | BurnedChicken | E | Jan. 17, 2026, 6:36 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 109 | 4403200 | ||
| 358365671 | leinad2 | E | Jan. 17, 2026, 5:24 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 46 | 109 | 10547200 | ||
| 358386754 | rainboy | E | Jan. 17, 2026, 8:34 p.m. | OK | GNU C11 | TESTS | 46 | 78 | 5632000 | ||
| 358374939 | golomb | E | Jan. 17, 2026, 6:37 p.m. | OK | PyPy 3-64 | TESTS | 46 | 312 | 40345600 | ||
| 358396466 | smilences | E | Jan. 18, 2026, 1:15 a.m. | OK | PyPy 3-64 | TESTS | 46 | 343 | 44339200 |
Back to search problems