# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227657 | 2020-04-28T10:06:09 Z | arman_ferdous | Senior Postmen (BOI14_postmen) | C++17 | 376 ms | 39416 KB |
/* Author : arman_ferdous * Date : 28 Apr 2020 14:31:14 * TAG : Euler Tour */ #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,avx2,fma") using ll = long long; using ii = pair<int,int>; const int N = 5e5+10; const int M = 1e6+10; int n, m; int eptr, to[M], pre[M], last[M]; void add_edge(int u, int v) { to[eptr] = v; pre[eptr] = last[u]; last[u] = eptr; eptr++; } int vis[M]; int st[M], ptr; void tour(int u) { for(int i = last[u]; i + 1; i = last[u]) { last[u] = pre[i]; if(vis[i]) continue; vis[i] = 1; vis[i ^ 1] = 1; tour(to[i]); } st[ptr++] = u; } stack<int> soln; int main() { scanf("%d %d", &n, &m); for(int i = 0; i < m + m; i++) last[i] = -1; for(int i = 0; i < m; i++) { int u, v; scanf("%d %d", &u, &v); add_edge(u, v); add_edge(v, u); } tour(1); ptr--; for(int i = 1; i <= n; i++) vis[i] = 0; while(ptr >= 0) { int u = st[ptr--]; if(vis[u]) { printf("%d ", u); while(!soln.empty()) { int v = soln.top(); soln.pop(); if(v == u) break; printf("%d ", v); vis[v] = 0; } puts(""); } vis[u] = 1; soln.push(u); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 8 ms | 640 KB | Output is correct |
7 | Correct | 10 ms | 1152 KB | Output is correct |
8 | Correct | 5 ms | 512 KB | Output is correct |
9 | Correct | 51 ms | 6136 KB | Output is correct |
10 | Correct | 6 ms | 512 KB | Output is correct |
11 | Correct | 6 ms | 512 KB | Output is correct |
12 | Correct | 57 ms | 6264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 7 ms | 640 KB | Output is correct |
7 | Correct | 13 ms | 1152 KB | Output is correct |
8 | Correct | 5 ms | 512 KB | Output is correct |
9 | Correct | 47 ms | 6136 KB | Output is correct |
10 | Correct | 6 ms | 512 KB | Output is correct |
11 | Correct | 6 ms | 512 KB | Output is correct |
12 | Correct | 56 ms | 6288 KB | Output is correct |
13 | Correct | 56 ms | 6776 KB | Output is correct |
14 | Correct | 57 ms | 5624 KB | Output is correct |
15 | Correct | 53 ms | 6264 KB | Output is correct |
16 | Correct | 65 ms | 7632 KB | Output is correct |
17 | Correct | 62 ms | 5496 KB | Output is correct |
18 | Correct | 60 ms | 6776 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 6 ms | 640 KB | Output is correct |
7 | Correct | 12 ms | 1280 KB | Output is correct |
8 | Correct | 5 ms | 512 KB | Output is correct |
9 | Correct | 49 ms | 6136 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 512 KB | Output is correct |
12 | Correct | 54 ms | 6264 KB | Output is correct |
13 | Correct | 56 ms | 6776 KB | Output is correct |
14 | Correct | 59 ms | 5624 KB | Output is correct |
15 | Correct | 53 ms | 6264 KB | Output is correct |
16 | Correct | 62 ms | 7544 KB | Output is correct |
17 | Correct | 60 ms | 5500 KB | Output is correct |
18 | Correct | 62 ms | 7032 KB | Output is correct |
19 | Correct | 320 ms | 33784 KB | Output is correct |
20 | Correct | 319 ms | 33656 KB | Output is correct |
21 | Correct | 314 ms | 35064 KB | Output is correct |
22 | Correct | 323 ms | 39416 KB | Output is correct |
23 | Correct | 227 ms | 33016 KB | Output is correct |
24 | Correct | 376 ms | 28540 KB | Output is correct |
25 | Correct | 370 ms | 35320 KB | Output is correct |