# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
580248 |
2022-06-20T19:38:31 Z |
MODDI |
Pipes (CEOI15_pipes) |
C++14 |
|
36 ms |
65536 KB |
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int n, m;
vector<int> G[100010];
vector<bool> vis;
vi tin, low;
int timer;
vector<pii> ans;
bool out[30000][30000];
void dfs(int node, int parent = -1){
vis[node] = true;
tin[node] = low[node] = timer++;
for(auto next : G[node]){
if(next == parent) continue;
if(vis[next]){
low[node] = min(low[node], tin[next]);
}
else{
dfs(next, node);
low[node] = min(low[node], low[next]);
if(low[next] > tin[node]){
ans.pb(mp(node,next));
}
}
}
}
void init(){
timer = 0;
vis.assign(n, false);
tin.assign(n, -1);
low.assign(n, -1);
for(int i = 0; i < n; i++){
if(!vis[i])
dfs(i);
}
}
int main(){
memset(out, false, sizeof(out));
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i = 0; i < m; i++){
int a, b;
cin>>a>>b;
a--; b--;
G[a].pb(b);
G[b].pb(a);
}
init();
for(int i = 0; i < (int)ans.size(); i++)
{
int a = ans[i].first, b = ans[i].second;
if(!out[a][b] && !out[b][a]){
cout<<a+1<<" "<<b+1<<endl;
out[a][b] = true;
out[b][a] = true;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
32 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
31 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
31 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
36 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
33 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |