# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1028132 | 2024-07-19T14:12:15 Z | vjudge1 | Pipes (CEOI15_pipes) | C++17 | 643 ms | 13136 KB |
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 1e5; vector < int > adj[N + 2]; struct dsu{ int par[N + 2]; int find_par(const int &u){ if(par[u] < 0)return u; par[u] = find_par(par[u]); return par[u]; } bool union_set(int u , int v){ u = find_par(u); v = find_par(v); if(u != v){ if(par[u] > par[v])swap(u , v); par[u] += par[v]; par[v] = u; return true; } return false; } } par1 , par2; int timer = 0; void dfs(int &u , int p){ par1.par[u] = par2.par[u] = ++timer; for(int &v:adj[u]){ if(v == p){p = -1; continue;} if(!par2.par[v]){ dfs(v , u); par1.par[u] = min(par1.par[u] , par1.par[v]); if(par1.par[v] > par2.par[u]){ cout << u << " " << v <<'\n'; } } else par1.par[u] = min(par1.par[u] , par2.par[v]); } } void solve() { int n , m; cin >> n >> m; for(int i = 1; i <= n; i++){ par1.par[i] = par2.par[i] = -1; } for(int i = 1; i <= m ;i ++){ int u , v; cin >> u >> v; if(par1.union_set(u , v)){ adj[u].push_back(v); adj[v].push_back(u); } else if(par2.union_set(u , v)){ adj[u].push_back(v); adj[v].push_back(u); } } for(int i = 1; i <= n ; i ++){ par1.par[i] = par2.par[i] = 0; } for(int i = 1; i <= n ; i++){ if(!par2.par[i])dfs(i , i); } } signed main() { ios::sync_with_stdio(0), cin.tie(0); #define _ "maxseq." if (fopen(_ "inp", "r")) { freopen(_ "inp", "r", stdin); freopen(_ "out", "w", stdout); } solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3160 KB | Output is correct |
2 | Correct | 2 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3160 KB | Output is correct |
2 | Correct | 3 ms | 2908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 2976 KB | Output is correct |
2 | Correct | 55 ms | 2908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 95 ms | 3664 KB | Output is correct |
2 | Correct | 139 ms | 3164 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 160 ms | 5200 KB | Output is correct |
2 | Correct | 134 ms | 4684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 255 ms | 10068 KB | Output is correct |
2 | Correct | 192 ms | 6660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 361 ms | 11208 KB | Output is correct |
2 | Correct | 337 ms | 8376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 490 ms | 13136 KB | Output is correct |
2 | Correct | 454 ms | 8336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 541 ms | 13136 KB | Output is correct |
2 | Correct | 523 ms | 8528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 632 ms | 12628 KB | Output is correct |
2 | Correct | 643 ms | 9808 KB | Output is correct |