#Description
中文题目
http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=718&pid=1002
#Algorithm
不知道讲什么东西,然后看Sample Output猜DIS,居然AC了
DIS代码摘自刘汝佳的《算法竞赛入门经典 训练指南》
#Code
#include <iostream>
#include <cstdio>
#include <climits>
using namespace std;
const int MAXN = 100000 + 9;
const int INF = INT_MAX;
int a[MAXN], g[MAXN], d[MAXN], ans[MAXN];
void solve()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
for (int i = 1; i <= n; i++) {
g[i] = INF;
}
for (int i = 0; i < n; i++) {
int k = lower_bound(g + 1, g + n + 1, a[i]) - g;
d[i] = k;
g[k] = a[i];
}
printf("%d", d[0]);
for (int i = 1; i < n; i++) {
printf(" %d", d[i]);
}
printf("\n");
}
int main()
{
// freopen("in.txt", "r", stdin);
int t;
scanf("%d", &t);
while (t--) {
solve();
}
}