Pagini recente » Cod sursa (job #429362) | Cod sursa (job #976277) | Cod sursa (job #2639140) | Cod sursa (job #3152397) | Cod sursa (job #253773)
Cod sursa(job #253773)
#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;
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 && r<=c*10 && r>0)
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;
}