Cod sursa(job #253666)

Utilizator jupanubv92Popescu Marius jupanubv92 Data 6 februarie 2009 10:47:22
Problema Grendizer Scor 20
Compilator cpp Status done
Runda Stelele Informaticii 2009, clasele 9-10, ziua 1 Marime 0.54 kb
#include<stdio.h>
#include<stdlib.h>

long n,m;
struct cord{
 long x;
 long y;
}a[100001];

int main()
{
    freopen("grendizer.in","r",stdin);
    freopen("grendizer.out","w",stdout);
    scanf("%ld %ld",&n,&m);
    for(int i=1;i<=n;i++)
     scanf("%ld %ld",&a[i].x,&a[i].y);
    for(int j=1;j<=m;j++)
     {long x,y,r;
      scanf("%ld %ld %ld",&x,&y,&r);
      long nr=0;
      for(int i=1;i<=n;i++)
         if(abs(x - a[i].x) + abs(y - a[i].y)==r)
            nr++;
      printf("%ld\n",nr);
     }
    return 0;
}