# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169419 |
2019-12-20T09:54:52 Z |
gs18103 |
Pipes (CEOI15_pipes) |
C++ |
|
1565 ms |
24680 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define em emplace
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int MAX = 100010;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
struct UFT {
int p[MAX];
UFT(int n) {
for(int i = 1; i <= n; i++) p[i] = i;
}
int find(int x) {
return p[x] == x ? p[x] : p[x] = find(p[x]);
}
void uni(int x, int y) {
p[find(x)] = find(y);
}
};
vector <int> g[MAX];
int low[MAX], ord[MAX], pa[MAX], cnt = 0;
void dfs(int x) {
ord[x] = low[x] = ++cnt;
bool was = false;
for(auto i : g[x]) {
if(i == pa[x] && !was) {
was = true;
continue;
}
if(ord[i] == 0) {
pa[i] = x;
dfs(i);
low[x] = min(low[x], low[i]);
if(low[i] > ord[x]) cout << x << ' ' << i << '\n';
}
else if(ord[i] < ord[x]) {
low[x] = min(low[x], ord[i]);
}
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int n, m;
cin >> n >> m;
UFT t1(n), t2(n);
for(int i = 1; i <= m; i++) {
int u, v; cin >> u >> v;
if(t1.find(u) != t1.find(v)) {
t1.uni(u, v);
g[u].eb(v), g[v].eb(u);
}
else if(t2.find(u) != t2.find(v)) {
t2.uni(u, v);
g[u].eb(v), g[v].eb(u);
}
}
for(int i = 1; i <= n; i++) {
if(ord[i] == 0) dfs(i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
3320 KB |
Output is correct |
2 |
Correct |
8 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
132 ms |
6520 KB |
Output is correct |
2 |
Correct |
127 ms |
6108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
214 ms |
6136 KB |
Output is correct |
2 |
Correct |
251 ms |
5508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
369 ms |
7676 KB |
Output is correct |
2 |
Correct |
311 ms |
5880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
537 ms |
12508 KB |
Output is correct |
2 |
Correct |
476 ms |
8844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
789 ms |
12664 KB |
Output is correct |
2 |
Correct |
740 ms |
9764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1046 ms |
15212 KB |
Output is correct |
2 |
Correct |
986 ms |
9948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1276 ms |
18016 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1565 ms |
15880 KB |
Output is correct |
2 |
Runtime error |
1487 ms |
24680 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |