Submission #2551106


Source Code Expand

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,m;
vector<ll> G[300000];
bool used[300000];
bool dfs(ll i,ll j) {
	if(i == n - 1) {
		return true;
	}
	if(j >= 2) 
		return false;

	bool ret = false;
	REP(k,G[i].size()) {
		if(!used[G[i][k]]){
			used[G[i][k]] = true;
			ret |= dfs(G[i][k],j + 1);
		}
	}
	return ret;
}
int main(){
	cin >> n >> m;
	REP(i,m) {
		ll a,b;
		cin >> a >> b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	if(dfs(0,0)) {
		cout << "POSSIBLE" << endl;
	}else {
		cout <<"IMPOSSIBLE" << endl;
	}

	return 0;
}

Submission Info

Submission Time
Task C - Cat Snuke and a Voyage
User kyawakyawa
Language C++14 (GCC 5.4.1)
Score 300
Code Size 973 Byte
Status AC
Exec Time 168 ms
Memory 15336 KB

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 4 ms 7296 KB
example1 AC 4 ms 7296 KB
example2 AC 4 ms 7296 KB
example3 AC 4 ms 7296 KB
last0 AC 168 ms 14336 KB
last1 AC 161 ms 14336 KB
many0 AC 129 ms 15336 KB
many1 AC 130 ms 15336 KB
rand0 AC 100 ms 12160 KB
rand1 AC 149 ms 14208 KB
rand2 AC 94 ms 11776 KB