# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
476059 |
2021-09-24T17:01:20 Z |
blue |
Pipes (CEOI15_pipes) |
C++17 |
|
5000 ms |
48816 KB |
#include <iostream>
#include <vector>
using namespace std;
struct disjoint_set
{
int N;
vector<int> parent;
vector<int> subtree;
int cc;
disjoint_set()
{
;
}
disjoint_set(int N_)
{
N = N_;
cc = N;
parent = vector<int>(1+N);
subtree = vector<int>(1+N, 1);
for(int i = 1; i <= N; i++) parent[i] = i;
}
int root(int u)
{
int v = u;
while(parent[v] != v) v = parent[v];
parent[u] = v;
return parent[u];
}
bool connected(int u, int v)
{
return root(u) == root(v);
}
void join(int u, int v)
{
u = root(u);
v = root(v);
if(u == v) return;
if(subtree[u] < subtree[v]) swap(u, v);
parent[v] = u;
subtree[u] += subtree[v];
cc--;
}
};
int main()
{
int N, M;
cin >> N >> M;
int u[M+1], v[M+1];
for(int j = 1; j <= M; j++) cin >> u[j] >> v[j];
disjoint_set basic(N);
for(int j = 1; j <= M; j++)
basic.join(u[j],v[j]);
for(int k = 1; k <= M; k++)
{
disjoint_set nw(N);
for(int j = 1; j <= M; j++)
{
if(j == k) continue;
nw.join(u[j], v[j]);
}
if(basic.cc != nw.cc)
{
cout << u[k] << ' ' << v[k] << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1495 ms |
420 KB |
Output is correct |
2 |
Correct |
1749 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5062 ms |
4956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5050 ms |
8276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5063 ms |
12564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5057 ms |
15824 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5057 ms |
24576 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5022 ms |
32016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5037 ms |
39648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5045 ms |
48816 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |