# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
97603 |
2019-02-17T12:22:43 Z |
dalgerok |
Pipes (CEOI15_pipes) |
C++17 |
|
1408 ms |
14036 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
int p[2][N];
int tin[N], fup[N], timer;
vector < int > g[N];
int dsu_get(int x, int v){
return p[x][v] == v ? v : p[x][v] = dsu_get(x, p[x][v]);
}
void dfs(int v, int pr = 0){
tin[v] = fup[v] = ++timer;
bool was = false;
for(int i = 0; i < (int)g[v].size(); i++){
int to = g[v][i];
if(to == pr){
if(was){
fup[v] = min(fup[v], tin[to]);
}
was = true;
continue;
}
if(!tin[to]){
dfs(to, v);
if(fup[to] > tin[v]){
cout << v << " " << to << "\n";
}
fup[v] = min(fup[v], fup[to]);
}
else{
fup[v] = min(fup[v], tin[to]);
}
}
timer -= 1;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++){
p[0][i] = p[1][i] = i;
}
for(int i = 1; i <= m; i++){
int x, y;
cin >> x >> y;
if(dsu_get(0, x) == dsu_get(0, y)){
if(dsu_get(1, x) == dsu_get(1, y)){
continue;
}
p[1][dsu_get(1, x)] = dsu_get(1, y);
}
else{
p[0][dsu_get(0, x)] = dsu_get(0, y);
}
g[x].push_back(y);
g[y].push_back(x);
}
for(int i = 1; i <= n; i++){
if(!tin[i]){
dfs(i);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
3 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3200 KB |
Output is correct |
2 |
Correct |
7 ms |
2944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
3064 KB |
Output is correct |
2 |
Correct |
97 ms |
2936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
3832 KB |
Output is correct |
2 |
Correct |
191 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
301 ms |
5496 KB |
Output is correct |
2 |
Correct |
248 ms |
5112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
447 ms |
10592 KB |
Output is correct |
2 |
Correct |
475 ms |
7124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
657 ms |
11888 KB |
Output is correct |
2 |
Correct |
639 ms |
8996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
934 ms |
14036 KB |
Output is correct |
2 |
Correct |
881 ms |
9140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1098 ms |
13992 KB |
Output is correct |
2 |
Correct |
1070 ms |
9076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1408 ms |
13416 KB |
Output is correct |
2 |
Correct |
1226 ms |
10616 KB |
Output is correct |