第八届河南省赛 zzuoj 10411: F.Distribution (模拟)水

10411: F.Distribution

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 10   Solved: 7
[ Submit][ Status][ Web Board]

Description

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.

Input

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

Output  contains   lines , a single line with a integer , the difference described above.

Sample Input

10 329 2217 1418 233 156 2830 274 126 78 011 212 255 1019 24

Sample Output

-644

HINT

Source

第八届河南省赛

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct zz
{
    int x;
    int y;
}q[210];
int main()
{
    int n,m;
    int x,y;
    int i,j;
    int a,b;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(i=0;i<n;i++)
            scanf("%d%d",&q[i].x,&q[i].y);
        while(m--)
        {
            a=b=0;
            scanf("%d%d",&x,&y);
            for(i=0;i<n;i++)
            {
                if((q[i].x<x&&q[i].y>y)||(q[i].x>x&&q[i].y<y))
                    a++;
            }
            b=n-a;
            printf("%d\n",b-a);
        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值