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 |
---|---|---|---|---|---|---|
1838 | Codeforces Round 877 (Div. 2) | FINISHED | False | 7200 | 51376463 | June 4, 2023, 2:45 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 16725 ) | B | Minimize Permutation Subarrays | PROGRAMMING | constructive algorithms greedy math |
B'You are given a permutation p of size n . You want to minimize the number of subarrays of p that are permutations. In order to do so, you must perform the following operation exactly once: For example, if p = [5, 1, 4, 2, 3] and we choose i = 2 , j = 3 , the resulting array will be [5, 4, 1, 2, 3] . If instead we choose i = j = 5 , the resulting array will be [5, 1, 4, 2, 3] . Which choice of i and j will minimize the number of subarrays that are permutations? A permutation of length n is an array consisting of n distinct integers from 1 to n 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 ( n=3 but there is 4 in the array). An array a is a subarray of an array b if a can be obtained from b by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. The first line of the input contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 3 <= n <= 2 cdot 10^5 ) -- the size of the permutation. The next line of each test case contains n integers p_1, p_2, ldots p_n ( 1 <= p_i <= n , all p_i are distinct) -- the elements of the permutation p . It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, output two integers i and j ( 1 <= i, j <= n ) -- the indices to swap in p . If there are multiple solutions, print any of them. For the first test case, there are four possible arrays after the swap: For the third sample case, after we swap elements at positions 2 '... |
Codeforces Round #877 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
208534556 | F_hh | B | June 5, 2023, 12:23 a.m. | OK | Clang++17 Diagnostics | TESTS | 15 | 717 | 1024000 | ||
208533258 | f2021ljh | B | June 4, 2023, 11:31 p.m. | OK | GNU C++14 | TESTS | 15 | 46 | 0 | ||
208534320 | admin1lin2 | B | June 5, 2023, 12:14 a.m. | OK | GNU C++14 | TESTS | 15 | 46 | 819200 | ||
208526423 | kashinbrij | B | June 4, 2023, 8:21 p.m. | OK | GNU C++14 | TESTS | 15 | 46 | 819200 | ||
208524828 | Abid_52 | B | June 4, 2023, 7:55 p.m. | OK | GNU C++14 | TESTS | 15 | 46 | 819200 | ||
208522963 | Acadaniket_1729 | B | June 4, 2023, 7:29 p.m. | OK | GNU C++14 | TESTS | 15 | 46 | 819200 | ||
208501478 | defective | B | June 4, 2023, 4:26 p.m. | OK | GNU C++14 | TESTS | 15 | 46 | 819200 | ||
208546615 | _wh | B | June 5, 2023, 4:48 a.m. | OK | GNU C++14 | TESTS | 15 | 46 | 4812800 | ||
208533365 | Malak_Slimene | B | June 4, 2023, 11:36 p.m. | OK | GNU C++14 | TESTS | 15 | 61 | 819200 | ||
208524584 | Sparks87 | B | June 4, 2023, 7:51 p.m. | OK | GNU C++14 | TESTS | 15 | 61 | 819200 | ||
208502455 | Rezkaudi | B | June 4, 2023, 4:28 p.m. | OK | GNU C++14 | TESTS | 15 | 61 | 819200 |
Back to search problems