Submission #2834

# Submission time Handle Problem Language Result Execution time Memory
2834 2013-07-31T14:42:57 Z mh5664 간선 파괴 (GA5_destroy) C++
Compilation error
0 ms 0 KB
#include <stdio.h>
#include <vector>

using namespace std;

const int MAXN = 700;

vector<pair<int,int> > data[MAXN + 1];
int q[MAXN + 1];
int r = -1, f = -1;
bool ch[MAXN + 1];
int main ()
{
	int n, m;
	scanf ("%d %d", &n, &m);

	for (int i = 0; i < m; ++i)
	{
		int x, y;
		scanf ("%d %d", &x, &y);
		data[x - 1].push_back (make_pair (y - 1, i + 1));
		data[y - 1].push_back (make_pair (x - 1, i + 1));
	}

	int k;
	scanf ("%d", &k);
	for (int i = 0; i < k; ++i)
	{
		int x, y;
		scanf ("%d %d", &x, &y);
		int sol = 0;
		for (int i = 0; i < n; ++i)
		{
			if (!ch[i])
			{
				int j;
				++sol;
				r = f = -1;
				q[++r] = i;
				ch[i] = true;
				while (r > f)
				{
					j = q[++f];
					for (int k = 0; k < data[j].size (); ++k)
					{
						if (x <= data[j][k].second && data[j][k].second <= y)
							continue;
						if (!ch[data[j][k].first])
						{
							ch[data[j][k].first] = true;
							q[++r] = data[j][k].first;
						}
					}
				}
			}
		}

		printf ("%d\n", sol);
		for (int i = 0; i < n; ++i)
		{
			ch[i] = false;
		}
	
	return 0;
}

Compilation message

destroy.cpp: In function 'int main()':
destroy.cpp:44:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
destroy.cpp:65:1: error: expected '}' at end of input
destroy.cpp:15:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
destroy.cpp:20:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
destroy.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
destroy.cpp:30:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]