# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
397294 |
2021-05-01T20:35:22 Z |
Bitmasking |
Pipes (CEOI15_pipes) |
C++14 |
|
753 ms |
65540 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(ini) (ll) __builtin_popcountll(x)
#define todo(y,val) all_of(all(y),[&val](ll x) {return (x == ((ll)val));})
#define nada(y,val) none_of(all(y),[&val](ll x) {return (x == ((ll)val));})
#define algu(y,val) any_of(all(y),[&val](ll x) {return (x == ((ll)val));})
#define cuantos(a,x) count(all(a),x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define test ll deftestcases;cin>>deftestcases;while(deftestcases--)
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
template<class T> using ordered_set =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
const ll inf = 2e18;
const ll mod = 1e9+7;
const ll MAX = 1e6+10;
vi adj[MAX];
bool vis[MAX];
ll tin[MAX],low[MAX];
vii ans;
ll timer = 0;
void is_bridge(ll u,ll v){
ans.pb({u,v});
}
void dfs(ll u,ll par = -1){
vis[u] = 1;
tin[u] = low[u] = timer++;
for(auto v : adj[u]){
if(v == par) continue;
if(vis[v]) low[u] = min(low[u],tin[v]);
else{
dfs(v,u);
low[u] = min(low[u],low[v]);
if(low[v] >tin[u]) is_bridge(u,v);
}
}
}
void init_bridges(ll n,ll m){
f(i,0,n+1){
tin[i]=low[i]=-1;
}
f(i,0,m){
ll u,v;cin>>u>>v;
adj[u].pb(v);
adj[v].pb(u);
}
f(i,0,n){
if(!vis[i]) dfs(i);
}
}
void print_bridges(){
for(auto it : ans){
cout<<it.fs<<" "<<it.sc<<"\n";
}
}
int main(){
fastio;
timer = 0;
ll n,m;cin>>n>>m;
init_bridges(n,m);
print_bridges();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
17 ms |
23804 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
21 ms |
24664 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
173 ms |
41152 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
266 ms |
47444 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
490 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
704 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
695 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
730 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
753 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
637 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |