답안 #28089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28089 2017-07-15T10:25:37 Z aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(#1199, suhgyuho_william) 도시와 비트코인 (FXCUP2_city) C++14
0 / 1
0 ms 2464 KB
#include <bits/stdc++.h>

using namespace std;

int N,M;
int a[302][302];
bool check[302][302];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void dfs(int x,int y){
	check[x][y] = true;
	for(int i=0; i<4; i++){
		if(a[x+dx[i]][y+dy[i]] == 0 || check[x+dx[i]][y+dy[i]]) continue;
		dfs(x+dx[i],y+dy[i]);
	}
}

int main(){
	scanf("%d %d",&M,&N);
	for(int i=1; i<=N; i++){
		for(int j=1; j<=M; j++){
			scanf("%d",&a[i][j]);
		}
	}
	dfs(1,1);
	printf("%s\n",check[N][M]?"YES":"NO");

	return 0;
}

Compilation message

city.cpp: In function 'int main()':
city.cpp:20:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&M,&N);
                      ^
city.cpp:23:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&a[i][j]);
                        ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2464 KB Output isn't correct
2 Halted 0 ms 0 KB -