# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
95870 |
2019-02-03T09:24:24 Z |
Kastanda |
Pipes (CEOI15_pipes) |
C++11 |
|
2967 ms |
5312 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 100005, M = N * 2;
int n, tk, H[N], Mn[N], stk[N], par[N];
int ts, head[N], nxt[M + M];
int m, from[M], to[M];
bitset < M > tree, bridge;
bitset < N > mark, gof;
inline void AddEdge(int v, int u)
{
from[ts >> 1] = v; to[ts >> 1] = u;
nxt[ts] = head[v]; head[v] = ts;
nxt[ts|1] = head[u]; head[u] = ts|1;
ts += 2;
}
inline void DFS()
{
int v, u;
while (tk)
{
v = stk[tk];
mark[v] = 1;
Mn[v] = H[v];
if (gof[tk])
{
u = from[head[v] >> 1] ^ to[head[v] >> 1] ^ v;
Mn[v] = min(Mn[v], Mn[u]);
if (Mn[u] < H[u])
bridge[head[v] >> 1] = 0;
head[v] = nxt[head[v]];
gof[tk] = 0;
}
for (; head[v] != -1; head[v] = nxt[head[v]])
if ((head[v] >> 1) != par[tk])
{
u = from[head[v] >> 1] ^ to[head[v] >> 1] ^ v;
if (mark[u])
Mn[v] = min(Mn[v], H[u]), bridge[head[v] >> 1] = 0;
else
{
H[u] = H[v] + 1;
tree[head[v] >> 1] = 1;
gof[tk] = 1;
++ tk;
stk[tk] = u;
par[tk] = head[v] >> 1;
break;
}
}
if (head[v] == -1)
tk --;
}
}
inline void Unlaze()
{
mark = 0; tree = 0; gof = 0;
memset(H, 0, sizeof(H));
for (int i = 1; i <= n; i++)
if (!mark[i])
{
tk = 1;
stk[tk] = i;
par[tk] = -1;
DFS();
}
int cnt = 0;
for (int i = 0; i < (ts >> 1); i++)
if (tree[i])
{
bool a;
a = tree[i];
tree[i] = tree[cnt];
tree[cnt] = a;
a = bridge[i];
bridge[i] = bridge[cnt];
bridge[cnt] = a;
swap(from[i], from[cnt]);
swap(to[i], to[cnt]);
cnt ++;
}
ts = 0;
memset(nxt, -1, sizeof(nxt));
memset(head, -1, sizeof(head));
for (int i = 0; i < cnt; i++)
AddEdge(from[i], to[i]);
}
int main()
{
memset(nxt, -1, sizeof(nxt));
memset(head, -1, sizeof(head));
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++)
{
int v, u;
scanf("%d%d", &v, &u);
bridge[ts >> 1] = 1;
AddEdge(v, u);
if (ts >= M + M - 20)
Unlaze();
}
Unlaze();
for (int i = 0; i < (ts >> 1); i++)
if (bridge[i])
printf("%d %d\n", from[i], to[i]);
return 0;
}
Compilation message
pipes.cpp: In function 'int main()':
pipes.cpp:94:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
~~~~~^~~~~~~~~~~~~~~~
pipes.cpp:98:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &v, &u);
~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2688 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2816 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
156 ms |
4400 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
275 ms |
4440 KB |
Output is correct |
2 |
Incorrect |
313 ms |
4472 KB |
Wrong number of edges |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
443 ms |
4540 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
741 ms |
5032 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1404 ms |
5232 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2107 ms |
5240 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2337 ms |
5224 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2967 ms |
5312 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |