Submission #116684

# Submission time Handle Problem Language Result Execution time Memory
116684 2019-06-13T14:26:11 Z fleimgruber Pipes (CEOI15_pipes) C++17
30 / 100
3643 ms 65536 KB
#include <bits/stdc++.h>

using namespace std;

//bridge finding
const int MAX_N = 100005;

int n,t,in[MAX_N];
vector<int> e[MAX_N];

int dfs(int i, int p = -1)
{
	in[i] = t++;
	int lo = in[i];
	for (int g : e[i])
	{
		if (g == p)
		{
			p = -1;
			continue;
		}
		if (in[g])
			lo = min(lo,in[g]);
		else
		{
			int lg = dfs(g,i);
			if (lg > in[i])
				printf("%d %d\n",i,g);
			lo = min(lo,lg);
		}
	}
	return lo;
}

void bridges()
{
	t = 1;
	for (int i=1; i<=n; i++)
		if (!in[i])
			dfs(i);
}
//-----

int main()
{
	int m,a,b;
	scanf("%d %d",&n,&m);
	//TODO simplify graph
	while (m--)
	{
		scanf("%d %d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	bridges();
	return 0;
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:47: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:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&a,&b);
   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3328 KB Output is correct
2 Correct 8 ms 3072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 166 ms 16260 KB Output is correct
2 Correct 164 ms 15480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 350 ms 23896 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 781 ms 41472 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1233 ms 51892 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1912 ms 65536 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2696 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3282 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3643 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -