"Codevs1215" Maze

Source: Internet
Author: User

Description

Inside the maze of N*n, "#" is the Wall, "." For the road, "s" for the beginning, "E" for the end, altogether 4 directions can walk. From the upper left corner ((0,0) "s" position to the lower right corner ((n-1,n-1) "E") position, you can walk the general output Yes, can not go output no.

Input

The first behavior of the input is an integer m, which indicates the number of mazes.
The first behavior of each maze data followed by an integer n (n≤16), representing the edge length of the maze, followed by n lines of n characters per line, with no spaces separating the characters.

Output

Output has m line, each line corresponding to the maze can go, then output yes, otherwise output No.

Sample Input








... E
Sample Output
YES
Exercises
#include <iostream>using namespacestd;Chara[ -][ -];BOOLvis[ -][ -];intxx[5]={0,-1,1,0,0};intyy[5]={0,0,0,-1,1};intM,n,judge;voidDfsintXinty) {Vis[x][y]=true; if(A[x][y] = ='e') {Judge=1; return; }     for(intI=1; i<=4; i++)        if(x+xx[i]>0&& x+xx[i]<=n && y+yy[i]>0&& y+yy[i]<=N)if(A[x+xx[i]][y+yy[i]]! ='#'&&!vis[x+xx[i]][y+Yy[i]]) DFS (x+xx[i],y+yy[i]);}intMain () {CIN>>m>>N;  for(intI=1; i<=m;i++) {Judge=0;  for(intj=1; j<=n;j++)             for(intk=1; k<=n;k++) Cin>>A[j][k]; DFS (1,1); if(judge) cout<<"YES"; Elsecout<<"NO"; }    return 0;}

"Codevs1215" Maze

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.