# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
503899 |
2022-01-09T06:51:25 Z |
CraniXort |
Pipes (CEOI15_pipes) |
C++17 |
|
3191 ms |
57884 KB |
#include <bits/stdc++.h>
#define maxn 100005
#define fin std::cin
#define fout std::cout
// std::ifstream fin("pipes.in");
// std::ofstream fout("pipes.out");
std::vector <int> edge[maxn];
int disc[maxn], low[maxn], timer;
bool visited[maxn];
void dfs(int node, int parent) {
visited[node] = true;
disc[node] = low[node] = ++timer;
bool ok = false;
for(auto next: edge[node]) {
if(next == parent and ok == false) {
ok = true;
continue;
}
if(visited[next] == false) {
dfs(next, node);
low[node] = std::min(low[node], low[next]);
if(low[next] > disc[node]) {
fout << node << ' ' << next << '\n';
}
}
else{
low[node] = std::min(low[node], disc[next]);
}
}
}
class DSU {
int size;
std::vector <int> rank, parent;
public:
DSU(int size): size(size) {
rank.resize(size+1);
parent.resize(size+1);
for(int i = 1; i <= size; i ++)
parent[i] = i;
}
int findRoot(int node) {
if(parent[node] == node)
return node;
return (parent[node] = findRoot(parent[node]));
}
void combine(int node1, int node2) {
node1 = findRoot(node1);
node2 = findRoot(node2);
if(node1 == node2)
return;
if(rank[node1] < rank[node2])
std::swap(node1, node2);
parent[node2] = node1;
if(rank[node1] == rank[node2])
rank[node1] ++;
}
};
int main() {
// std::ios_base::sync_with_stdio(false);
// std::cin.tie(NULL);
// std::cout.tie(NULL);
int V, E;
fin >> V >> E;
DSU first(V), second(V);
for(int i = 0, src, dest; i < E; i ++) {
fin >> src >> dest;
if(first.findRoot(src) == first.findRoot(dest)) {
edge[src].push_back(dest);
edge[dest].push_back(src);
first.combine(src, dest);
}
else if(second.findRoot(src) == second.findRoot(dest)) {
edge[src].push_back(dest);
edge[dest].push_back(src);
second.combine(src, dest);
}
}
for(int i = 1; i <= V; i ++)
if(visited[i] == false)
dfs(i, -1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2636 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2636 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
256 ms |
2684 KB |
Output is correct |
2 |
Incorrect |
265 ms |
2676 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
439 ms |
2772 KB |
Output is correct |
2 |
Incorrect |
539 ms |
2776 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
745 ms |
3120 KB |
Output is correct |
2 |
Incorrect |
604 ms |
3340 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
910 ms |
4236 KB |
Output is correct |
2 |
Incorrect |
784 ms |
4244 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1530 ms |
4548 KB |
Output is correct |
2 |
Incorrect |
1487 ms |
5168 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1900 ms |
4960 KB |
Output is correct |
2 |
Runtime error |
1808 ms |
46384 KB |
Memory limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2621 ms |
4956 KB |
Output is correct |
2 |
Runtime error |
2522 ms |
57884 KB |
Memory limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3191 ms |
4880 KB |
Output is correct |
2 |
Runtime error |
2990 ms |
18056 KB |
Memory limit exceeded |