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 |
|---|---|---|---|---|---|---|
| 2147 | Codeforces Global Round 29 (Div. 1 + Div. 2) | FINISHED | False | 10800 | 18026723 | Sept. 20, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 658 ) | F | Exchange Queries | PROGRAMMING | data structures greedy |
You are at a marketplace and there are two traders who are willing to trade on (n) different items. Each trader is represented by a permutation that signifies the relative value of the (n) items for that trader. Let's denote those two permutations (p) and (s). If you have an item (i), you can trade it for an item (j) if either (p_i > p_j) (using the first trader) or (s_i > s_j) (using the second trader). We say that an item (i) is at least as valuable as an item (j) if you can come to the marketplace with item (i), make some (possibly none) trades, and get item (j). Note that at any moment, you will have exactly one item on hand. Assume that the traders have infinite supplies of any item. Due to the never-ending updates in the market, traders will often reevaluate their views on the item values. You will be given (q) queries; each is a swap in one of the permutations. After every update, you should print the number of pairs ((i, j)) ((1 \le i, j \le n)) such that item (i) is at least as valuable as item (j). 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 two integers (n) and (q) ((2 \le n \le 10^5), (1 \le q \le 10^5)). The next two lines contain the initial permutations (p) and (s). The following (q) lines each contain three integers (tp), (i), (j) ((tp \in \{ 1, 2 \}), (1 \le i, j \le n), (i \ne j)). If (tp=1), swap (p_i) with (p_j). If (tp=2), swap (s_i) with (s_j). It is guaranteed that the sum of (n) over all test cases does not exceed (10^5), and the sum of (q) over all test cases does not exceed (10^5). For each test case, output (q) lines, the (k)-th of them containing a single integer — the number of pairs ((i, j)) such |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 339611184 | Az3ar | F | Sept. 20, 2025, 6:43 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 389 | 12083200 | ||
| 339595565 | -adhd- | F | Sept. 20, 2025, 5:09 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 592 | 20684800 | ||
| 339611435 | AA-2007 | F | Sept. 20, 2025, 6:44 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 608 | 23142400 | ||
| 339593976 | TadijaSebez | F | Sept. 20, 2025, 5:05 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 702 | 9625600 | ||
| 339599120 | sigmoid114 | F | Sept. 20, 2025, 5:20 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 734 | 2048000 | ||
| 339645472 | programpiggy | F | Sept. 21, 2025, 3:39 a.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 827 | 19251200 | ||
| 339602080 | kai824 | F | Sept. 20, 2025, 5:29 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 937 | 15769600 | ||
| 339597388 | Xuan2008 | F | Sept. 20, 2025, 5:15 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 952 | 21708800 | ||
| 339617838 | firewater.cryyy | F | Sept. 20, 2025, 7:26 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 968 | 32460800 | ||
| 339600968 | yookwi | F | Sept. 20, 2025, 5:26 p.m. | OK | C++17 (GCC 7-32) | TESTS | 22 | 1093 | 44134400 | ||
| 339613885 | Rubikun | F | Sept. 20, 2025, 6:58 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 249 | 17817600 | ||
| 339611653 | ngocnghia | F | Sept. 20, 2025, 6:45 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 249 | 23347200 | ||
| 339593387 | HugeWide | F | Sept. 20, 2025, 5:03 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 250 | 26931200 | ||
| 339601246 | JYJin | F | Sept. 20, 2025, 5:27 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 265 | 10956800 | ||
| 339611344 | Dragst | F | Sept. 20, 2025, 6:43 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 265 | 22528000 | ||
| 339613909 | VaVshchuck | F | Sept. 20, 2025, 6:58 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 311 | 5120000 | ||
| 339597952 | nosajuil | F | Sept. 20, 2025, 5:17 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 311 | 24576000 | ||
| 339642513 | houzhiyuan123 | F | Sept. 21, 2025, 2:42 a.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 358 | 13004800 | ||
| 339596111 | ballpoint_pen | F | Sept. 20, 2025, 5:11 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 358 | 18534400 | ||
| 339595895 | Kude | F | Sept. 20, 2025, 5:10 p.m. | OK | C++20 (GCC 13-64) | TESTS | 22 | 390 | 7372800 | ||
| 339596028 | onoco | F | Sept. 20, 2025, 5:11 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 234 | 30310400 | ||
| 339598107 | Be_dos | F | Sept. 20, 2025, 5:17 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 249 | 22835200 | ||
| 339656629 | aaditya.samadhiya11 | F | Sept. 21, 2025, 6:05 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 264 | 1843200 | ||
| 339626600 | weirdflexbutok | F | Sept. 20, 2025, 8:45 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 265 | 10240000 | ||
| 339597999 | Hoks_ | F | Sept. 20, 2025, 5:17 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 265 | 171417600 | ||
| 339644671 | __akash24_13 | F | Sept. 21, 2025, 3:24 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 280 | 19251200 | ||
| 339599642 | ridolo6937 | F | Sept. 20, 2025, 5:22 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 296 | 14336000 | ||
| 339599471 | mhb2010 | F | Sept. 20, 2025, 5:21 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 311 | 19251200 | ||
| 339631583 | amsraman | F | Sept. 20, 2025, 9:46 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 312 | 12390400 | ||
| 339611268 | defnotmee | F | Sept. 20, 2025, 6:43 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 22 | 312 | 13107200 | ||
| 339645798 | zouyu9631 | F | Sept. 21, 2025, 3:45 a.m. | OK | PyPy 3-64 | TESTS | 22 | 1812 | 46592000 | ||
| 339597606 | lagged | F | Sept. 20, 2025, 5:16 p.m. | OK | PyPy 3-64 | TESTS | 22 | 1952 | 96256000 | ||
| 339602307 | sansen | F | Sept. 20, 2025, 5:30 p.m. | OK | Rust 2021 | TESTS | 22 | 217 | 11366400 | ||
| 339589961 | Sugar_fan | F | Sept. 20, 2025, 4:53 p.m. | OK | Rust 2024 | TESTS | 22 | 296 | 13926400 |
Back to search problems