Submission #527184

# Submission time Handle Problem Language Result Execution time Memory
527184 2022-02-17T03:21:41 Z ecxx Pipes (CEOI15_pipes) C++17
30 / 100
3450 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;

template <typename T> class vec {

    T* arr;

public:

    int cap;
    int cur;

    vec() {
        arr = new T[1];
        cap = 1;
        cur = 0;
    }

    void push(T data) {
        if (cur==cap) {
            T* temp = new T[2*cap];
            for (int i = 0; i < cur; i++) {
                temp[i] = arr[i];
            }
            delete[] arr;
            cap*=2;
            arr=temp;
        }

        arr[cur] = data;
        cur++;
    }

    T get(int index) {
        return arr[index];
    }

};
    
int N;
const int MAXN = 100005;
int depth[MAXN] = {0};
int low[MAXN] = {0};
vec<int> AL[MAXN];
void AP(int i, int d, int pa) {
    depth[i] = d; low[i] = d;
    int paedges = 0, ch;
    for (int k = 0; k < AL[i].cur; k++) {
        ch = AL[i].get(k);
        if (ch==pa) {
            paedges++;
            continue;
        }
        if (depth[ch] > -1) {
            low[i] = min(low[i], depth[ch]);
        } else {
            AP(ch, d+1, i);
            low[i] = min(low[i], low[ch]);
        }
    }
    if (pa==-1) return;
    if (low[i] > depth[pa] && paedges == 1) {
        cout << i+1 << " " << pa+1 << "\n";
    }
}
    
int main() {
    
    int N, M, a, b; cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a >> b; a--;b--;
        AL[a].push(b); AL[b].push(a);
    }

    for (int i = 0; i < N; i++) {
        depth[i] = -1;
    }
    
    for (int i = 0; i < N; i++) {
        if (depth[i] == -1)  AP(i,0,-1);
    }
    
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 5276 KB Output is correct
2 Correct 10 ms 5092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 12972 KB Output is correct
2 Correct 284 ms 12368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 517 ms 16452 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 814 ms 26636 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1286 ms 30324 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1851 ms 51760 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2570 ms 64836 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3055 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3450 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -