Submission #527259

# Submission time Handle Problem Language Result Execution time Memory
527259 2022-02-17T04:23:54 Z joelau Pipes (CEOI15_pipes) C++14
20 / 100
1006 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;

int N,M, depth[100005], low[100005], p[100005];
vector<int> lst[100005];
bitset<100005> visited;
map< pair<int,int>, int> mp;

void dfs (int u, int d) {
    visited[u] = 1, depth[u] = d, low[u] = d;
    int num = 0;
    for (int v: lst[u]) {
        if (!visited[v]) {
            p[v] = u, num++;
            dfs(v,d+1);
            if (low[v] > depth[u] && mp[make_pair(min(u,v),max(u,v))] == 1) cout << u+1 << ' ' << v+1 << '\n';
            low[u] = min(low[u],low[v]);
        }
        else if (v != p[u])
            low[u] = min(low[u],depth[v]);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int u,v; cin>> u >> v; u--, v--;
        lst[u].push_back(v), lst[v].push_back(u);
        mp[make_pair(min(u,v),max(u,v))]++;
    }
    for (int i = 0; i < N; ++i) if (!visited[i]) dfs(i,0);

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3952 KB Output is correct
2 Correct 7 ms 3672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 689 ms 46204 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 931 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 905 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 990 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 981 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1006 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 993 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 980 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -