Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

谁来帮帮我,为什么WA?

Posted by 0912240010 at 2010-02-13 15:52:36 on Problem 2182 and last updated at 2010-02-13 16:06:41
#include<stdio.h>
int main()
{int a[8001],b[8001],c[8001],n,i,j;
 scanf("%d",&n);
 for(i=1;i<=n;i++)
   c[i]=i;
 for(i=2;i<=n;i++)
  scanf("%d",&a[i]);
  b[n]=a[n]+1;
 for(i=n-1;i>=2;i--)
  {
   b[i]=a[i]+1;
   for(j=n;j>i;j--)
    {if(b[j]<=b[i])
     b[i]+=1;
    }
  }
 for(i=1;i<=n;i++)
	for(j=2;j<=n;j++)
		if(b[j]==i)
                 c[i]=0;
 for(i=1;i<=n;i++)
	if(c[i]!=0)
          b[1]=c[i];
 for(i=1;i<=n;i++)
  printf("%d\n",b[i]);
 return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator