One day , Wang and Dong in the Dubai desert expedition, discovered an ancient castle. Fortunately, they found a map of the castle.The map marks the location of treasures.
They agreed to distribute the treasures according to the following rules:
Wang draws a horizontal line on the map and then Dong draws a vertical one so that the map is divided into 4 parts, as show below.
II I
III IV
Wang will save the treasures in I and III ,while those situated in II and IV will be taken away by Dong. Wang first draw a horizontal line, Dong after the draw a vertical line.
They drew several pairs of lines. For each pair, Wang wants to know the difference between their treasures.
It‘s guaranteed that all the reasures will lie on neither of the lines drew by them.
One day , Wang and Dong in the Dubai desert expedition, discovered an ancient castle. Fortunately, they found a map of the castle.The map marks the location of treasures.
They agreed to distribute the treasures according to the following rules:
Wang draws a horizontal line on the map and then Dong draws a vertical one so that the map is divided into 4 parts, as show below.
II I
III IV
Wang will save the treasures in I and III ,while those situated in II and IV will be taken away by Dong. Wang first draw a horizontal line, Dong after the draw a vertical line.
They drew several pairs of lines. For each pair, Wang wants to know the difference between their treasures.
It‘s guaranteed that all the reasures will lie on neither of the lines drew by them.
Output contains M lines , a single line with a integer , the difference described above.
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define N 1100
using namespace std;
struct node
{
int x,y;
};
int main()
{
int n,m,i,j,x,y,p,q;
node a[N];
while(scanf("%d%d",&n,&m)!=EOF)
{
for(i=0;i<n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
}
for(i=0;i<m;i++)
{
p=q=0;
scanf("%d%d",&x,&y);
for(j=0;j<n;j++)
{
if((a[j].x>x&&a[j].y>y)||(a[j].x<x&&a[j].y<y))//Wang的点的个数
p++;
else
q++;Dong的点的个数
}
printf("%d\n",p-q);
}
}
return 0;
}