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 |
---|---|---|---|---|---|---|
1882 | Codeforces Round 899 (Div. 2) | FINISHED | False | 7200 | 48871500 | Sept. 25, 2023, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 318 ) | E2 | Two Permutations (Hard Version) | PROGRAMMING | constructive algorithms |
B'This is the hard version of the problem. The difference between the two versions is that you have to minimize the number of operations in this version. You can make hacks only if both versions of the problem are solved. You have two permutations ^{ dagger} p_{1}, p_{2}, ldots, p_{n} (of integers 1 to n ) and q_{1}, q_{2}, ldots, q_{m} (of integers 1 to m ). Initially p_{i}=a_{i} for i=1, 2, ldots, n , and q_{j} = b_{j} for j = 1, 2, ldots, m . You can apply the following operation on the permutations several (possibly, zero) times. In one operation, p and q will change according to the following three steps: Your goal is to simultaneously make p_{i}=i for i=1, 2, ldots, n , and q_{j} = j for j = 1, 2, ldots, m . Find any way to achieve the goal using the minimum number of operations possible, or say that none exists. Please note that you have to minimize the number of operations. ^{ dagger} A permutation of length k is an array consisting of k distinct integers from 1 to k 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 ( k=3 but there is 4 in the array). The first line contains two integers n and m ( 1 <= n, m <= 2500 ). The second line contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= n ). The third line contains m integers b_1, b_2, ldots, b_m ( 1 <= b_i <= m ). It is guaranteed that a and b are permutations. If there is no solution, print a single integer -1 . Otherwise, print an integer k -- the number of operations to perform, followed by k lines, each containing two integers i and j ( 1 <= i <= n , 1 <= j <= m ) -- the integers chosen for the operation. '... |
Codeforces Round 899 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
225196960 | Ocelot_666 | E2 | Sept. 26, 2023, 2:08 a.m. | OK | GNU C++17 | TESTS | 103 | 187 | 102400 | ||
225164174 | regain0002 | E2 | Sept. 25, 2023, 5:51 p.m. | OK | GNU C++17 | TESTS | 103 | 218 | 614400 | ||
225209305 | liympanda | E2 | Sept. 26, 2023, 5:19 a.m. | OK | GNU C++17 | TESTS | 103 | 218 | 1126400 | ||
225173254 | kotatsugame | E2 | Sept. 25, 2023, 7:10 p.m. | OK | GNU C++17 (64) | TESTS | 103 | 171 | 921600 | ||
225206030 | chappy1 | E2 | Sept. 26, 2023, 4:32 a.m. | OK | GNU C++17 (64) | TESTS | 103 | 202 | 83046400 | ||
225159778 | Geothermal | E2 | Sept. 25, 2023, 5:20 p.m. | OK | GNU C++17 (64) | TESTS | 103 | 249 | 921600 | ||
225195999 | locsey | E2 | Sept. 26, 2023, 1:50 a.m. | OK | GNU C++20 (64) | TESTS | 103 | 46 | 102400 | ||
225156982 | BurnedChicken | E2 | Sept. 25, 2023, 5:04 p.m. | OK | GNU C++20 (64) | TESTS | 103 | 62 | 102400 | ||
225158476 | GusterGoose27 | E2 | Sept. 25, 2023, 5:12 p.m. | OK | GNU C++20 (64) | TESTS | 103 | 78 | 1740800 | ||
225169614 | S.ystem | E2 | Sept. 25, 2023, 6:35 p.m. | OK | GNU C++20 (64) | TESTS | 103 | 93 | 204800 | ||
225169027 | Slamaa | E2 | Sept. 25, 2023, 6:29 p.m. | OK | GNU C++20 (64) | TESTS | 103 | 93 | 204800 | ||
225160002 | vjudge39 | E2 | Sept. 25, 2023, 5:21 p.m. | OK | GNU C++20 (64) | TESTS | 103 | 93 | 204800 | ||
225153127 | Sulfox | E2 | Sept. 25, 2023, 4:32 p.m. | OK | GNU C++20 (64) | TESTS | 103 | 93 | 3276800 | ||
225190986 | A_G | E2 | Sept. 26, 2023, 12:09 a.m. | OK | GNU C++20 (64) | TESTS | 103 | 109 | 409600 | ||
225152769 | Vercingetorix | E2 | Sept. 25, 2023, 4:31 p.m. | OK | GNU C++20 (64) | TESTS | 103 | 109 | 716800 | ||
225207984 | neal | E2 | Sept. 26, 2023, 5:02 a.m. | OK | GNU C++20 (64) | TESTS | 103 | 140 | 409600 |
Back to search problems