Submission #290624

# Submission time Handle Problem Language Result Execution time Memory
290624 2020-09-04T08:13:46 Z davooddkareshki Pipes (CEOI15_pipes) C++17
10 / 100
2516 ms 65540 KB
#include<bits/stdc++.h>

using namespace std;

//#define int long long
#define F first
#define S second
#define pii pair<int,int>
#define mpr make_pair

typedef long long ll;

const int maxn = 1e5+10;
const int mod = 1e9+7;
const ll inf = 1e9+10;

int n, m;
vector<int> g[maxn];
bitset<maxn> mark;
int h[maxn], lo[maxn], Root;
vector<pii> ans;

void dfs(int v, int p = -1)
{
	mark[v] = 1;
	lo[v] = inf;

	for(auto u : g[v]) if(mark[u] && u != p) lo[v] = min(lo[v],h[u]);
	for(auto u : g[v])
		if(!mark[u])
		{
			h[u] = h[v] + 1;
			dfs(u,v);
			lo[v] = min(lo[v], lo[u]);
		}
	if(v != Root && lo[v] >= h[v]) ans.push_back({v,p});
}

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

	cin>> n >> m;
	for(int i = 1, u, v; i <= m; i++)
	{
		cin>> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	for(int i = 1; i <= n; i++)
		if(!mark[i]) {Root = i; dfs(i);}

	for(auto e : ans) cout<< e.F <<" "<< e.S <<"\n";
}
/*
10 11
1 7
1 8
1 6
2 8
6 7
5 8
2 5
2 3
2 4
3 4
10 9
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Incorrect 2 ms 2688 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3328 KB Output is correct
2 Incorrect 6 ms 3072 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 139 ms 16280 KB Output is correct
2 Correct 136 ms 15480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 279 ms 23832 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 537 ms 41208 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 899 ms 51192 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1447 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1951 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2385 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2516 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -