답안 #28198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28198 2017-07-15T14:55:42 Z lyzqm123(#1224, lyzqm123) 도시와 비트코인 (FXCUP2_city) C++
1 / 1
9 ms 2640 KB
#include <cstdio>
#include <queue>
using namespace std;
int N, M;
int map[301][301];
int go[301][301];
int main() {
	scanf("%d%d", &M, &N);
	for (int n = 0;n < N;n++)
		for (int m = 0;m < M;m++)
			scanf("%d", &map[n][m]);
	go[0][0] = 1;
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int y = q.front() / M, x = q.front() % M;
		q.pop();

		if (y + 1 < N && map[y + 1][x] && !go[y + 1][x]) {
			go[y + 1][x] = 1;
			q.push((y + 1)*M + x);
		}
		if (x + 1 < M && map[y][x + 1] && !go[y][x + 1]) {
			go[y][x + 1] = 1;
			q.push(y*M + x + 1);
		}
	}
	if (go[N - 1][M - 1])
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Compilation message

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