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 |
|---|---|---|---|---|---|---|
| 2002 | EPIC Institute of Technology Round August 2024 (Div. 1 + Div. 2) | FINISHED | False | 10800 | 53018723 | Aug. 11, 2024, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 2857 ) | D2 | DFS Checker (Hard Version) | PROGRAMMING | constructive algorithms data structures dfs and similar hashing implementation trees |
This is the hard version of the problem. In this version, you are given a generic tree and the constraints on (n) and (q) are higher. You can make hacks only if both versions of the problem are solved. You are given a rooted tree consisting of (n) vertices. The vertices are numbered from (1) to (n), and the root is the vertex (1). You are also given a permutation (p_1, p_2, \ldots, p_n) of (1,2,\ldots,n). You need to answer (q) queries. For each query, you are given two integers (x), (y); you need to swap (p_x) and (p_y) and determine if (p_1, p_2, \ldots, p_n) is a valid DFS order(^\dagger) of the given tree. Please note that the swaps are persistent through queries. (^\dagger) A DFS order is found by calling the following (dfs) function on the given tree. Note that the DFS order is not unique. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1\le t\le10^4)). The description of the test cases follows. The first line of each test case contains two integers (n), (q) ((2\le n\le 3\cdot 10^5), (2\le q\le 10^5)) — the number of vertices in the tree and the number of queries. The next line contains (n-1) integers (a_2,a_3,\ldots,a_n) ((1\le a_i<i)) — the parent of each vertex in the given tree. The next line contains (n) integers (p_1,p_2,\ldots,p_n) ((1\le p_i\le n), all (p_i) are distinct) — the initial permutation (p). The next (q) lines each contain two integers (x), (y) ((1\le x,y\le n,x\neq y)) — the positions of the elements to swap in the permutation. It is guaranteed that the sum of all (n) does not exceed (3\cdot 10^5), and the sum of all (q) does not exceed (10^5). For each test case, print (q) lines corresponding to the (q) queries. For each query, output (YES) if there is a DFS order that exactly equals the current per |
| EPIC Institute of Technology Round August 2024 (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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 275843672 | rsy__ | D2 | Aug. 11, 2024, 5:26 p.m. | OK | C++14 (GCC 6-32) | TESTS | 37 | 234 | 16896000 | ||
| 275862957 | neal | D2 | Aug. 11, 2024, 8:38 p.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 265 | 11161600 | ||
| 275877326 | antguz | D2 | Aug. 12, 2024, 1:43 a.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 280 | 16691200 | ||
| 275863456 | masonpop | D2 | Aug. 11, 2024, 8:46 p.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 312 | 11776000 | ||
| 275834904 | Little_CarT | D2 | Aug. 11, 2024, 4:58 p.m. | OK | C++14 (GCC 6-32) | TESTS | 37 | 312 | 26112000 | ||
| 275872646 | _FJqwq | D2 | Aug. 12, 2024, 12:16 a.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 327 | 17920000 | ||
| 275881604 | thanhdno | D2 | Aug. 12, 2024, 2:41 a.m. | OK | C++14 (GCC 6-32) | TESTS | 40 | 327 | 18124800 | ||
| 275880057 | mamingxiao | D2 | Aug. 12, 2024, 2:20 a.m. | OK | C++14 (GCC 6-32) | TESTS | 40 | 358 | 45568000 | ||
| 275878829 | yuannqwq | D2 | Aug. 12, 2024, 2:05 a.m. | OK | C++14 (GCC 6-32) | TESTS | 40 | 375 | 38297600 | ||
| 275896460 | supperpiggy | D2 | Aug. 12, 2024, 5:50 a.m. | OK | C++14 (GCC 6-32) | TESTS | 40 | 437 | 38297600 | ||
| 275862958 | neal | D2 | Aug. 11, 2024, 8:38 p.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 265 | 11161600 | ||
| 275891265 | dontforgetyourself | D2 | Aug. 12, 2024, 4:48 a.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 280 | 13107200 | ||
| 275861153 | Proofy | D2 | Aug. 11, 2024, 8:14 p.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 280 | 25190400 | ||
| 275874205 | LXH-cat | D2 | Aug. 12, 2024, 12:54 a.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 296 | 10752000 | ||
| 275859658 | radoslav11 | D2 | Aug. 11, 2024, 7:56 p.m. | OK | C++17 (GCC 7-32) | TESTS | 38 | 296 | 11161600 | ||
| 275856603 | jmyszka | D2 | Aug. 11, 2024, 7:22 p.m. | OK | C++17 (GCC 7-32) | TESTS | 37 | 312 | 12800000 | ||
| 275851789 | AliiSh | D2 | Aug. 11, 2024, 6:41 p.m. | OK | C++17 (GCC 7-32) | TESTS | 37 | 312 | 15564800 | ||
| 275836655 | 9320001e3 | D2 | Aug. 11, 2024, 5:03 p.m. | OK | C++17 (GCC 7-32) | TESTS | 37 | 312 | 20070400 | ||
| 275896060 | Xiaobaibubai | D2 | Aug. 12, 2024, 5:45 a.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 312 | 21504000 | ||
| 275851173 | kukuforward | D2 | Aug. 11, 2024, 6:37 p.m. | OK | C++17 (GCC 7-32) | TESTS | 37 | 312 | 21504000 | ||
| 275854340 | ImmortaLimit | D2 | Aug. 11, 2024, 7:01 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 156 | 47104000 | ||
| 275851587 | A_G | D2 | Aug. 11, 2024, 6:40 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 202 | 8396800 | ||
| 275838438 | A_G | D2 | Aug. 11, 2024, 5:10 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 218 | 8396800 | ||
| 275892170 | Orangeflavoredneck | D2 | Aug. 12, 2024, 5:01 a.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 233 | 21708800 | ||
| 275867407 | divanik | D2 | Aug. 11, 2024, 9:58 p.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 234 | 108646400 | ||
| 275878055 | Celebrate | D2 | Aug. 12, 2024, 1:54 a.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 249 | 16998400 | ||
| 275856780 | Gouk_ | D2 | Aug. 11, 2024, 7:24 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 280 | 27340800 | ||
| 275889048 | gcx12012 | D2 | Aug. 12, 2024, 4:20 a.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 281 | 25292800 | ||
| 275855938 | NekoYellow | D2 | Aug. 11, 2024, 7:15 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 312 | 23654400 | ||
| 275852735 | sjangy | D2 | Aug. 11, 2024, 6:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 312 | 23654400 | ||
| 275883885 | 2210030109_hitesh | D2 | Aug. 12, 2024, 3:11 a.m. | OK | Java 21 | TESTS | 40 | 1077 | 116736000 | ||
| 275841974 | Dukkha | D2 | Aug. 11, 2024, 5:21 p.m. | OK | Java 21 | TESTS | 37 | 1186 | 117760000 | ||
| 275869587 | profchi | D2 | Aug. 11, 2024, 10:51 p.m. | OK | Java 8 | TESTS | 39 | 1264 | 128512000 | ||
| 275869480 | profchi | D2 | Aug. 11, 2024, 10:48 p.m. | OK | Java 8 | TESTS | 39 | 1515 | 223948800 | ||
| 275869384 | profchi | D2 | Aug. 11, 2024, 10:46 p.m. | OK | Java 8 | TESTS | 39 | 1780 | 215142400 | ||
| 275869699 | profchi | D2 | Aug. 11, 2024, 10:55 p.m. | OK | Java 8 | TESTS | 39 | 1781 | 223232000 | ||
| 275869954 | profchi | D2 | Aug. 11, 2024, 11:02 p.m. | OK | Java 8 | TESTS | 39 | 1827 | 237056000 | ||
| 275869891 | profchi | D2 | Aug. 11, 2024, 11:01 p.m. | OK | Java 8 | TESTS | 39 | 1843 | 231628800 | ||
| 275869858 | profchi | D2 | Aug. 11, 2024, 11 p.m. | OK | Java 8 | TESTS | 39 | 1858 | 231628800 | ||
| 275869768 | profchi | D2 | Aug. 11, 2024, 10:57 p.m. | OK | Java 8 | TESTS | 39 | 1859 | 223334400 | ||
| 275869815 | profchi | D2 | Aug. 11, 2024, 10:58 p.m. | OK | Java 8 | TESTS | 39 | 1875 | 231628800 | ||
| 275876764 | profchi | D2 | Aug. 12, 2024, 1:35 a.m. | OK | Java 8 | TESTS | 39 | 1968 | 219648000 | ||
| 275851532 | misorin | D2 | Aug. 11, 2024, 6:39 p.m. | OK | PyPy 3-64 | TESTS | 37 | 562 | 57651200 | ||
| 275882395 | Little_Sheep_Yawn | D2 | Aug. 12, 2024, 2:52 a.m. | OK | PyPy 3-64 | TESTS | 40 | 1186 | 102195200 | ||
| 275891150 | NINGucas | D2 | Aug. 12, 2024, 4:47 a.m. | OK | PyPy 3-64 | TESTS | 40 | 1546 | 107417600 | ||
| 275839359 | chmpro | D2 | Aug. 11, 2024, 5:13 p.m. | OK | PyPy 3-64 | TESTS | 37 | 1687 | 88576000 | ||
| 275884923 | hxu10 | D2 | Aug. 12, 2024, 3:24 a.m. | OK | PyPy 3-64 | TESTS | 40 | 1749 | 176435200 |
Back to search problems