Submission #34433

# Submission time Handle Problem Language Result Execution time Memory
34433 2017-11-11T08:19:38 Z bnahmad15 Pipes (CEOI15_pipes) C++14
20 / 100
371 ms 8720 KB
#include <bits/stdc++.h>
using namespace std;

int n,m,u,v;
short tim = 0;
bool vis[10001]={false};
short low[10001]={0},disc[10001],parent[10001];
vector <short> adj[10001];

void DFS(int node){
	vis[node] = true;
	disc[node]=low[node]=++tim;
	for (auto i : adj[node]){
		if (!vis[i]){
			parent[i]=node;
			DFS(i);
			low[node]=min(low[node],low[i]);
			if (low[i] > disc[node]){
				cout<<node+1<<" "<<i+1<<endl;
			}
		}
		else if (i != parent[node])
			low[node] = min(low[node],disc[i]);
	}
}
void find_bridges(){
		for (int i = 0 ; i< n;i++){
			vis[i]=false;
			parent[i]=-1;
			disc[i]=0;
			low[i]=0;
		}
		for (int i = 0; i<n;i++)
			if (!vis[i]){
				tim = 0;
				DFS(i);
			}
}
int main(){

	scanf("%d%d",&n,&m);
	for (int i= 0 ;i <m;i++){
		scanf("%d%d",&u,&v);
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	find_bridges();
	return 0;
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
pipes.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&u,&v);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Incorrect 3 ms 640 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 6 ms 896 KB Output is correct
2 Incorrect 6 ms 768 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 155 ms 4752 KB Output is correct
2 Correct 146 ms 4476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 308 ms 6724 KB Output is correct
2 Correct 371 ms 8720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 996 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 996 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -