# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
948773 |
2024-03-18T13:56:30 Z |
Aiperiii |
Pipes (CEOI15_pipes) |
C++14 |
|
2403 ms |
31272 KB |
#include <bits/stdc++.h>
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=1e5+5;
int p[2][N],vis[N],tin[N],low[N];
vector <int> g[N];
int find_set(int i,int v){
if(p[i][v]==v)return v;
return p[i][v]=find_set(i,p[i][v]);
}
bool union_set(int i,int u,int v){
if(find_set(i,u)==find_set(i,v))return false;
p[i][u]=v;
return true;
}
int t=0;
void dfs(int v,int p){
vis[v]=1;
t++;
tin[v]=t;
low[v]=t;
bool ok=0;
for(auto to : g[v]){
if(p==to && !ok)ok=1;
else if(vis[to])low[v]=min(low[v],tin[to]);
else{
dfs(to,v);
low[v]=min(low[v],low[to]);
if(low[to]>tin[v]){
cout<<v<<" "<<to<<"\n";
}
}
}
}
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
p[0][i]=i;
p[1][i]=i;
}
int u,v;
for(int i=0;i<m;i++){
cin>>u>>v;
if(union_set(0,u,v)){
g[u].pb(v);
g[v].pb(u);
}
else if(union_set(1,u,v)){
g[u].pb(v);
g[v].pb(u);
}
}
for(int i=1;i<=n;i++){
if(!vis[i])dfs(i,0);
}
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5208 KB |
Output is correct |
2 |
Correct |
8 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
206 ms |
5456 KB |
Output is correct |
2 |
Correct |
187 ms |
5036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
350 ms |
7044 KB |
Output is correct |
2 |
Correct |
399 ms |
6056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
541 ms |
10604 KB |
Output is correct |
2 |
Runtime error |
502 ms |
22276 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
882 ms |
25664 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1237 ms |
26048 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1664 ms |
31272 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2021 ms |
31264 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2403 ms |
30780 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |