# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52624 |
2018-06-26T09:51:39 Z |
Alexa2001 |
Pipes (CEOI15_pipes) |
C++17 |
|
1181 ms |
14196 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(B.boss(x) == B.boss(y)) continue; /// same bcomp
if(A.boss(x) != A.boss(y)) A.unite(x, y);
else B.unite(x, y);
v[x].push_back(y);
v[y].push_back(x);
}
for(i=1; i<=n; ++i)
{
sort(v[i].begin(), v[i].end());
v[i].erase( unique(v[i].begin(), v[i].end()), v[i].end() );
}
for(i=1; i<=n; ++i)
if(!level[i]) solve(i);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Incorrect |
3 ms |
2688 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
3200 KB |
Output is correct |
2 |
Incorrect |
7 ms |
2944 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
3040 KB |
Output is correct |
2 |
Incorrect |
99 ms |
2936 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
168 ms |
3856 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
293 ms |
5432 KB |
Output is correct |
2 |
Correct |
245 ms |
5112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
423 ms |
10720 KB |
Output is correct |
2 |
Incorrect |
354 ms |
7128 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
656 ms |
12000 KB |
Output is correct |
2 |
Incorrect |
577 ms |
9064 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
809 ms |
14196 KB |
Output is correct |
2 |
Incorrect |
773 ms |
9088 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
981 ms |
14176 KB |
Output is correct |
2 |
Incorrect |
945 ms |
9076 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1181 ms |
13544 KB |
Output is correct |
2 |
Correct |
1096 ms |
10736 KB |
Output is correct |