Submission #851481

# Submission time Handle Problem Language Result Execution time Memory
851481 2023-09-20T00:19:01 Z Nhoksocqt1 Pipes (CEOI15_pipes) C++17
0 / 100
657 ms 65536 KB
#include<bits/stdc++.h>
using namespace std;

#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;

template<class X, class Y>
	inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
	inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int MAXN = 100005;
const int MAXM = 6000006;

struct Edge {
    int u, v, id;
} edge[MAXM];

vector<ii> bridges;
vector<int> adj[MAXN];
int low[MAXN], num[MAXN], numNode, numEdge;
bool dx[MAXM];

stack<int> st;
void dfs(int u, int p) {
    low[u] = num[u] = ++num[0];
    st.push(u);

    for (int it = 0; it < sz(adj[u]); ++it) {
        int id(adj[u][it]), v(edge[id].u ^ edge[id].v ^ u);
        if(!dx[id]) {
            dx[id] = 1;
            if(!num[v]) {
                dfs(v, u);
                low[u] = min(low[u], low[v]);
                if(low[v] >= num[v])
                    bridges.push_back({u, v});
            } else
                if(v != p) {
                    low[u] = min(low[u], num[v]);
                }
        }
    }
}

void process() {
    cin >> numNode >> numEdge;
    for (int i = 0; i < numEdge; ++i) {
        int u, v;
        cin >> u >> v;
        edge[i] = {u, v, i};
        adj[u].push_back(i);
        adj[v].push_back(i);
    }

    for (int i = 1; i <= numNode; ++i) {
        if(!num[i])
            dfs(i, -1);
    }

    for (int it = 0; it < sz(bridges); ++it)
        cout << bridges[it].fi << ' ' << bridges[it].se << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    process();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Incorrect 1 ms 6492 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7260 KB Output is correct
2 Incorrect 4 ms 7004 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 94 ms 27224 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 209 ms 41308 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 317 ms 63540 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 549 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 567 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 637 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 657 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 607 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -