STL技巧构造
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<sstream>//切割strtream头文件
#include<climits>//INT_MAX文件
#include <utility>
using i64 = int64_t;
using namespace std;
#define int i64
#define endl '\n'
#define AC return 0;
#define WA(x) cout << x << endl;
const int maxn = 1e6 + 10;
int n, m, k, d, T = 1, A, B;
int a[maxn];
template<typename T>void read(T &x) {
T f = 1;x = 0;char s = getchar();
while(s < '0' || s > '9') {if(s == '-')f = -1;s = getchar();}
while(s >= '0' && s <= '9') {x = x * 10 + s - '0';s = getchar();}
x *= f;
}
template<typename T>void print(T x) {
if(x < 0) putchar('-'),x = -x;
if(x > 9) print(x / 10);
putchar(x % 10 + '0');
putchar('\n');
}
/*
根据样例
每次从左往右截取最长的0子段,其中l = 子段头, r = 子段尾
r − l + 1 是奇数 a[l + r / 2] = i;else a[l + r - 1 / 2] = i;
*/
class node
{
public:
int l, r, len;
node(int a,int b,int c) : l(a), r(b), len(c) {};
bool operator < (const node& n)const
{
return n.len == this -> len ? l > n.l : len < n.len;
}
};
void solve()
{
priority_queue<node>Q;
read(n);
Q.emplace(1, n ,n);
for(int i = 1;i <= n;i++)
{
auto x = Q.top();Q.pop();
int pos = (x.l + x.r - 1 + ((x.len) & 1)) / 2;
a[pos] = i;
if(pos != x.l)Q.emplace(x.l,pos - 1,pos - x.l);
if(pos != x.r)Q.emplace(pos + 1,x.r,x.r - pos);
}
for(int i = 1;i <= n;i++)
cout << a[i] << (i == n ? '\n' : ' ');
}
signed main() {
cin.tie(0) -> sync_with_stdio(false);
int T = 1;
read(T);
while (T--) solve();
return 0;
}