# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169420 |
2019-12-20T09:55:42 Z |
gs18103 |
Pipes (CEOI15_pipes) |
C++14 |
|
5000 ms |
13540 KB |
#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;
vector <int> G[N];
int n, m, low[N], num[N], cnt;
struct dsu{
int pset[N];
void init(){
for (int i = 1; i <= n; i++) pset[i] = i;
}
int find(int i) {return ((pset[i] == i) ? i : pset[i] = find(pset[i]));}
bool Union(int i, int j){
int u = find(i), v = find(j);
if (u == v) return false;
pset[u] = v;
G[i].push_back(j);
G[j].push_back(i);
return true;
}
} a[2];
void dfs(int u, int p){
num[u] = low[u] = ++cnt; bool ck = false;
for (auto v : G[u]){
if (v == p && !ck) {ck = true; continue;}
if (num[v]){
low[u] = min(low[u], num[v]);
}
else{
dfs(v, u);
low[u] = min(low[u], low[v]);
}
}
if (u != p && low[u] >= num[u]) cout << u << " " << p << "\n";
}
int main(){
cin >> n >> m;
a[0].init(); a[1].init();
for (int i = 1; i <= m; i++){
int u, v; cin >> u >> v;
if (!a[0].Union(u, v)) a[1].Union(u, v);
}
for (int i = 1; i <= n; i++) if (!num[i]) dfs(i, i);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
3320 KB |
Output is correct |
2 |
Correct |
17 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
505 ms |
3180 KB |
Output is correct |
2 |
Correct |
492 ms |
3276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
892 ms |
4088 KB |
Output is correct |
2 |
Correct |
1030 ms |
3804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1435 ms |
5528 KB |
Output is correct |
2 |
Correct |
1316 ms |
5264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1901 ms |
10284 KB |
Output is correct |
2 |
Correct |
1694 ms |
7384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3162 ms |
11184 KB |
Output is correct |
2 |
Correct |
2955 ms |
8884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3997 ms |
13140 KB |
Output is correct |
2 |
Correct |
3798 ms |
9216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5030 ms |
13540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5005 ms |
7636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |