Cod sursa(job #365656)

Utilizator AndreiDDiaconeasa Andrei AndreiD Data 19 noiembrie 2009 15:56:27
Problema Zoo Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define file_in "zoo.in"
#define file_out "zoo.out"

#define Nmax 16010

int N,M;
int x[Nmax],y[Nmax];
int x1,y1,x2,y2;

void brute()
{
	int nr,i;
	
	while(M--)
	{
		nr=0;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		
		for (i=1;i<=N;++i)
			 if (x1<=x[i] && x[i]<=x2 && y1<=y[i] && y[i]<=y2)
				 nr++;
			 
		printf("%d\n", nr);
	}
}	


void solve()
{
}

void citire()
{
	int i;
	
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);

	scanf("%d", &N);
	for (i=1;i<=N;++i)
		 scanf("%d %d", &x[i], &y[i]);
	
	scanf("%d", &M);
	if (M<=1000)
	{
		brute();
	}
	else
	{
		solve();
	}
}
	
int main()
{
	citire();
	
	fclose(stdin);
	fclose(stdout);
	
	return 0;
	
}