here is my code sir......
#include<stdio.h>
int main()
{
int nt=0,i=0,n=0,m=0,j=0,x1=0,x2=0,y1=0,y2=0,xt=0,yt=0;
scanf("%d",&nt);
for(i=0;i<nt;i++)
{
scanf("%d %d",&n,&m);
int x[n],y[n];int out[m],k=0,l=0;
for(j=0;j<n;j++)
{
scanf("%d %d",&x[j],&y[j]);
}
for(j=0;j<m;j++)
{
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
int lhs=0,rhs=0;
lhs=(xt-x1)*(y2-y1);
rhs=(yt-y1)*(x2-x1);
int cnt=0;
for(l=0;l<n;l++)
{
if(x[l]>=x1 && y[l]>=y1 && x[l]<=x2 && y[l]<=y2)
{
if(((x[l]-x1)*(y2-y1))==((y[l]-y1)*(x2-x1)))
cnt++;
}
}
out[j]=cnt;
}
for(j=0;j<m;j++)
{
printf("%d\n",out[j]);
}
}
return 0;
}
1 month later
@Leppy-----i worked on some more furious test cases and debugged my code .............CODE REMOVED
1 month later
I have some trouble with that problem though it looks like an easy one. I'm not sure if it's a matter of wrong logic, I/O problem (with Python) or just misunderstanding the problem description. "Segment" is a rectangle, right?
For this testcase from a post above:
1
4 5
0 3
2 2
3 3
4 4
0 0 5 5
3 3 4 4
0 0 1 0
0 0 0 1
0 0 0 5
The output should be:
4
2
0
0
1
Right?