| 记录编号 | 
        136630 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        1105.走迷宫 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         RP++ | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.007 s  | 
    
    
        | 提交时间 | 
        2014-11-03 14:08:29 | 
        内存使用 | 
        0.32 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<iostream>
#include<cstdio>
using namespace std;
int h,l;
int num[20][20];
bool flag[20][20]={false};
int sx,sy;
int tx,ty;
int a[]={0,-1,0,0,1};
int b[]={0,0,-1,1,0};
int nWay[20][20]={false};
bool bj=false;
void print()
{
	bj=true;
	int x=sx,y=sy;
	while(x!=tx||y!=ty)
	{
		printf("(%d,%d)->",x,y);
		int tmp=x;
		x+=a[nWay[x][y]];
		y+=b[nWay[tmp][y]];
	}
	printf("(%d,%d)\n",x,y);
}
void dfs(int x,int y)
{
	if(x==tx&&y==ty)
	{
		print();
		return ;
	}
	for(int i=1;i<=4;i++)
	{
		int s=x+a[i],t=y+b[i];
		if(flag[s][t]||!num[s][t]||s<1||s>h||t<1||t>l)continue;
		flag[s][t]=true;
		nWay[x][y]=i;
		dfs(s,t);
		flag[s][t]=false;
		nWay[x][y]=0;
	}
}
int main()
{
	freopen("maize.in","r",stdin);
	freopen("maize.out","w",stdout);
	scanf("%d%d",&h,&l);
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=l;j++)
		{
			scanf("%d",&num[i][j]);
		}
	}
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	flag[sx][sy]=true;
	dfs(sx,sy);
	if(!bj)printf("-1");
}