답안 #9332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9332 2014-09-28T05:37:31 Z jwvg0425 Your life (kriii2_Y) C++
컴파일 오류
0 ms 0 KB
#include<stdint.h>
#include<vector>
#include<queue>

std::vector<int> route[100000];
int length[100000];

int main(void)
{	
	std::queue<int> queue;
	int N, M, x, y,min = -1;

	scanf("%d %d", &N, &M);

	for (int i = 0; i < M; i++)
	{
		scanf("%d %d", &x, &y);
		route[x - 1].push_back(y - 1);
	}
	queue.push(0);

	for (int l = 0;!queue.empty(); l++)
	{
		int size = queue.size();

		for (int i = 0; i < size; i++)
		{
			int n = queue.front();
			queue.pop();

			if (length[n]!=0 && length[n]<l)
			{
				continue;
			}

			length[n] = l;
			if (n == N - 1)
			{
				min = l;
			}

			for (int j = 0; j < route[n].size(); j++)
			{
				queue.push(route[n][j]);
			}
		}
	}
	printf("%d",min);
	return 0;
}

Compilation message

Y.cpp: In function 'int main()':
Y.cpp:13:23: error: 'scanf' was not declared in this scope
Y.cpp:42:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Y.cpp:48:17: error: 'printf' was not declared in this scope