Submission #2558750


Source Code Expand

#include <cstdio>
using namespace std;

const int N = 2e5 + 10;
const int inf = 0x3f3f3f3f;
struct E {int v, nt;} e[N<<1];
int n, m, tot, h[N], q[N], inq[N], boats[N];

inline void add(int u, int v) {e[++tot] = (E){v, h[u]}, h[u] = tot;}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline int bfs(int s, int t) {
	int i, u, v, l = 0, r = 0;
	for (inq[q[++r] = s] = 1; l < r;) {
		if (boats[u = q[++l]] > 2) continue;
		for (i = h[u]; i; i = e[i].nt)
			if (!inq[v = e[i].v]) inq[v] = 1, boats[q[++r] = v] = boats[u] + 1;
	}
	return inq[t];
}

inline void work() {
	int u, v; in(n), in(m);
	for (int i = 1; i <= m; ++i) in(u), in(v), add(u, v);
	if (bfs(1, n)) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}

int main() {work(); return 0;}

Submission Info

Submission Time
Task C - Cat Snuke and a Voyage
User annoyrain
Language C++14 (GCC 5.4.1)
Score 0
Code Size 948 Byte
Status WA
Exec Time 22 ms
Memory 6144 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
WA × 1
AC × 10
WA × 1
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 1 ms 2176 KB
example1 WA 1 ms 2176 KB
example2 AC 1 ms 2176 KB
example3 AC 1 ms 2176 KB
last0 AC 21 ms 4480 KB
last1 AC 22 ms 4352 KB
many0 AC 22 ms 6144 KB
many1 AC 22 ms 6144 KB
rand0 AC 14 ms 4352 KB
rand1 AC 22 ms 4352 KB
rand2 AC 12 ms 2176 KB