Suborrays CodeForces - 1391A rat800

A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).

For a positive integer n, we call a permutation p of length n good if the following condition holds for every pair i and j (1≤i≤j≤n) —

(pi OR pi+1 OR … OR pj−1 OR pj)≥j−i+1, where OR denotes the bitwise OR operation.
In other words, a permutation p is good if for every subarray of p, the OR of all elements in it is not less than the number of elements in that subarray.

Given a positive integer n, output any good permutation of length n. We can show that for the given constraints such a permutation always exists.

Input
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤100). Description of the test cases follows.

The first and only line of every test case contains a single integer n (1≤n≤100).

Output
For every test, output any good permutation of length n on a separate line.

Example
Input
3
1
3
7
Output
1
3 1 2
4 3 5 2 7 1 6
Note
For n=3, [3,1,2] is a good permutation. Some of the subarrays a

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值