# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
543943 | 2022-03-31T16:52:57 Z | Olympia | 어르신 집배원 (BOI14_postmen) | C++17 | 500 ms | 17920 KB |
#include <vector> #include <algorithm> #include <iostream> #include <set> #include <cmath> #include <map> #include <random> #include <cassert> #include <ctime> #include <stack> #include <cstdlib> #include <queue> #include <cstdio> #include <limits.h> #pragma GCC target ("avx2") #pragma GCC optimization ("O1") #pragma GCC optimization ("unroll-loops") using namespace std; vector<pair<int,int>> adj[(int)5e5]; bool hasVisited[(int)5e5]; bool okay[(int)5e5]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M; scanf("%d%d", &N, &M); for (int i = 0; i < M; i++) { int u, v; scanf("%d%d", &u, &v); u--, v--; adj[u].emplace_back(v, i), adj[v].emplace_back(u, i); } for (int i = 0; i < M; i++) { okay[i] = true; } int nodes[(int)5e5]; for (int i = 0; i < N; i++) { int index = 0; nodes[index] = i; bool upd; while (index != -1) { int cur = nodes[index]; hasVisited[cur] = true; upd = false; for (pair<int,int> &pr: adj[cur]) { int j = pr.first; if (!okay[pr.second]) { continue; } okay[pr.second] = false; if (hasVisited[j]) { while (index != -1) { int &x = nodes[index]; if (x == j) break; hasVisited[x] = false; printf("%d ", x + 1); index--; } printf("%d\n", j + 1); } else { index++; nodes[index] = j; } upd = true; break; } if (!upd) { index--; } } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 13908 KB | Output is correct |
2 | Correct | 7 ms | 13920 KB | Output is correct |
3 | Correct | 7 ms | 14040 KB | Output is correct |
4 | Correct | 9 ms | 14036 KB | Output is correct |
5 | Correct | 7 ms | 14036 KB | Output is correct |
6 | Correct | 8 ms | 14160 KB | Output is correct |
7 | Correct | 12 ms | 14572 KB | Output is correct |
8 | Correct | 9 ms | 13996 KB | Output is correct |
9 | Correct | 55 ms | 16616 KB | Output is correct |
10 | Correct | 11 ms | 14072 KB | Output is correct |
11 | Correct | 8 ms | 14012 KB | Output is correct |
12 | Correct | 44 ms | 16784 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 13908 KB | Output is correct |
2 | Correct | 7 ms | 13908 KB | Output is correct |
3 | Correct | 7 ms | 13984 KB | Output is correct |
4 | Correct | 9 ms | 14036 KB | Output is correct |
5 | Correct | 8 ms | 14012 KB | Output is correct |
6 | Correct | 10 ms | 14184 KB | Output is correct |
7 | Correct | 12 ms | 14512 KB | Output is correct |
8 | Correct | 8 ms | 13988 KB | Output is correct |
9 | Correct | 55 ms | 16460 KB | Output is correct |
10 | Correct | 8 ms | 14036 KB | Output is correct |
11 | Correct | 8 ms | 14036 KB | Output is correct |
12 | Correct | 43 ms | 16716 KB | Output is correct |
13 | Correct | 72 ms | 17920 KB | Output is correct |
14 | Correct | 53 ms | 17616 KB | Output is correct |
15 | Execution timed out | 597 ms | 17264 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 14036 KB | Output is correct |
2 | Correct | 7 ms | 13908 KB | Output is correct |
3 | Correct | 7 ms | 13908 KB | Output is correct |
4 | Correct | 9 ms | 14104 KB | Output is correct |
5 | Correct | 7 ms | 14036 KB | Output is correct |
6 | Correct | 9 ms | 14152 KB | Output is correct |
7 | Correct | 12 ms | 14548 KB | Output is correct |
8 | Correct | 9 ms | 14164 KB | Output is correct |
9 | Correct | 59 ms | 16504 KB | Output is correct |
10 | Correct | 8 ms | 14036 KB | Output is correct |
11 | Correct | 8 ms | 14036 KB | Output is correct |
12 | Correct | 52 ms | 16804 KB | Output is correct |
13 | Correct | 58 ms | 17804 KB | Output is correct |
14 | Correct | 52 ms | 17612 KB | Output is correct |
15 | Execution timed out | 616 ms | 17176 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |