A15383 | Permutation Value
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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$ .
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.
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$ .
In the second example, the permutation $[4, 1, 6, 2, 5, 3]$ is one of the possible answers; its value is $2$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted