Submission #958997

# Submission time Handle Problem Language Result Execution time Memory
958997 2024-04-07T11:11:34 Z Cyber_Wolf Pipes (CEOI15_pipes) C++17
10 / 100
1294 ms 65536 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define lg int
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
const lg N = 1e5+5;
 
vector<lg> adj[N];
lg n,m, low[N], tin[N], tmp, id;
set<array<lg, 2>> se;
 
void dfs(lg src, lg par = -1)
{
	tin[src] = low[src] = ++tmp;
	for(auto it : adj[src])
	{
		if(it == par)
		{
			continue;
		}
		if(tin[it])
		{
			if(low[it] > tin[src])
			{
				if(se.find({src, it}) != se.end())	se.erase({src, it});
			}
			low[src] = min(low[src], tin[it]);
			continue;
		}
		dfs(it, src);
		low[src] = min(low[src], low[it]);
		if(low[it] > tin[src])
		{
			se.insert({src, it});
		}
	}
	while(se.size())
	{
		auto it = se.lower_bound({src, -1});
		if(it == se.end())	break;
		if((*it)[0] != src)	break;
		cout << (*it)[0] << ' ' << (*it)[1] << '\n';
		se.erase(it);
	}	
	se.clear();
	// cout << src << ' ' << low[src] << '\n';
}
 
int main()
{
	fastio;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		lg u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i = 1; i <= n; i++)
	{
		if(!tin[i])	dfs(i);
	}
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 3420 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4188 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 81 ms 16360 KB Output is correct
2 Correct 86 ms 15072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 153 ms 23200 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 306 ms 39848 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 471 ms 51388 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 804 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1049 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1259 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1294 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -