Skip to content

Instantly share code, notes, and snippets.

@mangalvikas
Last active September 26, 2015 03:50
Show Gist options
  • Select an option

  • Save mangalvikas/8fdcc8dac8d3a4c56500 to your computer and use it in GitHub Desktop.

Select an option

Save mangalvikas/8fdcc8dac8d3a4c56500 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<stdlib.h>
int mod(int a){
if(a<0){
return (-1*a);
}
else return (a);
}
int main()
{
int t,i,j,k,*x,*y,*p,*r,m,l,n,d,count;
scanf("%d",&t);
for(i=0;i<t;i++){count=0;
scanf("%d%d%d",&n,&m,&d);
p=(int*)malloc(n*sizeof(int));
r=(int*)malloc(n*sizeof(int));
for(j=0;j<n;j++){
scanf("%d%d",p+j,r+j);
}
x=(int*)malloc(m*sizeof(int));
y=(int*)malloc(m*sizeof(int));
for(j=0;j<m;j++){
scanf("%d%d",x+j,y+j);
}
for(j=0;j<m;j++){
for(k=0;k<n;k++){
l=mod(*(p+k)-*(x+j))+mod(*(r+k)-*(y+j));
if(l<=d){
count=count+1;break;
}
}
}
if(count>=m/2){
printf("YES\n");
}
else
printf("NO\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment