Submission #948533

# Submission time Handle Problem Language Result Execution time Memory
948533 2024-03-18T07:44:22 Z vjudge1 Pipes (CEOI15_pipes) C++17
20 / 100
87 ms 16392 KB
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std;
using namespace __gnu_pbds; 

#define ff first
#define ss second
#define rep(i,s,f) for(int i = s;i < f;i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 

const int N = 5000;

int binpow(int n,int k){	
	if(k == 0){
		return 1 ;
	} else if(k % 2 == 0){
		int b = binpow(n,k / 2);
		return b * b ;
	} else{
		return n * binpow(n,k - 1) ;
	}

}

int timer;
vector<pair<int,int>> g[N];
vector<bool> vis(N);
vector<int> tin(N),low(N);

void dfs(int v, int p) {
    vis[v] = true;
    tin[v] = low[v] = timer++;
    for (auto [to,check] : g[v]) {
        if (check == p) continue;
        if (vis[to]) {
            low[v] = min(low[v], tin[to]);
        } else {
            dfs(to, check);
            low[v] = min(low[v], low[to]);
            if (low[to] > tin[v])
				cout << v << " " << to << "\n";
        }
    }
}

void solve(){
	
	int n;
	cin >> n;
	int m;
	cin >> m;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b;
		g[a].pb({b,i});
		g[b].pb({a,i});
	}
	for(int i = 0;i < n;i++){
		if(!vis[i]){
			dfs(i,-1);
		}
	}
	
}

signed main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	
	int t = 1;
	//~ cin >> t;
	while(t--){
		solve();
	}
	
}
	
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 3 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 87 ms 16392 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -