Submission #1463086


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define MAX_N 200000
#define INF 2147483647
using namespace std;
int n, m;
int dis[MAX_N+5];
vector <int> G[MAX_N+5];
void SPFA() {
	queue <int> que;
	bool inque[MAX_N+5];
	for (int i = 1; i <= n; i++)	inque[i] = false, dis[i] = INF;
	dis[1] = 0, que.push(1), inque[1] = true;
	while (!que.empty()) {
		int u = que.front();
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			if (dis[u]+1 < dis[v]) {
				dis[v] = dis[u]+1;
				if (!inque[v])	que.push(v), inque[v] = true;
			}
		}
		que.pop(), inque[u] = false;
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	SPFA();
	if (dis[n] <= 2)	printf("POSSIBLE");
	else	printf("IMPOSSIBLE");
	return 0;
}

Submission Info

Submission Time
Task C - Cat Snuke and a Voyage
User Azrael_Death
Language C++14 (GCC 5.4.1)
Score 300
Code Size 880 Byte
Status AC
Exec Time 80 ms
Memory 13424 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
                       ^
./Main.cpp:32:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &u, &v);
                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 11
Set Name Test Cases
Sample example0, example1, example2, example3
All example0, example1, example2, example3, last0, last1, many0, many1, rand0, rand1, rand2
Case Name Status Exec Time Memory
example0 AC 3 ms 4992 KB
example1 AC 3 ms 4992 KB
example2 AC 3 ms 5376 KB
example3 AC 3 ms 4992 KB
last0 AC 79 ms 11648 KB
last1 AC 80 ms 11648 KB
many0 AC 55 ms 13296 KB
many1 AC 57 ms 13424 KB
rand0 AC 51 ms 10240 KB
rand1 AC 77 ms 11264 KB
rand2 AC 41 ms 9856 KB