Pagini recente » Cod sursa (job #1679224) | Cod sursa (job #1519304) | Cod sursa (job #2804931) | Cod sursa (job #1664261) | Cod sursa (job #253768)
Cod sursa(job #253768)
#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)
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;
}