Cod sursa(job #264735)

Utilizator cristiprgPrigoana Cristian cristiprg Data 22 februarie 2009 17:49:01
Problema Grendizer Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <cstdio>

long abs (long x)
{
	if (x < 0 )
		return -x;

	return x;
}

struct cur
{
	long x,y;
} coord [100005];

long  n ,m, dist, gr, gx, gy;

int main ()
{
	FILE *in = fopen("grendizer.in", "r"), *out = fopen("grendizer.out", "w" );
	fscanf (in, "%ld%ld", &n, &m);
	int q;
	for (q = 1; q <= n; q++)
		fscanf (in,"%d%d", &coord[q].x, &coord[q].y);

	long nr ;
	for (q = 1; q <= m; q++)
	{
		nr = 0;
		fscanf(in, "%ld%ld%ld", &gx, &gy, &gr);
		long r;
		for (int i = 1; i <= n; i++)
		{
			r = abs(coord[i].x - gx) + abs(coord[i].y - gy);
			if (r <= gr)
				nr++;
		}

		fprintf (out, "%ld\n", nr);
	}
}