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

求大神告知,为啥在vc运行结果对,提交之后总是wrong anser

Posted by 2smile22 at 2016-12-10 18:25:56 on Problem 1068
#include<iostream>
#include<string>
using namespace std;

int main()
{
	int n,i,m,x,y,j,num,s[21],a[21];
	cin>>n;
	while(n--!=0)
	{
		
		memset(s,0,sizeof(s));
		memset(a,0,sizeof(a));
		cin>>num;
		for(i=0;i<num;i++)
			cin>>a[i];
		for(i=0;i<num;i++)
		{
		
			s[a[i]+i]=1;
		}

		for(i=0;i<num*2;i++)
		{
			if(s[i]==0)continue;
			x=1;
			y=1;
			for(j=i-1;j>0;j--)
			{
				if(s[j]==1)
				{
					x++;
					y++;
				}
				else
					x--;
				if(x==0)break;
				
			}
		 
			if(i==num*2-1)
				cout<<y<<" "<<endl;
			else
			cout<<y<<" ";

		}

	}

	  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