| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求大神帮助。。。 代码错误在哪里,我测试的数据都是正确的,就是不给过。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator