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 |
---|---|---|---|---|---|---|
1768 | Codeforces Round 842 (Div. 2) | FINISHED | False | 7200 | 58893899 | Jan. 5, 2023, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 7249 ) | D | Lucky Permutation | PROGRAMMING | dfs and similar ds graphs greedy |
B'You are given a permutation ^ dagger p of length n . In one operation, you can choose two indices 1 <= i < j <= n and swap p_i with p_j . Find the minimum number of operations needed to have exactly one inversion ^ ddagger in the permutation. ^ dagger A permutation 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). ^ ddagger The number of inversions of a permutation p is the number of pairs of indices (i, j) such that 1 <= i < j <= n and p_i > p_j . The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n ( 2 <= n <= 2 cdot 10^5 ). The second line of each test case contains n integers p_1,p_2, ldots, p_n ( 1 <= p_i <= n ). It is guaranteed that p is a permutation. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case output a single integer -- the minimum number of operations needed to have exactly one inversion in the permutation. It can be proven that an answer always exists. In the first test case, the permutation already satisfies the condition. In the second test case, you can perform the operation with (i,j)=(1,2) , after that the permutation will be [2,1] which has exactly one inversion. In the third test case, it is not possible to satisfy the condition with less than 3 operations. However, if we perform 3 operations with (i,j) being (1,3) , (2,4) , and (3,4) in that order, the final permutation will be [1, 2, 4, 3] which '... |
Codeforces Round #842 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
188163370 | my_father | D | Jan. 6, 2023, 4:35 a.m. | OK | C# 10 | TESTS | 31 | 109 | 14745600 | ||
188154317 | Wizard_of_Orz | D | Jan. 6, 2023, 1:40 a.m. | OK | Clang++17 Diagnostics | TESTS | 31 | 140 | 921600 | ||
188126912 | rainboy | D | Jan. 5, 2023, 5:36 p.m. | OK | GNU C11 | TESTS | 30 | 93 | 1843200 | ||
188141422 | Remilia1023 | D | Jan. 5, 2023, 7:50 p.m. | OK | GNU C++14 | TESTS | 30 | 31 | 4096000 | ||
188147333 | conexposys | D | Jan. 5, 2023, 9:45 p.m. | OK | GNU C++14 | TESTS | 30 | 46 | 1638400 | ||
188169744 | include_c2 | D | Jan. 6, 2023, 5:54 a.m. | OK | GNU C++14 | TESTS | 31 | 46 | 1638400 | ||
188159258 | modinte | D | Jan. 6, 2023, 3:24 a.m. | OK | GNU C++14 | TESTS | 31 | 46 | 1638400 | ||
188127305 | hy2004 | D | Jan. 5, 2023, 5:37 p.m. | OK | GNU C++14 | TESTS | 30 | 46 | 2662400 | ||
188149842 | CuiZhenhang | D | Jan. 5, 2023, 11:06 p.m. | OK | GNU C++14 | TESTS | 30 | 46 | 6041600 | ||
188149976 | conexposys | D | Jan. 5, 2023, 11:11 p.m. | OK | GNU C++14 | TESTS | 30 | 61 | 1638400 | ||
188159121 | jiangnan123 | D | Jan. 6, 2023, 3:21 a.m. | OK | GNU C++14 | TESTS | 31 | 61 | 1638400 | ||
188121180 | alex09 | D | Jan. 5, 2023, 4:33 p.m. | OK | GNU C++14 | TESTS | 30 | 61 | 2355200 | ||
188159240 | 2022haha | D | Jan. 6, 2023, 3:23 a.m. | OK | GNU C++14 | TESTS | 31 | 61 | 2457600 | ||
188153284 | LxRBS | D | Jan. 6, 2023, 1:10 a.m. | OK | GNU C++17 | TESTS | 31 | 31 | 2048000 | ||
188140422 | jack112739 | D | Jan. 5, 2023, 7:35 p.m. | OK | GNU C++17 | TESTS | 30 | 46 | 819200 | ||
188158669 | hhhyh | D | Jan. 6, 2023, 3:14 a.m. | OK | GNU C++17 | TESTS | 31 | 46 | 1638400 | ||
188164793 | WhiteSmile | D | Jan. 6, 2023, 4:55 a.m. | OK | GNU C++17 | TESTS | 31 | 46 | 1638400 | ||
188163398 | gn_wz | D | Jan. 6, 2023, 4:35 a.m. | OK | GNU C++17 | TESTS | 31 | 46 | 1638400 | ||
188153481 | socoobo | D | Jan. 6, 2023, 1:16 a.m. | OK | GNU C++17 | TESTS | 31 | 46 | 1638400 | ||
188142960 | George_Rubio | D | Jan. 5, 2023, 8:14 p.m. | OK | GNU C++17 | TESTS | 30 | 46 | 1638400 | ||
188139307 | Zawos | D | Jan. 5, 2023, 7:20 p.m. | OK | GNU C++17 | TESTS | 30 | 46 | 1638400 | ||
188137000 | wbscd | D | Jan. 5, 2023, 6:50 p.m. | OK | GNU C++17 | TESTS | 30 | 46 | 1638400 | ||
188126001 | MHMD. | D | Jan. 5, 2023, 5:32 p.m. | OK | GNU C++17 | TESTS | 30 | 46 | 1638400 | ||
188136707 | Zobio | D | Jan. 5, 2023, 6:47 p.m. | OK | GNU C++17 (64) | TESTS | 30 | 31 | 1638400 | ||
188131074 | Qualified | D | Jan. 5, 2023, 6 p.m. | OK | GNU C++17 (64) | TESTS | 30 | 31 | 4812800 | ||
188161044 | Liam_Evander | D | Jan. 6, 2023, 3:56 a.m. | OK | GNU C++17 (64) | TESTS | 31 | 46 | 1638400 | ||
188155139 | luogu_bot4 | D | Jan. 6, 2023, 2:02 a.m. | OK | GNU C++17 (64) | TESTS | 31 | 46 | 1638400 | ||
188153315 | cbyyx | D | Jan. 6, 2023, 1:11 a.m. | OK | GNU C++17 (64) | TESTS | 31 | 46 | 1638400 | ||
188149420 | Xylenox | D | Jan. 5, 2023, 10:51 p.m. | OK | GNU C++17 (64) | TESTS | 30 | 46 | 1638400 | ||
188141766 | camc | D | Jan. 5, 2023, 7:55 p.m. | OK | GNU C++17 (64) | TESTS | 30 | 46 | 1638400 | ||
188139286 | Xc4l16r3 | D | Jan. 5, 2023, 7:19 p.m. | OK | GNU C++17 (64) | TESTS | 30 | 46 | 1638400 | ||
188138301 | enslaved | D | Jan. 5, 2023, 7:06 p.m. | OK | GNU C++17 (64) | TESTS | 30 | 46 | 1638400 | ||
188167521 | poojan_021102 | D | Jan. 6, 2023, 5:30 a.m. | OK | GNU C++17 (64) | TESTS | 31 | 46 | 1638400 | ||
188132671 | Havoc_01 | D | Jan. 5, 2023, 6:10 p.m. | OK | GNU C++20 (64) | TESTS | 30 | 31 | 819200 | ||
188159029 | TreeQwQ | D | Jan. 6, 2023, 3:19 a.m. | OK | GNU C++20 (64) | TESTS | 31 | 31 | 1638400 | ||
188151477 | go_next | D | Jan. 6, 2023, 12:09 a.m. | OK | GNU C++20 (64) | TESTS | 30 | 31 | 1638400 | ||
188147365 | maximumSHOT | D | Jan. 5, 2023, 9:46 p.m. | OK | GNU C++20 (64) | TESTS | 30 | 31 | 1638400 | ||
188146181 | heon | D | Jan. 5, 2023, 9:15 p.m. | OK | GNU C++20 (64) | TESTS | 30 | 31 | 1638400 | ||
188166488 | munhwas1140 | D | Jan. 6, 2023, 5:17 a.m. | OK | GNU C++20 (64) | TESTS | 31 | 31 | 1638400 | ||
188136366 | unkn0wnB4ain302 | D | Jan. 5, 2023, 6:43 p.m. | OK | GNU C++20 (64) | TESTS | 30 | 31 | 1638400 | ||
188136198 | unkn0wnB4ain302 | D | Jan. 5, 2023, 6:41 p.m. | OK | GNU C++20 (64) | TESTS | 30 | 31 | 1638400 | ||
188127376 | Krishna_Bhakt_Anuj | D | Jan. 5, 2023, 5:38 p.m. | OK | GNU C++20 (64) | TESTS | 30 | 31 | 1638400 | ||
188142043 | Vlaned | D | Jan. 5, 2023, 7:59 p.m. | OK | GNU C++20 (64) | TESTS | 30 | 31 | 1638400 | ||
188128223 | NewbiePupil | D | Jan. 5, 2023, 5:42 p.m. | OK | Java 11 | TESTS | 30 | 218 | 0 | ||
188136450 | Lior | D | Jan. 5, 2023, 6:44 p.m. | OK | Java 11 | TESTS | 30 | 234 | 0 | ||
188167481 | HMETAO | D | Jan. 6, 2023, 5:29 a.m. | OK | Java 11 | TESTS | 31 | 249 | 0 | ||
188133039 | djrfrn | D | Jan. 5, 2023, 6:13 p.m. | OK | Java 11 | TESTS | 30 | 249 | 0 | ||
188129061 | sad_truant | D | Jan. 5, 2023, 5:47 p.m. | OK | Java 11 | TESTS | 30 | 249 | 8806400 | ||
188132024 | serndipty_ | D | Jan. 5, 2023, 6:06 p.m. | OK | Java 11 | TESTS | 30 | 265 | 0 | ||
188128279 | dzhi | D | Jan. 5, 2023, 5:43 p.m. | OK | Java 11 | TESTS | 30 | 280 | 7065600 | ||
188116333 | Yuki_B | D | Jan. 5, 2023, 4:23 p.m. | OK | Java 11 | TESTS | 30 | 639 | 0 | ||
188150849 | pc_invader | D | Jan. 5, 2023, 11:45 p.m. | OK | Java 17 | TESTS | 30 | 218 | 6758400 | ||
188149619 | StacGnihsihp | D | Jan. 5, 2023, 10:57 p.m. | OK | Java 17 | TESTS | 30 | 264 | 409600 | ||
188169085 | cys02 | D | Jan. 6, 2023, 5:47 a.m. | OK | Java 17 | TESTS | 31 | 280 | 2764800 | ||
188135989 | merlin_ | D | Jan. 5, 2023, 6:39 p.m. | OK | Java 17 | TESTS | 30 | 295 | 9830400 | ||
188141423 | ayushdragneel27 | D | Jan. 5, 2023, 7:50 p.m. | OK | Java 17 | TESTS | 30 | 716 | 93696000 | ||
188126322 | NerfThis | D | Jan. 5, 2023, 5:34 p.m. | OK | Java 8 | TESTS | 30 | 140 | 1843200 | ||
188129691 | bruhgamer | D | Jan. 5, 2023, 5:51 p.m. | OK | Java 8 | TESTS | 30 | 140 | 1843200 | ||
188131160 | Mohamed_Ahmed | D | Jan. 5, 2023, 6:01 p.m. | OK | Java 8 | TESTS | 30 | 155 | 2764800 | ||
188129476 | NerfThis | D | Jan. 5, 2023, 5:50 p.m. | OK | Java 8 | TESTS | 30 | 280 | 3686400 | ||
188133273 | Socrates1232 | D | Jan. 5, 2023, 6:15 p.m. | OK | Java 8 | TESTS | 30 | 311 | 0 | ||
188162949 | 2020akadaver | D | Jan. 6, 2023, 4:28 a.m. | OK | Java 8 | TESTS | 31 | 311 | 21913600 | ||
188129994 | pribic | D | Jan. 5, 2023, 5:52 p.m. | OK | Java 8 | TESTS | 30 | 358 | 28569600 | ||
188138546 | fatant | D | Jan. 5, 2023, 7:10 p.m. | OK | MS C++ 2017 | TESTS | 30 | 171 | 3276800 | ||
188126786 | Alexey | D | Jan. 5, 2023, 5:35 p.m. | OK | MS C++ 2017 | TESTS | 30 | 186 | 4096000 | ||
188115268 | K_0_R_D | D | Jan. 5, 2023, 4:21 p.m. | OK | MS C++ 2017 | TESTS | 30 | 187 | 3072000 | ||
188119315 | gavvah | D | Jan. 5, 2023, 4:30 p.m. | OK | MS C++ 2017 | TESTS | 30 | 202 | 8089600 | ||
188121140 | Kita | D | Jan. 5, 2023, 4:33 p.m. | OK | PyPy 3 | TESTS | 30 | 420 | 25907200 | ||
188137125 | SophieHatter | D | Jan. 5, 2023, 6:52 p.m. | OK | PyPy 3-64 | TESTS | 30 | 139 | 25395200 | ||
188140433 | Aravind | D | Jan. 5, 2023, 7:35 p.m. | OK | PyPy 3-64 | TESTS | 30 | 155 | 18022400 | ||
188120186 | eepsilon | D | Jan. 5, 2023, 4:32 p.m. | OK | PyPy 3-64 | TESTS | 30 | 155 | 22630400 | ||
188141402 | Th_K | D | Jan. 5, 2023, 7:49 p.m. | OK | PyPy 3-64 | TESTS | 30 | 171 | 27852800 | ||
188157053 | RobinFromTheHood | D | Jan. 6, 2023, 2:43 a.m. | OK | PyPy 3-64 | TESTS | 31 | 171 | 35225600 | ||
188151483 | ankan2526 | D | Jan. 6, 2023, 12:09 a.m. | OK | PyPy 3-64 | TESTS | 30 | 187 | 154214400 | ||
188139383 | kavorka | D | Jan. 5, 2023, 7:21 p.m. | OK | PyPy 3-64 | TESTS | 30 | 202 | 27443200 | ||
188144294 | iN_siDious | D | Jan. 5, 2023, 8:38 p.m. | OK | PyPy 3-64 | TESTS | 30 | 202 | 38400000 | ||
188153686 | mikeac | D | Jan. 6, 2023, 1:22 a.m. | OK | PyPy 3-64 | TESTS | 31 | 217 | 36454400 | ||
188130014 | jgs03177 | D | Jan. 5, 2023, 5:53 p.m. | OK | PyPy 3-64 | TESTS | 30 | 233 | 26316800 | ||
188144712 | abcsumits | D | Jan. 5, 2023, 8:45 p.m. | OK | Python 3 | TESTS | 30 | 202 | 14233600 | ||
188145735 | klindyuk | D | Jan. 5, 2023, 9:06 p.m. | OK | Python 3 | TESTS | 30 | 218 | 13926400 | ||
188142783 | NotGil | D | Jan. 5, 2023, 8:11 p.m. | OK | Python 3 | TESTS | 30 | 218 | 14233600 | ||
188166394 | HCISY | D | Jan. 6, 2023, 5:16 a.m. | OK | Python 3 | TESTS | 31 | 233 | 14233600 | ||
188160595 | chsv183 | D | Jan. 6, 2023, 3:48 a.m. | OK | Python 3 | TESTS | 31 | 248 | 14233600 | ||
188136748 | a2bailey | D | Jan. 5, 2023, 6:47 p.m. | OK | Python 3 | TESTS | 30 | 295 | 13926400 | ||
188126496 | darshan_prabhu | D | Jan. 5, 2023, 5:34 p.m. | OK | Python 3 | TESTS | 30 | 467 | 14233600 | ||
188135931 | Hi_rvn | D | Jan. 5, 2023, 6:39 p.m. | OK | Python 3 | TESTS | 30 | 670 | 14336000 | ||
188139506 | wmrmr | D | Jan. 5, 2023, 7:22 p.m. | OK | Rust 2021 | TESTS | 30 | 77 | 37683200 | ||
188138766 | wmrmr | D | Jan. 5, 2023, 7:12 p.m. | OK | Rust 2021 | TESTS | 30 | 108 | 45158400 |
Back to search problems