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 |
|---|---|---|---|---|---|---|
| 2003 | Codeforces Round 968 (Div. 2) | FINISHED | False | 7200 | 51809123 | Aug. 25, 2024, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 637 ) | E2 | Turtle and Inversions (Hard Version) | PROGRAMMING | brute force constructive algorithms data structures dp greedy two pointers |
This is a hard version of this problem. The differences between the versions are the constraint on (m) and (r_i < l_{i + 1}) holds for each (i) from (1) to (m - 1) in the easy version. You can make hacks only if both versions of the problem are solved. Turtle gives you (m) intervals (l_1, r_1, l_2, r_2, \ldots, l_m, r_m). He thinks that a permutation (p) is interesting if there exists an integer (k_i) for every interval ((l_i \le k_i < r_i)), and if he lets (a_i = \max\limits_{j = l_i}^{k_i} p_j, b_i = \min\limits_{j = k_i + 1}^{r_i} p_j) for every integer (i) from (1) to (m), the following condition holds: ()\max\limits_{i = 1}^m a_i < \min\limits_{i = 1}^m b_i() Turtle wants you to calculate the maximum number of inversions of all interesting permutations of length (n), or tell him if there is no interesting permutation. An inversion of a permutation (p) is a pair of integers ((i, j)) ((1 \le i < j \le n)) such that (p_i > p_j). 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 of each test case contains two integers (n, m) ((2 \le n \le 5 \cdot 10^3, 0 \le m \le 5 \cdot 10^3)) — the length of the permutation and the number of intervals. The (i)-th of the following (m) lines contains two integers (l_i, r_i) ((1 \le l_i < r_i \le n)) — the (i)-th interval. Note that there may exist identical intervals (i.e., there may exist two different indices (i, j) such that (l_i = l_j) and (r_i = r_j)). It is guaranteed that the sum of (n) over all test cases does not exceed (5 \cdot 10^3) and the sum of (m) over all test cases does not exceed (5 \cdot 10^3). For each test case, if there is no interesting permutation, output a single integer (-1). Otherwise, output a single integer — the max |
| sol-zh.pdf |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 278191668 | wenqizhi | E2 | Aug. 26, 2024, 3:03 a.m. | OK | C++14 (GCC 6-32) | TESTS | 45 | 62 | 204800 | ||
| 278191726 | QZJ114514 | E2 | Aug. 26, 2024, 3:04 a.m. | OK | C++14 (GCC 6-32) | TESTS | 45 | 93 | 204800 | ||
| 278196830 | Asuna241631 | E2 | Aug. 26, 2024, 4:22 a.m. | OK | C++14 (GCC 6-32) | TESTS | 45 | 203 | 204595200 | ||
| 278148674 | omeganot | E2 | Aug. 25, 2024, 4:33 p.m. | OK | C++14 (GCC 6-32) | TESTS | 45 | 234 | 197324800 | ||
| 278192190 | huang123zs | E2 | Aug. 26, 2024, 3:13 a.m. | OK | C++14 (GCC 6-32) | TESTS | 45 | 234 | 208691200 | ||
| 278193002 | Worldwide_D | E2 | Aug. 26, 2024, 3:25 a.m. | OK | C++14 (GCC 6-32) | TESTS | 45 | 249 | 200908800 | ||
| 278182419 | paulzrm | E2 | Aug. 25, 2024, 11:30 p.m. | OK | C++14 (GCC 6-32) | TESTS | 45 | 405 | 201011200 | ||
| 278184982 | NuclearMint | E2 | Aug. 26, 2024, 12:38 a.m. | OK | C++17 (GCC 7-32) | TESTS | 45 | 93 | 102400 | ||
| 278192451 | sxrcodeforces | E2 | Aug. 26, 2024, 3:16 a.m. | OK | C++17 (GCC 7-32) | TESTS | 45 | 109 | 104345600 | ||
| 278156355 | liympanda | E2 | Aug. 25, 2024, 5:57 p.m. | OK | C++17 (GCC 7-32) | TESTS | 45 | 218 | 208588800 | ||
| 278169290 | Sparkle_Twilight | E2 | Aug. 25, 2024, 7:53 p.m. | OK | C++17 (GCC 7-32) | TESTS | 45 | 249 | 200601600 | ||
| 278189932 | raincity | E2 | Aug. 26, 2024, 2:30 a.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 61 | 204800 | ||
| 278187217 | zjy2008 | E2 | Aug. 26, 2024, 1:32 a.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 62 | 204800 | ||
| 278189401 | JoesSR | E2 | Aug. 26, 2024, 2:19 a.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 77 | 102400 | ||
| 278181164 | njustbacon | E2 | Aug. 25, 2024, 10:57 p.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 77 | 102400 | ||
| 278173486 | Shantipriya | E2 | Aug. 25, 2024, 8:44 p.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 77 | 102400 | ||
| 278153308 | StellarSpecter | E2 | Aug. 25, 2024, 5:41 p.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 77 | 102400 | ||
| 278196359 | raincity | E2 | Aug. 26, 2024, 4:14 a.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 77 | 204800 | ||
| 278190755 | YuJiahe | E2 | Aug. 26, 2024, 2:47 a.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 77 | 204800 | ||
| 278194685 | hhhyh | E2 | Aug. 26, 2024, 3:50 a.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 78 | 102400 | ||
| 278188904 | JoesSR | E2 | Aug. 26, 2024, 2:09 a.m. | OK | C++20 (GCC 13-64) | TESTS | 45 | 78 | 102400 | ||
| 278185881 | neal | E2 | Aug. 26, 2024, 12:59 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 46 | 0 | ||
| 278186300 | neal | E2 | Aug. 26, 2024, 1:11 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 62 | 0 | ||
| 278197663 | pengyantong | E2 | Aug. 26, 2024, 4:34 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 62 | 204800 | ||
| 278186103 | neal | E2 | Aug. 26, 2024, 1:05 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 77 | 0 | ||
| 278183362 | oversolver | E2 | Aug. 25, 2024, 11:56 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 109 | 0 | ||
| 278185305 | neal | E2 | Aug. 26, 2024, 12:45 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 139 | 0 | ||
| 278149406 | Dominater069 | E2 | Aug. 25, 2024, 4:34 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 140 | 0 | ||
| 278185255 | neal | E2 | Aug. 26, 2024, 12:44 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 155 | 0 | ||
| 278185034 | neal | E2 | Aug. 26, 2024, 12:39 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 45 | 249 | 0 | ||
| 278174694 | golions | E2 | Aug. 25, 2024, 9:01 p.m. | OK | Java 8 | TESTS | 45 | 296 | 78438400 | ||
| 278174365 | golions | E2 | Aug. 25, 2024, 8:56 p.m. | OK | Java 8 | TESTS | 45 | 296 | 78438400 | ||
| 278172994 | golions | E2 | Aug. 25, 2024, 8:38 p.m. | OK | Java 8 | TESTS | 45 | 358 | 144588800 |
Back to search problems