#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define loop(n) for(ll i=0 ; i<n ; i++)
#define loop2(n) for(ll j=0 ; j<n ; j++)
#define fr(i,n) for (ll i=0;i<n;i++)
void fast()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int fib(int n)
{
if(n <= 1)
return n;
return fib(n-1) + fib(n-2);
}
long long Fib[]= {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987,
1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811,
514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817,
39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733,
1134903170, 1836311903
};
int gcd(int a, int b)
{
if(b==0)
return a;
return gcd(b, a%b);
}
struct student
{
string name;
int grade1,grade2,grade3,grade4;
int sum;
bool operator <(const student s1)
{
if(abs(sum-s1.sum)>10)
return sum>s1.sum;
else
return name<s1.name;
}
};
/*double binary_searchh(double low,double high,double key)
{
double mid;
for(double i=low; i<maxx; i++)
{
mid=(high+low)/2;
double res=(double)mid*log2(mid);
// cout<<" mid "<<mid<<" res "<<res<<" ";
if(res==key)
{
return mid;
}
else if(res<key)
{
low=mid;
// cout<<" low "<<low<<endl;
}
else
{
high=mid;
//cout<<" high "<<high<<endl;
}
}
*/
int main()
{
fast();
int t,n;
cin>>t;
while(t--)
{
cin>>n;
vector<ll> v(100003),p(100003);
for(int i=1; i<=n; i++){
cin>>v[i];
p[v[i]]=i;
}
int x=n+1;
for(int i=n; i>0; i--)
{
if(p[i]<x)
{
for(int j=p[i];j<x;j++)
{
cout<<v[j]<<" ";
//x=p[i];
}
x=p[i];
}
}
cout<<endl;
}
return 0;
}
405A - Gravity Flip | 499B - Lecture |
709A - Juicer | 1358C - Celex Update |
1466B - Last minute enhancements | 450B - Jzzhu and Sequences |
1582C - Grandma Capa Knits a Scarf | 492A - Vanya and Cubes |
217A - Ice Skating | 270A - Fancy Fence |
181A - Series of Crimes | 1638A - Reverse |
1654C - Alice and the Cake | 369A - Valera and Plates |
1626A - Equidistant Letters | 977D - Divide by three multiply by two |
1654B - Prefix Removals | 1654A - Maximum Cake Tastiness |
1649A - Game | 139A - Petr and Book |
1612A - Distance | 520A - Pangram |
124A - The number of positions | 1041A - Heist |
901A - Hashing Trees | 1283A - Minutes Before the New Year |
1654D - Potion Brewing Class | 1107B - Digital root |
25A - IQ test | 785A - Anton and Polyhedrons |