Submission #958985

# Submission time Handle Problem Language Result Execution time Memory
958985 2024-04-07T10:51:49 Z Cyber_Wolf Pipes (CEOI15_pipes) C++17
10 / 100
1354 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;
vector<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])
		{
			low[src] = min(low[src], tin[it]);
			continue;
		}
		dfs(it, src);
		low[src] = min(low[src], low[it]);
	}
	if((~par) && low[src] > tin[par])
	{
		se.push_back({min(par, src), max(par, src)});
	}
	// 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);
	}
	sort(se.begin(), se.end());
	for(int i = 0; i < se.size(); i++)
	{
		if(i && se[i] == se[i-1])	continue;
		if(i+1 < se.size() && se[i] == se[i+1])	continue;
		cout << se[i][0] << ' ' << se[i][1] << '\n';
	}

    return 0;
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for(int i = 0; i < se.size(); i++)
      |                 ~~^~~~~~~~~~~
pipes.cpp:57:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   if(i+1 < se.size() && se[i] == se[i+1]) continue;
      |      ~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3160 KB Output is correct
2 Incorrect 1 ms 3160 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3932 KB Output is correct
2 Incorrect 3 ms 3672 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 92 ms 11344 KB Output is correct
2 Correct 75 ms 10692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 136 ms 14928 KB Output is correct
2 Runtime error 174 ms 19132 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 295 ms 25872 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 440 ms 31624 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 705 ms 62704 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 960 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1191 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1354 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -