#include<stdio.h>
int main()
{
int a[25],b[50],c[25];
int i,j,n,m,k,count,p,t,flog;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
{
scanf("%d",&m);
for(j=0;j<m*2;j++)
b[j]=0;
for(j=0;j<m;j++)
{
scanf("%d",&a[j]);
b[a[j]+j]=2;
}
for(j=0;j<2*m;j++)
if(b[j]!=2)
b[j]=1;
count=0;
for(j=0;j<2*m;j++)
{
if(b[j]==2)
{
flog=1;
t=0;
for(k=j-1;k>=0;k--)
{
if(b[k]==0)
t++;
if(b[k]==1&&flog==1)
{
c[count]=j-k-t;
count++;
p=k;
flog=0;
}
}
b[p]=0;
}
}
printf("%d",c[0]);
for(k=1;k<m;k++)
printf(" %d",c[k]);
printf("\n");
}
}
return 0;
}
zoj 1016
最新推荐文章于 2020-08-25 00:34:49 发布