Submission #364815

# Submission time Handle Problem Language Result Execution time Memory
364815 2021-02-10T07:18:49 Z knightron0 Pipes (CEOI15_pipes) C++14
10 / 100
316 ms 21888 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e4 + 5;

vector<int> adj[MAXN];
bool vis[MAXN];
int timer = 0;
int tin[MAXN], low[MAXN];

void dfs(int u, int p){
	vis[u] = true;
	timer++;
	tin[u] = low[u] = timer;
	for(int v: adj[u]){
		if(v == p) continue;
		if(vis[v]){
			low[u] = min(low[u], tin[v]);
		} else {
			dfs(v, u);
			low[u] = min(low[u], low[v]);
			if (low[v] > tin[u]) {
				cout<<u<<' '<<v<<endl;
			}
		}
	}
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin>>n>>m;
    for(int i= 0;i<m;i++){
    	int t1, t2;
    	cin>>t1>>t2;
    	adj[t1].pb(t2);
    	adj[t2].pb(t1);
    }
    timer = 0;
    memset(low, -1, sizeof(low));
    memset(tin, -1, sizeof(tin));
    clr(vis);
    for(int i= 1;i<=n;i++){
    	if(!vis[i]){
    		dfs(i, -1);
    	}
    }
    return 0;
}



# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Incorrect 1 ms 620 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1260 KB Output is correct
2 Incorrect 5 ms 1004 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 137 ms 14444 KB Output is correct
2 Correct 131 ms 13524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 316 ms 21888 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -