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
北京大学《ACM-ICPC竞赛训练》暑期课面向全球招生。容量有限,报名从速!

WA炸 求解 代码凌乱勿喷

Posted by hanyuweining at 2017-05-18 13:38:55 on Problem 1059
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

int go[101],n,pawn[7];
bool missa[101],extra[101];
int a[1001],win,set[7];

void play()
{
	int i,j;
	i=-1;
	set[1]=set[2]=set[3]=set[4]=set[5]=set[6]=1;
	while(win==0)
	{
		for(j=1;j<=n;j++)
		{
			if(set[j]!=0)
			{
				if(pawn[j]+a[i+j]<=100)
				{
					pawn[j]+=a[i+j];	
				}
				if(pawn[j]==100)
				{
					win=j;
					return;
				}
				pawn[j]=go[pawn[j]];
				if(pawn[j]==100)
				{
					win=j;
					return;
				}
				
			}
			else
			{
				set[j]=1;
				continue;
			}
			
			if(set[j]==2)
			{
				i++;
				if(pawn[j]+a[i+j]<=100)
				{
					pawn[j]+=a[i+j];	
				}
				if(pawn[j]==100)
				{
					win=j;
					return;
				}
				pawn[j]=go[pawn[j]];
				if(pawn[j]==100)
				{
					win=j;
					return;
				}
				set[j]=1;
			}
		
			if(missa[pawn[j]]==true)
				set[j]=0;
			else if(extra[pawn[j]]==true)
				set[j]=2;
		}
		i+=n;
	}
}

int main()
{
	int p;
	p=0;
	scanf("%d",&a[p]);
	while(a[p]!=0)
	{
		p++;
		scanf("%d",&a[p]);
	}
	p++;
	
	scanf("%d",&n);
	while(n!=0)
	{
		int i;
		for(i=0;i<=100;i++)
		{
			go[i]=i;
		}
		scanf("%d",&i);
		scanf("%d",&go[i]);
		while(i!=0||go[i]!=0)
		{
			scanf("%d",&i);
			scanf("%d",&go[i]);
		}
		int b;
		scanf("%d",&b);
		while(b!=0)
		{
			if(b<0)
			{
				missa[-b]=true;
			}
			else
			{
				extra[b]=true;
			}
			scanf("%d",&b);
		}
		win=0;
		play();
		printf("%d\n",win);
		memset(missa,0,sizeof(missa));
		memset(extra,0,sizeof(extra));
		scanf("%d",&n);
	}
	
	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