# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
100617 |
2019-03-12T21:09:18 Z |
doowey |
Pipes (CEOI15_pipes) |
C++14 |
|
1125 ms |
11860 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = (int)1e5 + 9;
struct DSU{
int pi[N];
void Init(){
for(int i = 0 ; i < N; i ++ )
pi[i] = i;
}
int fin(int node){
if(node == pi[node])
return node;
return pi[node] = fin(pi[node]);
}
bool unite(int a, int b){
a = fin(a);
b = fin(b);
if(a==b)
return false;
pi[a] = b;
return true;
}
};
DSU A, B;
// all this memory bullsh*t
int nod[N * 4];
int prv[N * 4];
int tin[N];
int las[N];
int p;
void init(){
for(int i =0 ; i < N; i ++ )
las[i] = -1, tin[i] = -1;
for(int i = 0 ;i < N * 4 ;i ++ )
prv[i] = -1, nod[i] = -1;
}
void addedg(int a, int b){
prv[p] = las[a];
nod[p] = b;
las[a] = p;
p ++ ;
}
void EDGE(int a, int b){
addedg(a, b);
addedg(b, a);
}
int low[N];
int timer;
void dfs(int node, int par){
tin[node] = timer ++ ;
low[node] = tin[node];
for(int i = las[node]; i != -1; i = prv[i]){
if(nod[i] == par)
continue;
if(tin[nod[i]] != -1){
low[node] = min(low[node], tin[nod[i]]);
}
else{
dfs(nod[i], node);
low[node] = min(low[node], low[nod[i]]);
if(tin[node] < low[nod[i]] && B.fin(nod[i]) != B.fin(node)){
cout << node << " " << nod[i] << "\n";
}
}
}
}
int main(){
fastIO;
init();
A.Init();
B.Init();
int n, m;
cin >> n >> m;
int u, v;
for(int i =0 ; i < m ; i ++ ){
cin >> u >> v;
if(A.unite(u,v)){
EDGE(u,v);
}
else if(B.unite(u, v)){
EDGE(u,v);
}
}
dfs(1,-1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4992 KB |
Output is correct |
2 |
Correct |
6 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
5376 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
5208 KB |
Output is correct |
2 |
Correct |
94 ms |
5116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
157 ms |
5720 KB |
Output is correct |
2 |
Correct |
182 ms |
5112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
6620 KB |
Output is correct |
2 |
Correct |
228 ms |
6136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
376 ms |
9820 KB |
Output is correct |
2 |
Correct |
324 ms |
6008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
562 ms |
10576 KB |
Output is correct |
2 |
Correct |
553 ms |
7928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
736 ms |
11860 KB |
Output is correct |
2 |
Correct |
696 ms |
6360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
922 ms |
11860 KB |
Output is correct |
2 |
Correct |
867 ms |
6364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1125 ms |
11484 KB |
Output is correct |
2 |
Correct |
1066 ms |
8664 KB |
Output is correct |