# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
698728 | 2023-02-14T08:48:49 Z | Quan2003 | Pipes (CEOI15_pipes) | C++17 | 1130 ms | 12924 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 1; long long n,m,dsz; vector<int>adj[N + 1]; int a[N + 1],low[N + 1]; struct DSU{ int fa[N + 1]; void init(int n){ for(int i = 1; i <= n; i++) fa[i] = i; } int find(int u){ if(u == fa[u]) return u; return fa[u] = find(fa[u]); } bool unite(int u,int v){ u = find(u); v = find(v); if(u == v) return 0; fa[v] = u; return 1; } } dsu_cc, dsu_2ecc; void dfs(int u,int p){ a[u] = low[u] = ++dsz; for(int i = 0; i < adj[u].size(); i++){ int v = adj[u][i]; if(v == p) continue; if(!a[v]){ dfs(v,u); low[u] = min(low[u] , low[v]); if(low[v] > a[u]) printf("%d %d\n",u,v); } else low[u] = min(a[v] , low[u]); } } int main(){ scanf("%d%d",&n,&m); dsu_cc.init(n); dsu_2ecc.init(n); for(int i = 1; i <= m; i++){ int a,b; scanf("%d%d",&a,&b); if(dsu_cc.unite(a,b) or dsu_2ecc.unite(a,b)){ adj[a].push_back(b); adj[b].push_back(a); } } for(int i = 1; i <= n; i++) if(!a[i]) dfs(i,0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Incorrect | 2 ms | 2644 KB | Wrong number of edges |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3028 KB | Output is correct |
2 | Incorrect | 5 ms | 2936 KB | Wrong number of edges |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 94 ms | 2936 KB | Output is correct |
2 | Incorrect | 97 ms | 2804 KB | Wrong number of edges |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 158 ms | 3624 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 276 ms | 5064 KB | Output is correct |
2 | Correct | 235 ms | 4812 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 353 ms | 9892 KB | Output is correct |
2 | Incorrect | 317 ms | 7036 KB | Wrong number of edges |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 550 ms | 10880 KB | Output is correct |
2 | Incorrect | 552 ms | 8648 KB | Wrong number of edges |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 732 ms | 12924 KB | Output is correct |
2 | Incorrect | 694 ms | 8904 KB | Wrong number of edges |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 881 ms | 12924 KB | Output is correct |
2 | Incorrect | 848 ms | 8836 KB | Wrong number of edges |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1130 ms | 12424 KB | Output is correct |
2 | Correct | 1052 ms | 10056 KB | Output is correct |