Pagini recente » Cod sursa (job #1375028) | Cod sursa (job #3183240) | Cod sursa (job #2141958) | Cod sursa (job #415450) | Cod sursa (job #253765)
Cod sursa(job #253765)
#include <stdio.h>
FILE*in = fopen("grendizer.in","r");
FILE*out= fopen("grendizer.out","w");
long long n,m;
struct coord{ int x,y;} xy[100001];
long long abs(long long x){
if(x>0) return x;
return -x;
}
int main(){
long long i,j,x,y,r,k,c=100000000,mod1,mod2;
fscanf(in,"%lld%lld",&n,&m);
for(i=1;i<=n;++i)
fscanf(in,"%lld%lld",&x,&y);
if(abs(x) <= c && abs(y)<=c){xy[i].x=x;xy[i].y=y;}
else{--i;--n;}
for(i=1;i<=m;++i){
k=0;
fscanf(in,"%lld%lld%lld",&x,&y,&r);
if(abs(x)<=c && abs(y)<=c)
for(j=1;j<=n;++j){
if(abs(x-xy[j].x)+abs(y-xy[j].y) == r)++k;
}
fprintf(out,"%lld\n",k);
}
return 0;
}