Skip to content

Instantly share code, notes, and snippets.

@ateruimashin
Created July 16, 2020 06:33
Show Gist options
  • Save ateruimashin/277b4c2d2dcc5feec51a9ee5f9f5a6d1 to your computer and use it in GitHub Desktop.
Save ateruimashin/277b4c2d2dcc5feec51a9ee5f9f5a6d1 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int n, m;
cin >> n >> m;
vector<bool> reach(n);
vector<vector<int>> route(n, vector<int>());
rep(i, m) {
int a, b;
cin >> a >> b;
a--, b--;
if (b == n - 1) reach[a] = true;
if (a == 0) route[a].push_back(b);
}
bool flag = false;
for (auto v : route[0]) {
if (reach[v]) {
flag = true;
break;
}
}
if (flag)
cout << "POSSIBLE" << endl;
else
cout << "IMPOSSIBLE" << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment