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

帮忙看看 为什么在用注释掉的 就错 用没注释掉的就ac了

Posted by fanhuafeng1314 at 2009-04-12 12:10:18 on Problem 2488
附代码:
#include<iostream>
using namespace std;
//int x[]={-2,-2,-1,-1,1,1,2,2};
//int y[]={-1,1,-2,2,-2,2,-1,1};
int x[]={-1,1,-2,2,-2,2,-1,1};
int y[]={-2,-2,-1,-1,1,1,2,2};
int chess[30][30];
int hang,lie,biaozhi;
int L[300],H[300];  //H 是 字母
int k;
void dfs(int h,int l)
{
	int i,hh,ll;
	if(k == hang*lie)
	{
		biaozhi = 1;
		for(i = 1; i <= k ; i ++)
		printf("%c%d",H[i]+'A'-1,L[i]);
		printf("\n");
		return ;
	}
	
	for(i = 0; i <= 7; i ++)
	{
		ll = l + x[i];
		hh = h + y[i];
		if(ll > 0 && ll <= lie && hh > 0 && hh <= hang && chess[hh][ll] == 0)
		{  
			chess[hh][ll] = 1;k++;H[k] = hh;  L[k] =ll;
			dfs(hh,ll);
			chess[hh][ll] = 0; k--;
		}
		if(biaozhi == 1)
			break ;
	}
	if(biaozhi == 1)  return ;
}
int main()
{
	int n,cas;
	int i,j;
	cin>>n;
	for(cas = 1; cas <= n; cas ++)
	{
       cin>>lie>>hang;  biaozhi = 0;
	   printf("Scenario #%d:\n",cas);
			   memset(chess,0,sizeof(chess));
			   k = 1;  chess[1][1] = 1;  H[1] = 1;  L[1] =1;
			   dfs(1,1);
	   if(biaozhi == 0)  printf("impossible\n");
	   printf("\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