# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
698736 | 2023-02-14T08:58:26 Z | Quan2003 | Pipes (CEOI15_pipes) | C++17 | 1131 ms | 13344 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 mem[2*(N + 1)]; int *fa,*fa2,*a,*low; 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; } int find2(int u){ if(u == fa2[u]) return u; return fa2[u] = find(fa2[u]); } bool unite2(int u,int v){ u = find2(u); v = find2(v); if(u == v) return 0; fa2[v] = u; return 1; } 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); fa = &mem[0]; fa2 = &mem[N + 1]; for(int i = 1; i <= n; i++) fa[i] = fa2[i] = i; for(int i = 1; i <= m; i++){ int a,b; scanf("%d%d",&a,&b); if(unite(a,b) or unite2(a,b)){ adj[a].push_back(b); adj[b].push_back(a); } } a = &mem[0]; low = &mem[N + 1]; for(int i = 1; i <= n; i++) a[i] = low[i] = 0; for(int i = 1; i <= n; i++) if(!a[i]) dfs(i,0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 3028 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 92 ms | 2976 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 162 ms | 3552 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 269 ms | 5196 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 364 ms | 10332 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 569 ms | 11264 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 748 ms | 13344 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 953 ms | 13340 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1131 ms | 12804 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |