Submission #1022059

# Submission time Handle Problem Language Result Execution time Memory
1022059 2024-07-13T09:30:57 Z vjudge1 Pipes (CEOI15_pipes) C++17
0 / 100
808 ms 65536 KB
#include <bits/stdc++.h>

#define ll long long
using namespace std;
const  int N = 1e5 + 2;
set < int > adj[N + 2];
int low[N + 2] , num[N + 2] , timer;
void dfs(int u){
    low[u] = num[u] = ++timer;
    for(int v:adj[u]){
        if(!num[v]){
            adj[v].erase(u);
            dfs(v);
            low[u] = min(low[u] , low[v]);
            if(low[v] == num[v]) cout << u << " " << v <<'\n';
        }
        else{
            low[u] = min(low[u] , num[v]);
            adj[v].erase(u);
        } 

    }
}
void solve() {
    int n, m;
    cin >> n >> m;
    for(int i  = 1; i <= m ; i++){
        int u , v;
        cin >> u >> v;
        adj[u].insert(v);
        adj[v].insert(u);
    }
    for(int i = 1; i <= n ;i ++){
        if(!num[i]) dfs(i );
    }
    
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    #define _ "maxseq."
    if (fopen(_ "inp", "r")) {
        freopen(_ "inp", "r", stdin);
        freopen(_ "out", "w", stdout);
    }
    
    solve();
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         freopen(_ "inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
pipes.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         freopen(_ "out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Incorrect 2 ms 4956 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6492 KB Output is correct
2 Incorrect 6 ms 6236 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 808 ms 64336 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 739 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 546 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 548 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 488 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 598 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 511 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 535 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -