"Recursion" Go maze

Source: Internet
Author: User

Maze time: 1000ms memory limit: 10000K Total time: 3000ms

Describe:

Determine if you can reach the exit from the entrance of the maze

Input:

Enter two integers to indicate the number of rows in the maze m and the number of columns N, and then the coordinates of the entry and exit, and the last M-line input maze, where 1 represents the wall, 0 indicates a space between each number has a space.

Output:

If it can be reached, the output is "Yes", otherwise the output "No", the result occupies a row.

Input Sample:

3 3
0 0
2 2
0 0 0
1 1 0
0 1 0

Sample output:

Yes

1#include <stdio.h>2#include <stdlib.h>3 inta[10000][10000],h,l;4 voidSearchintIintj)5 {6     if(a[i][j]==0)7     {8a[i][j]=2;9         if(J-1>=0)TenSearch (i,j-1); One         if(i+1<h) ASearch (i+1, j); -         if(j+1<l) -Search (i,j+1); the         if(I-1>=0) -Search (I-1, j); -     } - } + intMain () - { +scanf"%d%d",&h,&l); A     intI,j,m,n; atscanf"%d%d",&i,&j); -scanf"%d%d",&m,&n); -     intt,b; -      for(t=0; t) -          for(b=0; b<l; b++) -scanf"%d",&a[t][b]); in search (i,j); -     if(a[m][n]==2) toprintf"yes\n"); +     Else -printf"no\n"); the     return 0; *}

"Recursion" Go maze

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.