309839: CF1743B. Permutation Value

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Permutation Value

题意翻译

给定一个 $n$,需要构造一个长度为 $n$ 的数列,使得数列中所有子段中有特殊性质的子段数量最小。 特殊性质:设子段长度为 $k$,则该子段需包含 $1\sim k$ 的所有数。

题目描述

You are given an integer $ n $ . You have to construct a permutation of size $ n $ . A permutation is an array where each integer from $ 1 $ to $ s $ (where $ s $ is the size of permutation) occurs exactly once. For example, $ [2, 1, 4, 3] $ is a permutation of size $ 4 $ ; $ [1, 2, 4, 5, 3] $ is a permutation of size $ 5 $ ; $ [1, 4, 3] $ is not a permutation (the integer $ 2 $ is absent), $ [2, 1, 3, 1] $ is not a permutation (the integer $ 1 $ appears twice). A subsegment of a permutation is a contiguous subsequence of that permutation. For example, the permutation $ [2, 1, 4, 3] $ has $ 10 $ subsegments: $ [2] $ , $ [2, 1] $ , $ [2, 1, 4] $ , $ [2, 1, 4, 3] $ , $ [1] $ , $ [1, 4] $ , $ [1, 4, 3] $ , $ [4] $ , $ [4, 3] $ and $ [3] $ . The value of the permutation is the number of its subsegments which are also permutations. For example, the value of $ [2, 1, 4, 3] $ is $ 3 $ since the subsegments $ [2, 1] $ , $ [1] $ and $ [2, 1, 4, 3] $ are permutations. You have to construct a permutation of size $ n $ with minimum possible value among all permutations of size $ n $ .

输入输出格式

输入格式


The first line contains one integer $ t $ ( $ 1 \le t \le 48 $ ) — the number of test cases. Then, $ t $ lines follow. The $ i $ -th of them contains one integer $ n $ ( $ 3 \le n \le 50 $ ) representing the $ i $ -th test case.

输出格式


For each test case, print $ n $ integers — the permutation of size $ n $ with minimum possible value. If there are multiple such permutations, print any of them.

输入输出样例

输入样例 #1

2
5
6

输出样例 #1

1 4 3 5 2
4 1 6 2 5 3

说明

In the first example, the permutation $ [1, 4, 3, 5, 2] $ is one of the possible answers; its value is $ 2 $ . In the second example, the permutation $ [4, 1, 6, 2, 5, 3] $ is one of the possible answers; its value is $ 2 $ .

Input

题意翻译

给定一个 $n$,需要构造一个长度为 $n$ 的数列,使得数列中所有子段中有特殊性质的子段数量最小。 特殊性质:设子段长度为 $k$,则该子段需包含 $1\sim k$ 的所有数。

Output

**排列值**

**题意翻译**
给定一个 $ n $,需要构造一个长度为 $ n $ 的数列,使得数列中所有子段中有特殊性质的子段数量最小。

特殊性质:设子段长度为 $ k $,则该子段需包含 $ 1\sim k $ 的所有数。

**题目描述**
给定一个整数 $ n $。你需要构造一个大小为 $ n $ 的排列。

排列是一个数组,其中每个整数从 $ 1 $ 到 $ s $(其中 $ s $ 是排列的大小)恰好出现一次。例如,$ [2, 1, 4, 3] $ 是一个大小为 $ 4 $ 的排列;$ [1, 2, 4, 5, 3] $ 是一个大小为 $ 5 $ 的排列;$ [1, 4, 3] $ 不是一个排列(整数 $ 2 $ 缺失),$ [2, 1, 3, 1] $ 不是一个排列(整数 $ 1 $ 出现两次)。

排列的子段是排列的连续子序列。例如,排列 $ [2, 1, 4, 3] $ 有 $ 10 $ 个子段:$ [2] $,$ [2, 1] $,$ [2, 1, 4] $,$ [2, 1, 4, 3] $,$ [1] $,$ [1, 4] $,$ [1, 4, 3] $,$ [4] $,$ [4, 3] $ 和 $ [3] $。

