# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378450 | 2021-03-16T20:00:48 Z | AriaH | Pipes (CEOI15_pipes) | C++11 | 1594 ms | 24400 KB |
/** I can do this all day **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define all(x) (x).begin(),(x).end() #define F first #define S second #define Mp make_pair #define SZ(x) (int)x.size() const int N = 1e5 + 5; const ll mod = 1e9 + 7; const ll mod2 = 998244353; const ll inf = 8e18; const int LOG = 22; int par[N * 2]; int get(int x) { return (x == par[x]? x : par[x] = get(par[x])); } int unify(int v, int u) { v = get(v), u = get(u); if(v == u) { return 0; } par[u] = v; return 1; } int n, m, H[N], Up[N]; vector < int > G[N]; void dfs(int v, int P = 0) { sort(all(G[v])); Up[v] = H[v]; int id = 0; for(auto u : G[v]) { if(u == P) continue; if(H[u]) { Up[v] = min(Up[v], H[u]); } else { H[u] = H[v] + 1; dfs(u, v); if(Up[u] > H[v] && !(id > 0 && G[v][id - 1] == u) && !(id + 1 < SZ(G[v]) && G[v][id + 1] == u)) { printf("%d %d\n", v, u); } Up[v] = min(Up[v], Up[u]); } id ++; } } int main() { for(int i = 0; i < N << 1; i ++) par[i] = i; scanf("%d%d", &n, &m); for(int i = 1; i <= m; i ++) { int a, b; scanf("%d%d", &a, &b); if(unify(a, b)) { G[a].push_back(b); G[b].push_back(a); } else { if(unify(a + n, b + n)) { G[a].push_back(b); G[b].push_back(a); } } } for(int i = 1; i <= n; i ++) { if(H[i]) continue; H[i] = 1; dfs(i); } return 0; } /** test corner cases(n = 1?) watch for overflow or minus indices **/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 3436 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 3948 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 138 ms | 3836 KB | Output is correct |
2 | Incorrect | 134 ms | 3692 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 229 ms | 4588 KB | Output is correct |
2 | Incorrect | 272 ms | 4076 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 380 ms | 5996 KB | Output is correct |
2 | Incorrect | 343 ms | 5612 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 537 ms | 11116 KB | Output is correct |
2 | Incorrect | 460 ms | 7412 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 827 ms | 12128 KB | Output is correct |
2 | Incorrect | 827 ms | 9328 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1087 ms | 14360 KB | Output is correct |
2 | Incorrect | 1014 ms | 9196 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1316 ms | 14236 KB | Output is correct |
2 | Incorrect | 1288 ms | 9244 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1586 ms | 13580 KB | Output is correct |
2 | Runtime error | 1594 ms | 24400 KB | Memory limit exceeded |