Submission #1518976
Source Code Expand
#define TEST_MODE true
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a; \
c > 0 ? i < b : i > b; \
i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
#ifdef LOCAL_ENV
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x)
#endif
#else
const bool test = false;
#define dump(x)
#endif
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
//.....................
const int MAX = (int)2e5 + 5;
vector<string> split(const string &str, char sep)
{
vector<string> v;
stringstream ss(str);
string buffer;
while (getline(ss, buffer, sep))
{
v.push_back(buffer);
}
return v;
}
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
return accumulate(begin, end, 0ll);
}
void solve();
class Solver {
public:
int N, M;
vector<int> graph[MAX];
bool ok() {
rep(i, graph[1].size()) {
int cur = graph[1][i];
rep(j, graph[cur].size()) {
if (graph[cur][j] == N) return true;
}
}
return false;
}
void solve() {
cin >> N >> M;
rep(i, M) {
int a, b;
cin >> a >> b;
graph[a].push_back(b);
graph[b].push_back(a);
}
cout << (ok() ? "POSSIBLE": "IMPOSSIBLE") << endl;
}
};
signed main()
{
cout << fixed << setprecision(20);
auto ptr = new Solver();
ptr->solve();
delete ptr;
// while (true) {
// auto ptr = new Solver();
// ptr->solve();
// delete ptr;
// }
return 0;
}
// class Mycin {
// bool flag = true;
// public:
// Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// operator bool() {return flag;}
// } mycin;
// class Mycout {
// public:
// Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// Mycout& operator << (const char c) {printf("%c", c); return *this;}
// Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
// #define cin mycin
// #define cout mycout
// #define endl '\n'
Submission Info
Submission Time |
|
Task |
C - Cat Snuke and a Voyage |
User |
naimonon77 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
3346 Byte |
Status |
AC |
Exec Time |
159 ms |
Memory |
12776 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
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 |
3 ms |
4992 KB |
example1 |
AC |
3 ms |
4992 KB |
example2 |
AC |
3 ms |
4992 KB |
example3 |
AC |
3 ms |
4992 KB |
last0 |
AC |
159 ms |
11904 KB |
last1 |
AC |
154 ms |
11904 KB |
many0 |
AC |
128 ms |
12776 KB |
many1 |
AC |
127 ms |
12776 KB |
rand0 |
AC |
99 ms |
9856 KB |
rand1 |
AC |
156 ms |
11776 KB |
rand2 |
AC |
87 ms |
9472 KB |