Submission #580246

# Submission time Handle Problem Language Result Execution time Memory
580246 2022-06-20T19:36:28 Z MODDI Pipes (CEOI15_pipes) C++14
10 / 100
1948 ms 65536 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int n, m;
vector<int> G[100010];
vector<bool> vis;
vi tin, low;
int timer;
vector<pii> ans;
void dfs(int node, int parent = -1){
	vis[node] = true;
	tin[node] = low[node] = timer++;
	for(auto next : G[node]){
		if(next == parent)	continue;
		if(vis[next]){
			low[node] = min(low[node], tin[next]);
		}
		else{
			dfs(next, node);
			low[node] = min(low[node], low[next]);
			if(low[next] > tin[node]){
				ans.pb(mp(node,next));
			}
		}
	}
}
void init(){
	timer = 0;
	vis.assign(n, false);
	tin.assign(n, -1);
	low.assign(n, -1);
	for(int i = 0; i < n; i++){
		if(!vis[i])
			dfs(i);
	}
}
int main(){	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin>>a>>b;
		a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	init();
	for(int i = 0; i < ans.size(); i++)
	{
		cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
	}
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:56:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for(int i = 0; i < ans.size(); i++)
      |                 ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Incorrect 2 ms 2644 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3284 KB Output is correct
2 Incorrect 7 ms 3028 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 16224 KB Output is correct
2 Correct 152 ms 15492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 222 ms 23916 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 365 ms 41376 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 603 ms 33516 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1168 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1557 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1839 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1948 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -