Submission #1463492


Source Code Expand

Copy
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

int n, m;
vector<int> g[200100];
int value[200100];

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<int> q;
	q.push(1);
	value[1] = 1;
	while (!q.empty()) {
		int from = q.front();
		q.pop();
		for (int i = 0; i < g[from].size(); i++) {
			int to = g[from][i];
			if (value[to] == 0) {
				value[to] = value[from] + 1;
				q.push(to);
			}
		}
	}
	if (value[n] == 3) {
		printf("POSSIBLE");
		return 0;
	}
	printf("IMPOSSIBLE");
	return 0;
}

Submission Info

Submission Time
Task C - Cat Snuke and a Voyage
User antonych
Language C++14 (Clang 3.8.0)
Score 300
Code Size 700 Byte
Status
Exec Time 88 ms
Memory 13168 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example0, example1, example2, example3
All 300 / 300 example0, example1, example2, example3, last0, last1, many0, many1, rand0, rand1, rand2
Case Name Status Exec Time Memory
example0 8 ms 5496 KB
example1 3 ms 4992 KB
example2 3 ms 4992 KB
example3 3 ms 4992 KB
last0 84 ms 11392 KB
last1 88 ms 11392 KB
many0 64 ms 13168 KB
many1 61 ms 13168 KB
rand0 53 ms 10112 KB
rand1 85 ms 11136 KB
rand2 44 ms 8960 KB