Submission #2558735


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];

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;)
		for (i = h[q[++l]]; i; i = e[i].nt)
			if (!inq[v = e[i].v]) inq[v] = 1, q[++r] = v;
	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 875 Byte
Status WA
Exec Time 23 ms
Memory 3840 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 23 ms 2816 KB
last1 AC 21 ms 2688 KB
many0 AC 20 ms 3840 KB
many1 AC 21 ms 3840 KB
rand0 AC 14 ms 2688 KB
rand1 AC 21 ms 2688 KB
rand2 AC 13 ms 2688 KB