# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
680456 |
2023-01-10T22:07:25 Z |
danikoynov |
Pipes (CEOI15_pipes) |
C++14 |
|
1239 ms |
56760 KB |
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 1e5 + 10;
struct edge
{
int v, u;
edge(int _v, int _u)
{
v = _v;
u = _u;
}
};
int n, m;
int par1[maxn], par2[maxn];
int find_leader1(int v)
{
if (v == par1[v])
return v;
return (par1[v] = find_leader1(par1[v]));
}
bool connected1(int v, int u)
{
v = find_leader1(v);
u = find_leader1(u);
if (v == u)
return true;
par1[u] = v;
return false;
}
int find_leader2(int v)
{
if (v == par2[v])
return v;
return (par2[v] = find_leader2(par2[v]));
}
bool connected2(int v, int u)
{
v = find_leader2(v);
u = find_leader2(u);
if (v == u)
return true;
par2[u] = v;
return false;
}
vector < int > g[maxn];
int tin[maxn], low[maxn], timer;
void dfs(int v, int p)
{
tin[v] = low[v] = ++ timer;
///cout << v << " : " << p << " " << g[v].size() << endl;
for (int u : g[v])
{
if (u == p)
continue;
if (tin[u] != 0)
{
low[v] = min(low[v], tin[u]);
}
else
{
dfs(u, v);
if (low[u] > tin[v])
cout << v << " " << u << endl;
low[v] = min(low[v], low[u]);
}
}
}
void solve()
{
cin >> n >> m;
int v, u;
for (int i = 1; i <= n; i ++)
par1[i] = i, par2[i] = i;
vector < edge > ed;
for (int i = 1; i <= m; i ++)
{
cin >> v >> u;
if (connected1(v, u))
{
if (!connected2(v, u))
ed.push_back(edge(v, u));
}
else
{
ed.push_back(edge(v, u));
}
}
for (edge cur : ed)
{
g[cur.v].push_back(cur.u);
g[cur.u].push_back(cur.v);
//cout << cur.v << " " << cur.u << " : " << endl;
// cout << g[7].size() << endl;
}
for (int i = 1; i <= n; i ++)
if (tin[i] == 0)
dfs(i, 0);
}
int main()
{
speed();
solve();
return 0;
}
Compilation message
pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:89:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
89 | if (low[u] > tin[v])
| ^~
pipes.cpp:91:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
91 | low[v] = min(low[v], low[u]);
| ^~~
pipes.cpp: In function 'void solve()':
pipes.cpp:99:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
99 | for (int i = 1; i <= n; i ++)
| ^~~
pipes.cpp:101:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
101 | vector < edge > ed;
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2644 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
3284 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3048 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
8516 KB |
Output is correct |
2 |
Incorrect |
97 ms |
8292 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
195 ms |
13496 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
336 ms |
21984 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
341 ms |
33164 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
654 ms |
29724 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
782 ms |
37232 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
962 ms |
44124 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1239 ms |
56760 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |