#include <stdio.h>
int main()
{
int t = 0;
scanf("%d", &t);
while (t--)
{
int n = 0;
scanf("%d", &n);
int nLast = 0;
char aParens[40];
int nIndex = 0;
for (int i = 0; i < n; i++)
{
int nCur = 0;
scanf("%d", &nCur);
for (int j = 0; j < (nCur - nLast); j++)
{
aParens[nIndex++] = 'L';
}
aParens[nIndex++] = 'R';
nLast = nCur;
}
for (int i = 0; i < nIndex; i++)
{
if (aParens[i] == 'R')
{
int nRight = 0;
int nRightSum = 1;
for (int j = i - 1; j >= 0; j--)
{
if (aParens[j] == 'L')
{
if (nRight == 0)
{
break;
}
else
{
nRight--;
}
}
else
{
nRight++;
nRightSum++;
}
}
printf("%d ", nRightSum);
}
}
printf("\n");
}
return 0;
}
POJ 1068
最新推荐文章于 2020-07-28 22:33:41 发布