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 wangfeichi at 2012-08-01 17:47:54 on Problem 2488
#include <iostream>
using namespace std;

int visit[10][10];
bool judge;
struct path {int x;int y;};
int next[8][2]={{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}}; 
path result[64];
int Count,num,latin;
void findpath(int i,int j)
{
	if(judge==1) return;
	int p,q;
	visit[i][j]=1;
	result[Count].x=i;
	result[Count].y=j;
	Count++;
	if(Count==num*latin)
	{
		judge=1;
		return;
	}
	for(int a=0;a<8;a++)
	{
		p=i+next[a][0];
		q=j+next[a][1];
		if(p<latin && p>=0 && q>=0 && q<num)
			if(visit[p][q]==0) findpath(p,q);
	}
	return;
}
int main()
{
	int n;
	int a,b,c=1,d;
	cin>>n;
	while(c<=n)
	{
		Count=0;
		judge=0;
	    for(a=0;a<10;a++)
		    for(b=0;b<10;b++)
		    	visit[a][b]=0;
		cin>>num>>latin;
		if(num*latin>26 || num*latin<1) continue;
		findpath(0,0);
		cout<<"Scenario #"<<c<<":"<<endl;
		if(Count<num*latin) cout<<"impossible";
		else for(d=0;d<Count;d++) cout<<char('A'+result[d].x)<<result[d].y+1;
		cout<<endl<<endl;
		c++;
	}
	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