| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
代码虽然难看 还是想贴贴#include<iostream>
using namespace std;
int main()
{
int t,n,i,j,k,m,l,h,x,q,p[50],f[50],con;
char yy[50]={'0'};
cin>>t;
while(t--)
{
cin>>n;
k=0;m=0;
memset(f,0,sizeof(f));
for(i=0;i<n;i++)
{
cin>>p[i];
l=p[i]-m;
for(j=k;j<k+l;j++)
{
yy[j]='(';
f[j]=1;
}
yy[k+l]=')';
k=k+l+1;
m=p[i];
}
q=strlen(yy);
for(h=1;h<q;h++)
{
con=1;
if(yy[h]==')')
{
for(x=h-1;x>=0;x--)
{
if(yy[x]=='('&&f[x]==1)
{
f[x]=0;
cout<<con<<" ";
break;
}
if(yy[x]=='('&&f[x]==0)
con++;
}
}
}
cout<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator