Submission #7473468


Source Code Expand

#include <iostream>
using namespace std;

int book[100][100],n,m,flag;
char a[1000][1000];

void dfs(int x,int y)
{
	int tx,ty;
	int s[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
	if(a[x][y]=='g')
	   {
	   	cout<<"Yes"<<endl;
	   	flag=1;
	   	return;
	   }
	  
	   for(int k=0;k<4;k++)
	   {
	   	 tx=x+s[k][0];
	   	 ty=y+s[k][1];
	   	 if(tx<1||tx>n||ty<1||ty>m)
	   	      continue;
	   	 if(a[tx][ty]!='#'&&book[tx][ty]==0)
	   	 {
	   	 	book[tx][ty]=1;
	   	 	dfs(tx,ty);
		 }
	    }
	    return ;	    
 } 
 int main()
 {
 	int i,j,startx,starty;
 	scanf("%d%d",&n,&m);
 	for(i=0;i<n;i++)
 	scanf("%s",a[i]);
 	a[startx][starty]='s';
 	dfs(startx,starty);
 	book[startx][starty]=1;
 	if(flag==1)
 	cout<<"Yes"<<endl;
 	else
 	cout<<"No"<<endl;
 	return 0;
 }

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:21: error: ‘scanf’ was not declared in this scope
   scanf("%d%d",&n,&m);
                     ^