# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52615 |
2018-06-26T09:18:51 Z |
Alexa2001 |
Pipes (CEOI15_pipes) |
C++17 |
|
1285 ms |
14048 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax = 1e5 + 5;
int n, m, i, x, y;
int level[Nmax], low[Nmax];
vector<int> v[Nmax];
struct Forest
{
int t[Nmax];
void clear()
{
int i;
for(i=1; i<=n; ++i) t[i] = i;
}
int boss(int x)
{
if(t[x] == x) return x;
return t[x] = boss(t[x]);
}
void unite(int x, int y)
{
x = boss(x), y = boss(y);
t[x] = y;
}
} A, B;
void solve(int node, int dad = 0)
{
level[node] = low[node] = level[dad] + 1;
for(auto son : v[node])
{
if(son == dad) continue;
if(level[son])
{
low[node] = min(low[node], level[son]);
continue;
}
solve(son, node);
low[node] = min(low[node], low[son]);
if(low[son] == level[son])
cout << node << ' ' << son << '\n';
}
}
int main()
{
// freopen("input", "r", stdin);
// freopen("output", "w", stdout);
cin.sync_with_stdio(false);
cin >> n >> m;
A.clear(); B.clear();
while(m--)
{
cin >> x >> y;
if(A.boss(x) != A.boss(y)) A.unite(x, y);
else if(B.boss(x) != B.boss(y)) B.unite(x, y);
else continue;
v[x].push_back(y);
v[y].push_back(x);
}
for(i=1; i<=n; ++i)
if(!level[i]) solve(i);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2624 KB |
Output is correct |
2 |
Incorrect |
4 ms |
2688 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3200 KB |
Output is correct |
2 |
Incorrect |
8 ms |
2984 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
3040 KB |
Output is correct |
2 |
Incorrect |
100 ms |
2908 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
168 ms |
3848 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
303 ms |
5436 KB |
Output is correct |
2 |
Correct |
256 ms |
4984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
447 ms |
10700 KB |
Output is correct |
2 |
Incorrect |
401 ms |
7164 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
662 ms |
11876 KB |
Output is correct |
2 |
Incorrect |
633 ms |
9092 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
852 ms |
13960 KB |
Output is correct |
2 |
Incorrect |
806 ms |
9204 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1077 ms |
14048 KB |
Output is correct |
2 |
Incorrect |
978 ms |
9088 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1285 ms |
13412 KB |
Output is correct |
2 |
Correct |
1167 ms |
10728 KB |
Output is correct |