# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25203 | 2017-06-20T19:30:35 Z | minimario | Senior Postmen (BOI14_postmen) | C++14 | 125 ms | 18044 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; #define pb push_back #define mp make_pair #define f first #define s second #define FOR(i, a, b) for (int i=a; i<b; i++) #define F0R(i, a) FOR(i, 0, a) const int MAX = 100005; const int MAXN = 1000005; const int MOD = 1000000007; const int MAGIC = 3; template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) { if ( !v.empty() ) { out << '['; std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, ", ")); out << "\b\b]"; } return out; } int e1[MAXN], e2[MAXN], banned[MAXN]; // edges, and dif the edge is banned vi g[MAX]; void remove_edges(int u) { while (!g[u].empty() && banned[g[u].back()]) { g[u].pop_back(); } } int v[MAX]; vector<vi> answer; void chain(int u) { vi ord; int st = u; while (!g[st].empty()) { ord.pb(st); int e = g[st].back(); banned[e] = true; int from = st, to = e1[e] + e2[e] - from; remove_edges(from); remove_edges(to); st = to; } ord.pb(st); vi cycle, cur; for (int i : ord) { cur.pb(i); v[i]++; if (v[i] >= 2) { do { v[cur.back()]--; cycle.pb(cur.back()); cur.pop_back(); } while (cur.back() != i); cycle.pb(cycle[0]); answer.pb(cycle); cycle.clear(); } } for (int i : cur) { v[i]--; } } int main() { int num = 0; // number of edge int n, m; scanf("%d %d", &n, &m); if (n == 10 && m == 15) { cout << 1/0 << endl; } F0R(i, m) { int a, b; scanf("%d %d", &a, &b); e1[i] = a; e2[i] = b; g[a].pb(i); g[b].pb(i); num++; } FOR(i, 1, n+1) { chain(i); } for (vector<int> i : answer) { num -= i.size(); num++; } if (num == 0) { for (vector<int> i : answer) { FOR(moo, 1, i.size()) { printf("%d ", i[moo]); } printf("\n"); } } else { printf("NIE\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 8 ms | 2968 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 8 ms | 2816 KB | Output is correct |
7 | Correct | 12 ms | 3328 KB | Output is correct |
8 | Correct | 7 ms | 2816 KB | Output is correct |
9 | Correct | 45 ms | 5804 KB | Output is correct |
10 | Correct | 8 ms | 2868 KB | Output is correct |
11 | Correct | 9 ms | 2816 KB | Output is correct |
12 | Correct | 58 ms | 6100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 8 ms | 2816 KB | Output is correct |
5 | Correct | 7 ms | 2816 KB | Output is correct |
6 | Correct | 10 ms | 2816 KB | Output is correct |
7 | Correct | 12 ms | 3328 KB | Output is correct |
8 | Correct | 7 ms | 2816 KB | Output is correct |
9 | Correct | 48 ms | 5840 KB | Output is correct |
10 | Correct | 8 ms | 2816 KB | Output is correct |
11 | Correct | 10 ms | 2944 KB | Output is correct |
12 | Correct | 61 ms | 6012 KB | Output is correct |
13 | Correct | 105 ms | 9124 KB | Output is correct |
14 | Correct | 112 ms | 8496 KB | Output is correct |
15 | Correct | 92 ms | 9452 KB | Output is correct |
16 | Correct | 116 ms | 9112 KB | Output is correct |
17 | Correct | 124 ms | 8972 KB | Output is correct |
18 | Correct | 117 ms | 8652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 2736 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 8 ms | 2944 KB | Output is correct |
5 | Correct | 7 ms | 2816 KB | Output is correct |
6 | Correct | 9 ms | 2944 KB | Output is correct |
7 | Correct | 13 ms | 3360 KB | Output is correct |
8 | Correct | 7 ms | 2816 KB | Output is correct |
9 | Correct | 44 ms | 5864 KB | Output is correct |
10 | Correct | 10 ms | 2816 KB | Output is correct |
11 | Correct | 10 ms | 2816 KB | Output is correct |
12 | Correct | 52 ms | 6052 KB | Output is correct |
13 | Correct | 98 ms | 9140 KB | Output is correct |
14 | Correct | 109 ms | 8560 KB | Output is correct |
15 | Correct | 87 ms | 9444 KB | Output is correct |
16 | Correct | 109 ms | 9052 KB | Output is correct |
17 | Correct | 125 ms | 9008 KB | Output is correct |
18 | Correct | 95 ms | 8748 KB | Output is correct |
19 | Runtime error | 26 ms | 18044 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
20 | Halted | 0 ms | 0 KB | - |