Submission #1084678

# Submission time Handle Problem Language Result Execution time Memory
1084678 2024-09-06T16:40:11 Z SulA Pipes (CEOI15_pipes) C++17
10 / 100
1033 ms 65536 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
using namespace std;
using namespace __gnu_pbds;
#define bitcount __builtin_popcountll
 
vector<int> adj[100000];
vector<pair<int,int>> bridges;
int dep[100000], low[100000];
 
void dfs(int u, int p) {
    low[u] = dep[u] = dep[p] + 1;
    for (int ch : adj[u]) {
        if (ch == p) continue;
        if (dep[ch] == 0) { // tree edge
            dfs(ch, u);
            low[u] = min(low[u], low[ch]);
        } else { // back edge
            low[u] = min(low[u], dep[ch]);
        }
    }
 
    if (low[u] == dep[u] && u != p) {
        bridges.emplace_back(u+1, p+1);
    }
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 
    int n,m; cin >> n >> m;
    while (m--) {
        int a,b; cin >> a >> b;
        adj[--a].push_back(--b);
        adj[b].push_back(a);
    }
    for (int i = 0; i < n; i++) if (dep[i] == 0) {
        dfs(i, i);
    }
 
    for (auto [a, b] : bridges) {
        cout << a << " " << b << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Incorrect 1 ms 2652 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3164 KB Output is correct
2 Incorrect 4 ms 3164 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 10832 KB Output is correct
2 Correct 78 ms 14676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 14164 KB Output is correct
2 Runtime error 166 ms 30028 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 228 ms 24912 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 334 ms 30196 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 564 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 936 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 907 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1033 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -