#include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define pb push_back #define mkp make_pair #define fi first #define se second #define FOR(i, l, r) for(int i = l; i <= r; i++) #define ROF(i, r, l) for(int i = r; i >= l; i--) #define all(a) a.begin(), a.end() inline int ckmax(int &a, int b) { return a < b ? a = b, 1 : 0; } inline int ckmin(int &a, int b) { return a > b ? a = b, 1 : 0; } int T, n, a[100100], f[100100], top, sta[100100]; int main(){ #ifndef ONLINE_JUDGE freopen("x.in", "r", stdin); freopen("x.out", "w", stdout); #endif scanf("%d", &T); while(T--){ scanf("%d", &n); top = 0; for(int i = 1; i <= n; ++i){ scanf("%d", a + i); if(!top || a[i] > sta[top]){ sta[++top] = a[i]; f[i] = top; } int t = lower_bound(sta + 1, sta + top + 1, a[i]) - sta; f[i] = t; sta[t] = a[i]; printf("%d", f[i]); if(i < n) printf(" "); } printf("\n"); } return 0; } /* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||// \ / _||||| -:- |||||- \ | | \\\ - /// | | | \_| ''\---/'' | | \ .-\__ `-` ___/-. / ___`. .' /--.--\ `. . __ ."" '< `.___\_<|>_/___.' >'"". | | : `- \`.;`\ _ /`;.`/ - ` : | | \ \ `-. \_ __\ /__ _/ .-` / / ======`-.____`-.___\_____/___.-`____.-'====== `=---=' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 佛祖保佑 永无BUG */