排列的值是它的子段中也是排列的子段的数量。例如,$ [2, 1, 4, 3] $ 的值是 $ 3 $,因为子段 $ [2, 1] $,$ [1] $ 和 $ [2, 1, 4, 3] $ 是排列。

你需要构造一个大小为 $ n $ 的排列,其值在所有大小为 $ n $ 的排列中可能的最小。


**输入输出格式**

**输入格式**
第一行包含一个整数 $ t $($ 1 \le t \le 48 $)——测试用例的数量。

然后,有 $ t $ 行。第 $ i $ 行包含一个整数 $ n $($ 3 \le n \le 50 $)表示第 $ i $ 个测试用例。

**输出格式**
对于每个测试用例,打印 $ n $ 个整数——大小为 $ n $ 的排列,其值在所有大小为 $ n $ 的排列中可能的最小。如果有多个这样的排列,请打印其中任何一个。

**输入输出样例**

**输入样例 #1**
```
2
5
6
```
**输出样例 #1**
```
1 4 3 5 2
4 1 6 2 5 3
```

**说明**
在第一个例子中,排列 $ [1, 4, 3, 5, 2] $ 是可能答案之一;它的值是 $ 2 $。

在第二个例子中,排列 $ [4, 1, 6, 2, 5, 3] $ 是可能答案之一;它的值是 $ 2 $。**排列值** **题意翻译** 给定一个 $ n $,需要构造一个长度为 $ n $ 的数列,使得数列中所有子段中有特殊性质的子段数量最小。 特殊性质:设子段长度为 $ k $,则该子段需包含 $ 1\sim k $ 的所有数。 **题目描述** 给定一个整数 $ n $。你需要构造一个大小为 $ n $ 的排列。 排列是一个数组,其中每个整数从 $ 1 $ 到 $ s $(其中 $ s $ 是排列的大小)恰好出现一次。例如,$ [2, 1, 4, 3] $ 是一个大小为 $ 4 $ 的排列;$ [1, 2, 4, 5, 3] $ 是一个大小为 $ 5 $ 的排列;$ [1, 4, 3] $ 不是一个排列(整数 $ 2 $ 缺失),$ [2, 1, 3, 1] $ 不是一个排列(整数 $ 1 $ 出现两次)。 排列的子段是排列的连续子序列。例如,排列 $ [2, 1, 4, 3] $ 有 $ 10 $ 个子段:$ [2] $,$ [2, 1] $,$ [2, 1, 4] $,$ [2, 1, 4, 3] $,$ [1] $,$ [1, 4] $,$ [1, 4, 3] $,$ [4] $,$ [4, 3] $ 和 $ [3] $。 排列的值是它的子段中也是排列的子段的数量。例如,$ [2, 1, 4, 3] $ 的值是 $ 3 $,因为子段 $ [2, 1] $,$ [1] $ 和 $ [2, 1, 4, 3] $ 是排列。 你需要构造一个大小为 $ n $ 的排列,其值在所有大小为 $ n $ 的排列中可能的最小。 **输入输出格式** **输入格式** 第一行包含一个整数 $ t $($ 1 \le t \le 48 $)——测试用例的数量。 然后,有 $ t $ 行。第 $ i $ 行包含一个整数 $ n $($ 3 \le n \le 50 $)表示第 $ i $ 个测试用例。 **输出格式** 对于每个测试用例,打印 $ n $ 个整数——大小为 $ n $ 的排列,其值在所有大小为 $ n $ 的排列中可能的最小。如果有多个这样的排列,请打印其中任何一个。 **输入输出样例** **输入样例 #1** ``` 2 5 6 ``` **输出样例 #1** ``` 1 4 3 5 2 4 1 6 2 5 3 ``` **说明** 在第一个例子中,排列 $ [1, 4, 3, 5, 2] $ 是可能答案之一;它的值是 $ 2 $。 在第二个例子中,排列 $ [4, 1, 6, 2, 5, 3] $ 是可能答案之一;它的值是 $ 2 $。

加入题单

算法标签: