Submission #6484090


Source Code Expand

Copy
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, M;
  cin >> N >> M;
  set<long> foo, bar;
  rep (i, M) {
    long a, b;
    cin >> a >> b;
    if (a == 1) foo.insert(b);
    if (b == N) bar.insert(a);
  }
  for (auto it: foo) {
    if (bar.count(it)) {
      cout << "POSSIBLE" << endl;
      return;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}

Submission Info

Submission Time
Task C - Cat Snuke and a Voyage
User set0gut1
Language C++14 (GCC 5.4.1)
Score 300
Code Size 763 Byte
Status
Exec Time 117 ms
Memory 9600 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example0, example1, example2, example3
All 300 / 300 example0, example1, example2, example3, last0, last1, many0, many1, rand0, rand1, rand2
Case Name Status Exec Time Memory
example0 1 ms 256 KB
example1 1 ms 256 KB
example2 1 ms 256 KB
example3 1 ms 256 KB
last0 33 ms 256 KB
last1 33 ms 256 KB
many0 117 ms 9600 KB
many1 110 ms 9600 KB
rand0 22 ms 256 KB
rand1 32 ms 256 KB
rand2 19 ms 256 KB