답안 #28167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28167 2017-07-15T14:00:43 Z 메구스타스뚜구스타스뚜(#1203, cls327) 도시와 비트코인 (FXCUP2_city) C
1 / 1
13 ms 1820 KB
#include <stdio.h>
int map[300][300], visited[300][300], N, M;

void DFS(int x, int y) {
	visited[x][y] = 1;
	if (map[x + 1][y] == 1 && visited[x + 1][y] == 0 && x + 1 <= M)
		DFS(x + 1, y);
	if (map[x][y + 1] == 1 && visited[x][y + 1] == 0 && y + 1 <= N)
		DFS(x, y + 1);
}
int main() {
	int i, j;
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		for (j = 0; j < N; j++)
			scanf("%d", &map[i][j]);
	}
	for (i = 0; i < M; i++) {
		for (j = 0; j < N; j++) {
			if (map[i][j] == 1) visited[i][j] = 0;
			else visited[i][j] = -1;
		}
	}
	DFS(0,0);
	if (visited[M - 1][N - 1] == 1) printf("Yes");
	else printf("No");
	return 0;
}

Compilation message

city.c: In function 'main':
city.c:13:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &M);
  ^
city.c:16:4: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &map[i][j]);
    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1820 KB Output is correct
2 Correct 0 ms 1820 KB Output is correct
3 Correct 0 ms 1820 KB Output is correct
4 Correct 0 ms 1820 KB Output is correct
5 Correct 0 ms 1820 KB Output is correct
6 Correct 0 ms 1820 KB Output is correct
7 Correct 0 ms 1820 KB Output is correct
8 Correct 0 ms 1820 KB Output is correct
9 Correct 0 ms 1820 KB Output is correct
10 Correct 0 ms 1820 KB Output is correct
11 Correct 3 ms 1820 KB Output is correct
12 Correct 3 ms 1820 KB Output is correct
13 Correct 3 ms 1820 KB Output is correct
14 Correct 3 ms 1820 KB Output is correct
15 Correct 3 ms 1820 KB Output is correct
16 Correct 6 ms 1820 KB Output is correct
17 Correct 13 ms 1820 KB Output is correct
18 Correct 9 ms 1820 KB Output is correct
19 Correct 9 ms 1820 KB Output is correct
20 Correct 9 ms 1820 KB Output is correct