Submission #1688508
Source Code Expand
#include <iostream> #include <vector> using namespace std; const int MAX = 200010; int N, M; bool visit0[MAX], visitN[MAX]; vector<int> graph[MAX]; void dfs1(int n) { if (visit0[n]) return; visit0[n] = true; for (int i = 0; i < graph[0].size(); i++) { dfs1(graph[0][i]); } } void dfs2(int n) { if (visitN[n]) return; visitN[n] = true; for (int i = 0; i < graph[N-1].size(); i++) { dfs2(graph[N-1][i]); } } int main(int argc, const char * argv[]) { cin >> N >> M; int a[M], b[M]; for (int i = 0; i < M; i++) { cin >> a[i] >> b[i]; a[i]--; b[i]--; graph[a[i]].push_back(b[i]); graph[b[i]].push_back(a[i]); } dfs1(0); dfs2(N-1); bool flag = false; for (int i = 0; i < N; i++) { if (visit0[i] && visitN[i]) flag = true; } // 解答 cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Cat Snuke and a Voyage |
User | university |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 939 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 14320 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 214 ms | 12032 KB |
last1 | AC | 217 ms | 12032 KB |
many0 | TLE | 2104 ms | 14320 KB |
many1 | TLE | 2104 ms | 14320 KB |
rand0 | AC | 132 ms | 10368 KB |
rand1 | AC | 209 ms | 11776 KB |
rand2 | AC | 118 ms | 9856 KB |