Codeforces Global Round 23

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
1746 Codeforces Global Round 23 FINISHED False 8100 65978699 Oct. 15, 2022, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 12891 ) C Permutation Operations PROGRAMMING constructive algorithms greedy implementation math

B"You are given a permutation a of size n and you should perform n operations on it. In the i -th operation, you can choose a non-empty suffix of a and increase all of its elements by i . How can we perform the operations to minimize the number of inversions in the final array? Note that you can perform operations on the same suffix any number of times you want. A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. A suffix is several consecutive elements of an array that include the last element of the array. An inversion in an array a is a pair of indices (i, j) such that i > j and a_{i} < a_{j} . 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 a single integer n ( 1 <= n <= 10^5 ) -- the size of the array. The second line contains n distinct integers a_{1}, a_{2}, ... , a_{n} ( 1 <= a_i <= n ), the initial permutation a . It's guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, print n integers x_{1}, x_{2}, ldots, x_{n} ( 1 <= x_{i} <= n for each 1 <= i <= n ) indicating that the i -th operation must be applied to the suffix starting at index x_{i} . If there are multiple answers, print any of them. In the first test case one of the optimal solutions is to increase the whole array on each operation (that is, choose the suffix starting at index 1 ). The final array [11, 12, 13, 14] contains 0 inversions. In the second test case, a will be equal to [2, 4, 3, 5, 6] , [2, 4, 3, 7, 8] , [2, 4, 6, 10, 11] , [2, 8, 10, 14, 15] and [7, 13, 15, 19, 20] after the first, second, third, fo"...

Tutorials

Codeforces Global Round 23 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
176374324 Tdyx C Oct. 15, 2022, 4:41 p.m. OK C# 8 TESTS 60 171 21401600

remove filters

Back to search problems