Codeforces Round 868 (Div. 2)

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
1823 Codeforces Round 868 (Div. 2) FINISHED False 7200 49217099 April 27, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 16127 ) B Sort with Step PROGRAMMING brute force math sortings

B"Let's define a permutation of length n as an array p of length n , which contains every number from 1 to n exactly once. You are given a permutation p_1, p_2, ... , p_n and a number k . You need to sort this permutation in the ascending order. In order to do it, you can repeat the following operation any number of times (possibly, zero): Unfortunately, some permutations can't be sorted with some fixed numbers k . For example, it's impossible to sort [2, 4, 3, 1] with k = 2 . That's why, before starting the sorting, you can make at most one preliminary exchange: Your task is to: For example, if k = 2 and permutation is [2, 4, 3, 1] , then you can make a preliminary exchange of p_1 and p_4 , which will produce permutation [1, 4, 3, 2] , which is possible to sort with given k . Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^4 ). The description of the test cases follows. The first line of each test case contains two integers n and k ( 2 <= n <= 2 cdot 10^5 ; 1 <= k <= n - 1 ) -- length of the permutation, and a distance between elements that can be swapped. The second line of each test case contains n integers p_1, p_2, ... , p_n ( 1 <= p_i <= n ) -- 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 print In the first test case, there is no need in preliminary exchange, as it is possible to swap (p_1, p_2) and then (p_2, p_3) . In the second test case, there is no need in preliminary exchange, as it is possible to swap (p_1, p_3) and then (p_2, p_4) . In the third test case, you need to apply preliminary exchange to (p_2, p_3) . After that the permutation becomes [3, 4, 1, 2] and can be sorted with k = 2 . "...

Tutorials

115465

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
203701184 Alfafox B April 27, 2023, 3:40 p.m. OK C# 10 TESTS 8 171 12800000
203756816 bluemegane B April 28, 2023, 2:32 a.m. OK C# 8 TESTS 8 155 16384000
203761940 Nabil71-dev B April 28, 2023, 4:22 a.m. OK Clang++17 Diagnostics TESTS 8 795 19968000
203765757 wryaidyd B April 28, 2023, 5:32 a.m. OK Clang++17 Diagnostics TESTS 8 982 11571200
203760889 harshkumarrai98 B April 28, 2023, 4:07 a.m. OK Clang++20 Diagnostics TESTS 8 966 19968000
203709505 m4k1sama B April 27, 2023, 4:10 p.m. OK GNU C++14 TESTS 8 31 819200
203717461 tarek200 B April 27, 2023, 4:55 p.m. OK GNU C++14 TESTS 8 46 0
203762840 tothanhdat1421 B April 28, 2023, 4:38 a.m. OK GNU C++14 TESTS 8 46 819200
203723142 trion_leninster B April 27, 2023, 5:42 p.m. OK GNU C++14 TESTS 8 46 819200
203717544 spybit B April 27, 2023, 4:55 p.m. OK GNU C++14 TESTS 8 46 819200
203709341 coks B April 27, 2023, 4:10 p.m. OK GNU C++14 TESTS 8 46 819200
203708527 kartikC03 B April 27, 2023, 4:07 p.m. OK GNU C++14 TESTS 8 46 819200
203708505 bamproIO B April 27, 2023, 4:07 p.m. OK GNU C++14 TESTS 8 46 819200
203707359 xish B April 27, 2023, 4:02 p.m. OK GNU C++14 TESTS 8 46 819200
203705992 kuldeepkushwaha B April 27, 2023, 3:57 p.m. OK GNU C++14 TESTS 8 46 819200

remove filters

Back to search problems