답안 #28094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28094 2017-07-15T10:31:42 Z 외않된데?(#1196, solarmagic) 도시와 비트코인 (FXCUP2_city) C++14
0 / 1
296 ms 65536 KB
#include <cstdio>
#include <queue>
using namespace std;
typedef pair<int, int> p;
// city[y][x]; N==x�� ����, M==y�� ����
int city[333][333];
int main()
{
	int N, M;
	scanf("%d %d", &N, &M);
	for (int i = 1; i <= M; ++i)
	{
		for (int j = 1; j <= N; ++j)
		{
			scanf("%d", &city[i][j]);
		}
	}
	queue<p> q;
	q.push(p(1, 1));
	while (!q.empty())
	{
		p n = q.front();
		q.pop();
		if (n.first == M && n.second == N)
		{
			printf("Yes");
			return 0;
		}
		
		if (n.first + 1 <= M && city[n.first + 1][n.second] == 1)
			q.push(p(n.first + 1, n.second));
		if (n.second + 1 <= N && city[n.first][n.second + 1] == 1)
			q.push(p(n.first, n.second + 1));
	}
	printf("No");
	return 0;
}

Compilation message

city.cpp: In function 'int main()':
city.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &M);
                        ^
city.cpp:15:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &city[i][j]);
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2364 KB Output is correct
2 Correct 0 ms 2364 KB Output is correct
3 Correct 0 ms 2364 KB Output is correct
4 Memory limit exceeded 296 ms 65536 KB Memory limit exceeded
5 Halted 0 ms 0 KB -