Submission #2866

# Submission time Handle Problem Language Result Execution time Memory
2866 2013-08-01T04:44:17 Z ladown21 간선 파괴 (GA5_destroy) C++
25 / 100
2424 ms 1364 KB
#include <stdio.h>

struct Edge{int a,b;};
Edge inner(int a,int b)
{Edge r={a,b};return r;}

int ufind(int k, int *T)
{
	if (T[k] == k) return k;
	return T[k] = ufind(T[k], T);
}

int main()
{
	int V,E,Q;
	scanf("%d%d",&V,&E);

	Edge G[50010];
	int u,v;
	for (int i=1; i<=E; i++) {
		scanf("%d%d",&u,&v);
		G[i] = inner(u,v);
	}

	scanf("%d",&Q);
	while (Q--)
	{
		int T[510]={0}, a,b;
		for (int i=1; i<=V; i++)
			T[i] = i;

		scanf("%d%d",&a,&b);
		for (int i=1; i<=E; i++) {
			if (a<=i && i<=b) continue;
			int x = ufind(G[i].a, T);
			int y = ufind(G[i].b, T);
			T[x] = y;
		}
		for (int i=1; i<=V; i++) 
			ufind(i,T);

		int C[800]={0}, ret=0;
		for (int i=1; i<=V; i++)
			ret += (C[T[i]]++)==0;
		printf("%d\n",ret);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1356 KB Output is correct
2 Correct 0 ms 1356 KB Output is correct
3 Correct 0 ms 1360 KB Output is correct
4 Correct 0 ms 1360 KB Output is correct
5 Correct 0 ms 1360 KB Output is correct
6 Correct 0 ms 1356 KB Output is correct
7 Correct 0 ms 1360 KB Output is correct
8 Correct 0 ms 1360 KB Output is correct
9 Correct 0 ms 1364 KB Output is correct
10 Correct 0 ms 1360 KB Output is correct
11 Correct 0 ms 1360 KB Output is correct
12 Correct 0 ms 1356 KB Output is correct
13 Correct 0 ms 1356 KB Output is correct
14 Correct 0 ms 1364 KB Output is correct
15 Correct 0 ms 1360 KB Output is correct
16 Correct 0 ms 1360 KB Output is correct
17 Correct 0 ms 1364 KB Output is correct
18 Correct 0 ms 1364 KB Output is correct
19 Correct 0 ms 1356 KB Output is correct
20 Correct 0 ms 1364 KB Output is correct
21 Correct 0 ms 1360 KB Output is correct
22 Correct 0 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 336 ms 1360 KB Output is correct
2 Correct 320 ms 1356 KB Output is correct
3 Correct 360 ms 1360 KB Output is correct
4 Correct 1000 ms 1364 KB Output is correct
5 Correct 976 ms 1360 KB Output is correct
6 Runtime error 2424 ms 1356 KB Program hung waiting for input
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 1356 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -