Submission #872927

# Submission time Handle Problem Language Result Execution time Memory
872927 2023-11-14T05:16:21 Z Ghulam_Junaid Pipes (CEOI15_pipes) C++17
20 / 100
5000 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
int n, m;
vector<pair<int, int>> edges, g[N];
bool vis[N];

void dfs(int v, int id){
    vis[v] = 1;
    for (auto [u, x] : g[v]){
        if (x == id or vis[u])
            continue;

        dfs(u, id);
    }
}

int main(){
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++){
        int u, v; 
        cin >> u >> v;

        g[u].push_back({v, i});
        g[v].push_back({u, i});
        edges.push_back({u, v});
    }

    int orig = 0;
    for (int v = 1; v <= n; v++){
        if (!vis[v]){
            orig++;
            dfs(v, m);
        }
    }

    for (int i=0; i<m; i++){
        int cc = 0;
        for (int v = 1; v <= n; v++)
            vis[v] = 0;

        for (int v = 1; v <= n; v++){
            if (!vis[v]){
                cc++;
                dfs(v, i);
            }
        }

        if (cc != orig)
            cout << edges[i].first << " " << edges[i].second << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1583 ms 3472 KB Output is correct
2 Correct 1484 ms 3316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5031 ms 32696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5086 ms 42156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5022 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5062 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1034 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 936 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 964 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 946 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -