#P11132. 【MX-X5-T4】「GFOI Round 1」epitaxy

    ID: 12355 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>Special JudgeO2优化构造Ad-hoc梦熊比赛

【MX-X5-T4】「GFOI Round 1」epitaxy

Background

Original link: https://oier.team/problems/X5E.


epitaxy - かめりあ

Problem Description

You are given two positive integers n,mn, m.

Define the value of a permutation pp of 1n1 \sim n as the greatest common divisor of the maximum values of all nm+1n - m + 1 consecutive subarrays of length mm.
(By definition, the greatest common divisor of a single number is the number itself.)

Please find a permutation of 1n1 \sim n with the maximum value among all such permutations. If there are multiple, output any one.

This problem will use a custom checker to verify whether the permutation you construct is correct, so outputting any permutation with the maximum value will be accepted.

Input Format

This problem has multiple test cases.

The first line contains a positive integer TT, denoting the number of test cases.

For each test case:

The first line contains two positive integers n,mn, m.

Output Format

For each test case, output one line with nn positive integers, denoting a permutation p1,p2,,pnp_1, p_2, \ldots, p_n that meets the requirement.

This problem will use a custom checker to verify whether the permutation you construct is correct, so outputting any permutation with the maximum value will be accepted.

4
2 2
4 2
7 5
10 3
1 2
1 2 4 3
5 3 6 7 1 2 4
6 3 5 8 1 2 4 10 9 7

Hint

Sample Explanation.

In the first test case, when n=2,m=2n = 2, m = 2, the permutation p=[1,2]p = [1, 2] has the maximum value, which is 22. It can also be proven that when n=2,m=2n = 2, m = 2, there is no permutation with value >2> 2.

In the second test case, when n=4,m=2n = 4, m = 2, the permutation p=[1,2,4,3]p = [1, 2, 4, 3] has the maximum value, which is 22, because the maximum values of all subarrays of length 22 are 2,4,42, 4, 4, whose greatest common divisor is 22. It can also be proven that when n=4,m=2n = 4, m = 2, there is no permutation with value >2> 2.

Constraints.

This problem uses bundled tests and enables subtask dependencies.

Subtask ID nn \le n\sum n \le Special Property Subtask Dependencies Score
11 88 100100 None None 2828
22 10610^6 A 2323
33 B 77
44 None 1,2,31, 2, 3 4242
  • Special Property A: m=2m = 2.
  • Special Property B: m=nm = n.

For all testdata, it holds that 1T1051 \le T \le 10^5, 1m1061 \le m \le 10^6, 2n,n1062 \le n, \sum n \le 10^6, and mnm \le n.

Translated by ChatGPT 5