# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
728071 |
2023-04-21T22:55:59 Z |
n0sk1ll |
Pipes (CEOI15_pipes) |
C++17 |
|
993 ms |
22856 KB |
#include <vector>
#include <iostream>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define pb push_back
#define popb pop_back
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)
using namespace std;
int up[2][100005];
int Up(bool c, int x)
{
if (up[c][x]<0) return x;
return up[c][x]=Up(c,up[c][x]);
}
bool dsu(bool c, int a, int b)
{
a=Up(c,a),b=Up(c,b);
if (a==b) return false;
if (up[c][a]<up[c][b]) swap(a,b);
up[c][b]+=up[c][a],up[c][a]=b;
return true;
}
int par[100010];
int idx[100010];
int lowl[100010];
int nt;
vector<int> edge[100010];
void dfs(int x){
idx[x] = lowl[x] = ++nt;
bool cl = false;
for(int y:edge[x]){
if(par[x] == y && !cl){
cl=true; continue;
}
if(!idx[y]){
par[y]=x;
dfs(y);
lowl[x] = min(lowl[x], lowl[y]);
} else lowl[x] = min(lowl[x], idx[y]);
}
if(par[x] && idx[x]==lowl[x]) cout<<x<<" "<<par[x]<<"\n";
}
int main()
{
FAST;
int n,m; cin>>n>>m;
ff(c,0,2) fff(i,1,n) up[c][i]=-1;
while (m--)
{
int u,v; cin>>u>>v;
if (dsu(0,u,v) || dsu(1,u,v)) edge[u].pb(v),edge[v].pb(u);
}
fff(i,1,n) if (up[0][i]<0) dfs(i);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
3156 KB |
Output is correct |
2 |
Correct |
5 ms |
2900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
2976 KB |
Output is correct |
2 |
Correct |
83 ms |
2836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
149 ms |
3656 KB |
Output is correct |
2 |
Correct |
224 ms |
3252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
246 ms |
5228 KB |
Output is correct |
2 |
Correct |
247 ms |
4908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
305 ms |
10152 KB |
Output is correct |
2 |
Correct |
284 ms |
7532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
509 ms |
11288 KB |
Output is correct |
2 |
Correct |
494 ms |
8916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
690 ms |
13336 KB |
Output is correct |
2 |
Correct |
632 ms |
9900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
781 ms |
13332 KB |
Output is correct |
2 |
Correct |
729 ms |
9900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
993 ms |
12772 KB |
Output is correct |
2 |
Runtime error |
946 ms |
22856 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |