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

大牛们,救救我吧

Posted by vortex101 at 2009-02-27 20:46:32 on Problem 2488
#include<iostream>
using namespace std;

char qs[30]={0};
char o[1001]={0};
int d[1001]={0};
int v[50][50]={0};
int p,q;
int pt,dt;

void init()
{
	int i;
	for(i=0;i<27;i++)
	{
		qs[i]='A'+i;
	}
	pt=0;
	dt=0;
	o[pt]='\0';
}

void clearv()
{
	int i,j;
	for(i=0;i<27;i++)
		for(j=0;j<27;j++)
			v[i][j]=0;
	pt=0;
	dt=0;
	o[pt]='\0';
}

int isover()
{
	int i,j;
	for(i=0;i<p;i++)
		for(j=0;j<q;j++)
		{
			if(!v[i][j])
				return 0;
		}
	return 1;
}

void geta(int x,int y)
{
	if(x<0||y<0||x>p-1||y>q-1)
		return ;
	else
	{
		if(!v[x][y])
		{
			v[x][y]=1;
			o[pt++]=qs[y];
			d[dt++]=x+1;
			geta(x-1,y-2);
			geta(x+1,y-2);
			geta(x-2,y-1);
			geta(x+2,y-1);
			geta(x-2,y+1);
			geta(x+2,y+1);
			geta(x-1,y+2);
			geta(x+1,y+2);
		}
	}
}

int main()
{
	int n;
	cin>>n;
//	while(cin>>n)
	{
		int i;
		init();
		for(i=1;i<=n;i++)
		{
			cin>>p>>q;
			clearv();
			geta(0,0);
			o[pt++]='\0';
			cout<<"Scenario #"<<i<<":"<<endl;
			if(isover())
			{
				int	l;
				for(l=0;l<pt-1;l++)
				{
					printf("%c%d",o[l],d[l]);
				}
				printf("\n");
			}
			else
				cout<<"impossible"<<endl;
			cout<<endl;
		}
	}
	return 0;
}

到底错哪了?
WA了N次了

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