Codeforces Round 1020 (Div. 3)

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
2106 Codeforces Round 1020 (Div. 3) FINISHED False 8100 30900323 April 24, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 28287 ) B St. Chroma PROGRAMMING constructive algorithms greedy math

Given a permutation(^{\text{∗}}) (p) of length (n) that contains every integer from (0) to (n-1) and a strip of (n) cells, St. Chroma will paint the (i)-th cell of the strip in the color (\operatorname{MEX}(p_1, p_2, ..., p_i))(^{\text{†}}). For example, suppose (p = 1, 0, 3, 2). Then, St. Chroma will paint the cells of the strip in the following way: (0, 2, 2, 4). You have been given two integers (n) and (x). Because St. Chroma loves color (x), construct a permutation (p) such that the number of cells in the strip that are painted color (x) is maximized . (^{\text{∗}})A permutation of length (n) is a sequence of (n) elements that contains every integer from (0) to (n-1) exactly once. For example, (0, 3, 1, 2) is a permutation, but (1, 2, 0, 1) isn't since (1) appears twice, and (1, 3, 2) isn't since (0) does not appear at all. (^{\text{†}})The (\operatorname{MEX}) of a sequence is defined as the first non-negative integer that does not appear in it. For example, (\operatorname{MEX}(1, 3, 0, 2) = 4), and (\operatorname{MEX}(3, 1, 2) = 0). The first line of the input contains a single integer (t) ((1 \le t \le 4000)) — the number of test cases. The only line of each test case contains two integers (n) and (x) ((1 \le n \le 2 \cdot 10^5), (0 \le x \le n)) — the number of cells and the color you want to maximize. It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). Output a permutation (p) of length (n) such that the number of cells in the strip that are painted color (x) is maximized . If there exist multiple such permutations, output any of them. The first example is explained in the statement. It can be shown that (2) is the maximum amount of cells that can be painted in color (2). Note that another correct answer would be the permutation $$$

Tutorials

Codeforces Round 1020 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
317085687 A1ternate B April 24, 2025, 5:40 p.m. OK C# 10 TESTS 5 108 14131200
317072063 Shortyoo B April 24, 2025, 4:39 p.m. OK C# 10 TESTS 5 312 3891200
317106971 coder_143 B April 24, 2025, 9:22 p.m. OK C++17 (GCC 7-32) TESTS 5 46 0
317131402 -Araby B April 25, 2025, 5:20 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317130503 npmduyy B April 25, 2025, 5:12 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317130382 poj45 B April 25, 2025, 5:10 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317129491 JhdFarrell B April 25, 2025, 4:57 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317126801 wiise B April 25, 2025, 4:14 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317126312 Neel_Shah12 B April 25, 2025, 4:05 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317126144 out_of_the_Circle B April 25, 2025, 4:02 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317133494 ShouryaBhale2703 B April 25, 2025, 5:50 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317133483 Tenacious. B April 25, 2025, 5:50 a.m. OK C++17 (GCC 7-32) TESTS 5 61 0
317115928 bluemegane B April 25, 2025, 12:31 a.m. OK C# 8 TESTS 5 124 12492800

remove filters

Back to search problems