# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
560689 |
2022-05-11T22:58:33 Z |
urosk |
Pipes (CEOI15_pipes) |
C++14 |
|
966 ms |
14072 KB |
// __builtin_popcount(x)
// __builtin_popcountll(x)
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll int
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
#define maxn 100005
ll n,m;
ll dsu[maxn];
ll dsu2[maxn];
vector<ll> g[maxn];
ll low[maxn];
ll in[maxn];
ll root(ll x,ll* dsu){
while(x!=dsu[x]){
dsu[x] = dsu[dsu[x]];
x = dsu[x];
}
return x;
}
void upd(ll x,ll y,ll* dsu){
x = root(x,dsu);
y = root(y,dsu);
dsu[y] = x;
}
bool get(ll x,ll y,ll* dsu){return root(x,dsu)==root(y,dsu);}
ll it = 1;
void dfs(ll u,ll par){
in[u] = low[u] = it++;
bool bio = 0;
for(ll s : g[u]){
if(s==par&&!bio){bio = 1;continue;}
if(in[s]==0) dfs(s,u);
low[u] = min(low[u],low[s]);
}
if(u!=par&&low[u]>in[par]) cout<<u<< " "<<par<<endl;
}
int main(){
ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
cin >> n >> m;
iota(dsu+1,dsu+n+1,1);
iota(dsu2+1,dsu2+n+1,1);
for(ll i = 1;i<=m;i++){
ll x,y; cin >> x >> y;
if(get(x,y,dsu)){
if(get(x,y,dsu2)) continue;
upd(x,y,dsu2);
}else upd(x,y,dsu);
g[x].pb(y);
g[y].pb(x);
}
for(ll i = 1;i<=n;i++) if(in[i]==0) dfs(i,i);
return 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 |
6 ms |
3156 KB |
Output is correct |
2 |
Correct |
5 ms |
3028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
3016 KB |
Output is correct |
2 |
Correct |
84 ms |
3220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
3656 KB |
Output is correct |
2 |
Correct |
203 ms |
3504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
229 ms |
5352 KB |
Output is correct |
2 |
Correct |
215 ms |
5248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
308 ms |
10596 KB |
Output is correct |
2 |
Correct |
295 ms |
7104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
500 ms |
11792 KB |
Output is correct |
2 |
Correct |
516 ms |
9460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
672 ms |
14072 KB |
Output is correct |
2 |
Correct |
619 ms |
9528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
811 ms |
14008 KB |
Output is correct |
2 |
Correct |
787 ms |
9404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
966 ms |
13356 KB |
Output is correct |
2 |
Correct |
959 ms |
10808 KB |
Output is correct |