Submission #7101387


Source Code Expand

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
char xq[550][550];
int i,j,x,y,m,n;
bool dfs(int w,int a,int b)
{
    if(xq[a][b]=='g')
    return true;
    //w,1上2下3左4右
    if(xq[a-1][b]!='#'&&w!=1)
     if(dfs(2,a-1,b))
      return true;
    if(xq[a+1][b]!='#'&&w!=2)
     if(dfs(1,a+1,b))
      return true;
    if(xq[a][b-1]!='#'&&w!=3)
     if(dfs(4,a,b-1))
      return true;
    if(xq[a][b+1]!='#'&&w!=4)
     if(dfs(3,a,b+1))
      return true;
    return false;
}
int main()
{
    memset(xq,'#',sizeof(xq));
    cin>>x>>y;
    for(i=1;i<=x;i++)
    {
    for(j=1;j<=y;j++)
    {
    cin>>xq[i][j];
    if(xq[i][j]=='s')
    m=i;n=j;
    }
    }
    if(dfs(0,m,n))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Submission Info

Submission Time
Task A - 深さ優先探索
User luogu_bot5
Language C++ (GCC 5.4.1)
Score 0
Code Size 778 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:29: error: ‘memset’ was not declared in this scope
     memset(xq,'#',sizeof(xq));
                             ^