Submission #876854

# Submission time Handle Problem Language Result Execution time Memory
876854 2023-11-22T12:38:51 Z Hacv16 Pipes (CEOI15_pipes) C++17
10 / 100
306 ms 43092 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX = 2e4 + 15;
const int INF = 0x3f3f3f3f;

int n, m, pre[MAX], low[MAX], seen[MAX], timer;
vector<int> adj[MAX];
vector<pair<int, int>> bridges;

void dfs(int u, int p)
{
    seen[u] = true;
    pre[u] = low[u] = ++timer;

    for(auto v : adj[u])
    {
        if(v == p) continue;

        if(!seen[v])
        {
            dfs(v, u);
            low[u] = min(low[u], low[v]);
        }else{
            low[u] = min(low[u], pre[v]);
        }

        if(low[v] > pre[u]) bridges.emplace_back(u, v);
    }
}

int32_t main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;

    while(m--)
    {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(1, 1);

    for(int i = 1; i <= n; i++)
        if(!seen[i]) dfs(i, i);

    for(auto [u, v] : bridges)
        cout << u << ' ' << v << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 860 KB Output is correct
2 Incorrect 1 ms 860 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1368 KB Output is correct
2 Incorrect 4 ms 1116 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 102 ms 9040 KB Output is correct
2 Correct 75 ms 8412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 12584 KB Output is correct
2 Runtime error 169 ms 16724 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 306 ms 43092 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1368 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1372 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1368 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1368 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1372 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -