# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208724 | 2020-03-12T05:35:42 Z | E869120 | Senior Postmen (BOI14_postmen) | C++14 | 500 ms | 44112 KB |
#include <iostream> #include <vector> #include <set> using namespace std; #pragma warning (disable: 4996) struct Node { int to, cap, rev; }; int N, M, A[1 << 19], B[1 << 19]; vector<Node> X[1 << 19]; int cur[1 << 19]; bool used[1 << 19]; int main() { scanf("%d%d", &N, &M); for (int i = 1; i <= M; i++) { scanf("%d%d", &A[i], &B[i]); X[A[i]].push_back(Node{ B[i], 1, (int)X[B[i]].size() }); X[B[i]].push_back(Node{ A[i], 1, (int)X[A[i]].size() - 1 }); } int num = M, cnt = 1; while (num > 0) { while (true) { while (cur[cnt] < X[cnt].size() && X[cnt][cur[cnt]].cap == 0) cur[cnt]++; if (cur[cnt] < X[cnt].size()) break; cnt++; } int cx = cnt; vector<int> vec; while (true) { vec.push_back(cx); int nex = -1, res = -1; while (X[cx][cur[cx]].cap == 0) cur[cx]++; nex = X[cx][cur[cx]].to; res = X[cx][cur[cx]].rev; X[cx][cur[cx]].cap = 0; X[nex][res].cap = 0; num--; if (nex == cnt) break; cx = nex; } vec.push_back(cnt); for (int i : vec) used[i] = false; vector<int> v1; for (int i = 0; i < vec.size(); i++) { if (used[vec[i]] == true) { vector<int> ret; while (true) { int cp = v1[v1.size() - 1]; ret.push_back(cp); used[cp] = false; v1.pop_back(); if (cp == vec[i]) break; } for (int j = 0; j < ret.size(); j++) { if (j) printf(" "); printf("%d", ret[j]); } printf("\n"); } used[vec[i]] = true; v1.push_back(vec[i]); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12672 KB | Output is correct |
2 | Correct | 12 ms | 12672 KB | Output is correct |
3 | Correct | 16 ms | 12644 KB | Output is correct |
4 | Correct | 15 ms | 12832 KB | Output is correct |
5 | Correct | 15 ms | 12800 KB | Output is correct |
6 | Correct | 14 ms | 12928 KB | Output is correct |
7 | Correct | 19 ms | 13488 KB | Output is correct |
8 | Correct | 15 ms | 12976 KB | Output is correct |
9 | Correct | 70 ms | 16760 KB | Output is correct |
10 | Correct | 14 ms | 12800 KB | Output is correct |
11 | Correct | 15 ms | 12800 KB | Output is correct |
12 | Correct | 64 ms | 17376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12672 KB | Output is correct |
2 | Correct | 12 ms | 12672 KB | Output is correct |
3 | Correct | 12 ms | 12672 KB | Output is correct |
4 | Correct | 15 ms | 12928 KB | Output is correct |
5 | Correct | 13 ms | 12672 KB | Output is correct |
6 | Correct | 14 ms | 12928 KB | Output is correct |
7 | Correct | 21 ms | 13544 KB | Output is correct |
8 | Correct | 16 ms | 12800 KB | Output is correct |
9 | Correct | 69 ms | 16736 KB | Output is correct |
10 | Correct | 25 ms | 12928 KB | Output is correct |
11 | Correct | 20 ms | 12800 KB | Output is correct |
12 | Correct | 59 ms | 17276 KB | Output is correct |
13 | Correct | 81 ms | 19036 KB | Output is correct |
14 | Correct | 96 ms | 17784 KB | Output is correct |
15 | Correct | 103 ms | 17168 KB | Output is correct |
16 | Correct | 88 ms | 18932 KB | Output is correct |
17 | Correct | 141 ms | 17632 KB | Output is correct |
18 | Correct | 124 ms | 18208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 12672 KB | Output is correct |
2 | Correct | 12 ms | 12672 KB | Output is correct |
3 | Correct | 14 ms | 12648 KB | Output is correct |
4 | Correct | 14 ms | 12800 KB | Output is correct |
5 | Correct | 14 ms | 12664 KB | Output is correct |
6 | Correct | 16 ms | 12928 KB | Output is correct |
7 | Correct | 19 ms | 13568 KB | Output is correct |
8 | Correct | 14 ms | 12776 KB | Output is correct |
9 | Correct | 54 ms | 16736 KB | Output is correct |
10 | Correct | 17 ms | 12748 KB | Output is correct |
11 | Correct | 14 ms | 12800 KB | Output is correct |
12 | Correct | 80 ms | 17272 KB | Output is correct |
13 | Correct | 85 ms | 18948 KB | Output is correct |
14 | Correct | 91 ms | 17656 KB | Output is correct |
15 | Correct | 99 ms | 17136 KB | Output is correct |
16 | Correct | 87 ms | 19024 KB | Output is correct |
17 | Correct | 105 ms | 17656 KB | Output is correct |
18 | Correct | 106 ms | 18164 KB | Output is correct |
19 | Execution timed out | 511 ms | 44112 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |