Submission #731327

# Submission time Handle Problem Language Result Execution time Memory
731327 2023-04-27T10:14:53 Z esomer Pipes (CEOI15_pipes) C++17
10 / 100
2239 ms 65536 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"

typedef long long int ll;
 
const int MOD = 1e9 + 7;

vector<pair<int, int>> pipes;
int cnt = 1;

void DFS(int x, vector<vector<int>>& adj, vector<int>& vis, vector<int>& mn, int p){
	vis[x] = cnt; mn[x] = cnt; cnt++;
	for(int node : adj[x]){
		if(node == p) continue;
		if(vis[node] > 0){
			mn[x] = min(mn[x], vis[node]);
		}else{
			DFS(node, adj, vis, mn, x);
			mn[x] = min(mn[x], mn[node]);
			if(mn[node] > vis[x]){
				pipes.push_back({node, x});
			}
		}
	}
}

void solve(){
	int n, m; cin >> n >> m;
	vector<vector<int>> adj(n);
	for(int i = 0; i < m; i++){
		int u, v; cin >> u >> v; u--; v--;
		adj[u].push_back(v); adj[v].push_back(u);
	}
	vector<int> vis(n, 0);
	vector<int> mn(n, 0);
	for(int i = 0; i < n; i++){
		if(!vis[i]){
			DFS(i, adj, vis, mn, -1);
		}
	}
	for(auto p : pipes) cout << p.first + 1 << " " << p.second + 1 << endl;
}

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

    //~ int tt; cin >> tt;
    int tt = 1;
    for(int t = 1; t <= tt; t++){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 316 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1108 KB Output is correct
2 Incorrect 5 ms 796 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 177 ms 14064 KB Output is correct
2 Correct 114 ms 13316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 240 ms 21980 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 490 ms 39956 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 834 ms 52360 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1642 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1687 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1994 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2239 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -