Submission #959007

# Submission time Handle Problem Language Result Execution time Memory
959007 2024-04-07T11:20:34 Z Cyber_Wolf Pipes (CEOI15_pipes) C++17
20 / 100
1745 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;
	int idx = 0;
	for(auto it : adj[src])
	{
		if(it == par)
		{
			idx++;	
			continue;
		}
		if(tin[it])
		{
			low[src] = min(low[src], tin[it]);
			idx++;	
			continue;
		}
		dfs(it, src);
		low[src] = min(low[src], low[it]);
		if(idx && adj[src][idx-1] == it)	continue;
		if(idx+1 < adj[src].size() && adj[src][idx+1] == it)	continue;
		if(low[it] > tin[src])
		{
			cout << src << ' ' << it << '\n';
		}
		idx++;	
	}
}
 
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++)	sort(adj[i].begin(), adj[i].end());
	for(int i = 1; i <= n; i++)
	{
		if(!tin[i])	dfs(i);
	}
 
    return 0;
}

Compilation message

pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:34:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   if(idx+1 < adj[src].size() && adj[src][idx+1] == it) continue;
      |      ~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Incorrect 1 ms 3420 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3928 KB Output is correct
2 Correct 4 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 142 ms 14740 KB Output is correct
2 Correct 120 ms 13956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 228 ms 20492 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 474 ms 34904 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 593 ms 44008 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 944 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1319 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1745 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1672 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -