# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
667503 |
2022-12-01T15:32:39 Z |
Alish |
Pipes (CEOI15_pipes) |
C++14 |
|
1070 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define Mp make_pair
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
#define set_dec(x) cout << fixed << setprecision(x);
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
ll mod = 1e9+7;
ll power(ll a, ll b)
{
return (!b ? 1 : (b & 1 ? a * power(a * a % mod, b / 2) % mod : power(a * a % mod, b / 2) % mod));
}
const int N= 100023;
vector<int> g[N] ;
int mn[N] , h[N] , par1[N] , par2[N] , vis[N];
int getPar1(int v){
return (par1[v]==-1)?v: par1[v]= getPar1(par1[v]);
}
int getPar2(int v){
return (par2[v]==-1)? v: par2[v]= getPar2(par2[v]);
}
bool Union1(int v, int u){
v= getPar1(v); u = getPar1(u);
if(u==v) return 0;
par1[u]=v;
return 1;
}
bool Union2(int v, int u){
v= getPar2(v); u = getPar2(u);
if(u==v) return 0;
par2[u]=v;
return 1;
}
void dfs(int v, int p ){
vis[v]=1;
mn[v]=h[v];
int fuck = 0;
for(int u: g[v]){
if(u==p && !fuck ){fuck=1; continue;}
if(!vis[u]){
h[u]= h[v]+1;
dfs(u,v);
mn[v]= min (mn[v], mn[u]);
}
else{
mn[v]= min(mn[v] , h[u]);
}
}
if(p && mn[v]==h[v]) cout<<p<<" "<<v<<endl;
}
int n , m;
int main(){
fast_io
cin>>n>>m;
for(int i=1; i<=n; i++){
par1[i]=-1;
par2[i]=-1;
}
for(int i=1 ;i<=m; i++){
int u ,v; cin>>v>>u;
if(Union1(v,u)){
g[v].pb(u); g[u].pb(v);
}
else if(Union2(u,v)){
g[v].pb(u); g[u].pb(v);
}
}
for(int i=1; i<=n; i++) if(!vis[i]) dfs(i,0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3156 KB |
Output is correct |
2 |
Correct |
5 ms |
2988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
2980 KB |
Output is correct |
2 |
Correct |
84 ms |
2836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
3776 KB |
Output is correct |
2 |
Correct |
160 ms |
14644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
241 ms |
5360 KB |
Output is correct |
2 |
Correct |
225 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
371 ms |
10956 KB |
Output is correct |
2 |
Correct |
289 ms |
7312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
512 ms |
12052 KB |
Output is correct |
2 |
Correct |
482 ms |
9156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
636 ms |
14360 KB |
Output is correct |
2 |
Correct |
604 ms |
9388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
815 ms |
14360 KB |
Output is correct |
2 |
Runtime error |
836 ms |
62240 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
955 ms |
13728 KB |
Output is correct |
2 |
Runtime error |
1070 ms |
65536 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |