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 |
|---|---|---|---|---|---|---|
| 2187 | Codeforces Round 1077 (Div. 1) | FINISHED | False | 10800 | 6708323 | Jan. 29, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 204 ) | F1 | Al Fine (Maximizing Version) | PROGRAMMING | binary search data structures divide and conquer greedy trees |
This is the maximizing version of the problem. The difference between the versions is that in this version, you need to find the maximum possible depth among all common trees. Also, the constraint on (n) in this version is larger. You can hack only if you solved all versions of this problem. For Christmas, Tortinita and Arietta each get a Christmas tree. Coincidentally, their trees share the same properties: both have (n+1) vertices and are rooted at vertex (0). In their Christmas card to you, each of them appends a DFS order sequence of their tree after their greetings. Recall that a DFS order sequence is generated by the following pseudocode. Let the DFS order sequence of Tortinita's tree be (a_0, a_1, \ldots, a_n) and that of Arietta's tree be (b_0, b_1, \ldots, b_n). You observe that (a_0 = b_0 = 0), and since they are twin sisters, you wonder if they could have the exact same tree. You also feel that for their Christmas tree, the sisters would not choose a trivial structure. Therefore, you want to find the maximum possible depth(^{\text{∗}}) among all common trees for both sequences . (^{\text{∗}})The depth of a tree is defined as the maximum number of edges on a simple path from any node to the root. 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 one integer (n) ((2 \le n \le 10^6)). The second line of each test case contains (n) integers (a_1, a_2, \cdots, a_n) ((1 \le a_i \le n)). The third line of each test case contains (n) integers (b_1, b_2, \cdots, b_n) ((1 \le b_i \le n)). It is guaranteed that neither sequence (a) nor (b) contains duplicates. It is guaranteed that the sum of (n) over all test cases does not exceed (10^6). For each test case, output one integer — the maximum possible depth among all common |
| Codeforces Round 1077 (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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 360596263 | hos.lyric | F1 | Jan. 29, 2026, 4:45 p.m. | OK | C++17 (GCC 7-32) | TESTS | 49 | 1156 | 48025600 | ||
| 360654037 | Kasane_Teto | F1 | Jan. 30, 2026, 2:59 a.m. | OK | C++17 (GCC 7-32) | TESTS | 49 | 1765 | 76185600 | ||
| 360599923 | Um_nik | F1 | Jan. 29, 2026, 4:53 p.m. | OK | C++17 (GCC 7-32) | TESTS | 49 | 1921 | 108544000 | ||
| 360597864 | qwef_ | F1 | Jan. 29, 2026, 4:49 p.m. | OK | C++17 (GCC 7-32) | TESTS | 49 | 1937 | 388915200 | ||
| 360620622 | mickeyjung | F1 | Jan. 29, 2026, 6:19 p.m. | OK | C++17 (GCC 7-32) | TESTS | 49 | 2953 | 95846400 | ||
| 360590434 | tourist | F1 | Jan. 29, 2026, 4:33 p.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 687 | 51712000 | ||
| 360655415 | Jelefy | F1 | Jan. 30, 2026, 3:23 a.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 703 | 120320000 | ||
| 360655235 | Jelefy | F1 | Jan. 30, 2026, 3:20 a.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 734 | 105779200 | ||
| 360629456 | Rubikun | F1 | Jan. 29, 2026, 7:27 p.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 781 | 190566400 | ||
| 360654987 | Jelefy | F1 | Jan. 30, 2026, 3:15 a.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 796 | 105779200 | ||
| 360626997 | Jelefy | F1 | Jan. 29, 2026, 7:04 p.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 796 | 113766400 | ||
| 360608136 | nantf | F1 | Jan. 29, 2026, 5:14 p.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 1046 | 160358400 | ||
| 360593061 | Dinprosperity | F1 | Jan. 29, 2026, 4:38 p.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 1203 | 64204800 | ||
| 360607553 | adam01 | F1 | Jan. 29, 2026, 5:12 p.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 1343 | 224665600 | ||
| 360612165 | bingpao | F1 | Jan. 29, 2026, 5:25 p.m. | OK | C++20 (GCC 13-64) | TESTS | 49 | 1375 | 148480000 | ||
| 360593836 | ecnerwala | F1 | Jan. 29, 2026, 4:40 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 406 | 100454400 | ||
| 360586290 | Nachia | F1 | Jan. 29, 2026, 4:25 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 687 | 108134400 | ||
| 360655473 | Jelefy | F1 | Jan. 30, 2026, 3:24 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 718 | 120422400 | ||
| 360659452 | kingcoder84 | F1 | Jan. 30, 2026, 4:25 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 812 | 134656000 | ||
| 360613634 | lzyrapx | F1 | Jan. 29, 2026, 5:29 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 968 | 178380800 | ||
| 360606414 | Golovanov399 | F1 | Jan. 29, 2026, 5:09 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 984 | 99225600 | ||
| 360603001 | noimi | F1 | Jan. 29, 2026, 5:01 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 1031 | 49049600 | ||
| 360615917 | hitonanode | F1 | Jan. 29, 2026, 5:34 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 1093 | 200601600 | ||
| 360599292 | BurnedChicken | F1 | Jan. 29, 2026, 4:52 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 1140 | 73625600 | ||
| 360574809 | Kevin114514 | F1 | Jan. 29, 2026, 4:06 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 49 | 1140 | 139980800 | ||
| 360664229 | DP_Once | F1 | Jan. 30, 2026, 5:15 a.m. | OK | Java 8 | TESTS | 49 | 640 | 127488000 |
Back to search problems