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 3
29 22
17 14
18 23
3 15
6 28
30 27
4 1
26 7
8 0
11 21
2 25
5 10
19 24

Sample Output

-6
4
4 这一题当时是第一个做的,并且一血使我们学校的一个队拿的,应该是道签到题吧 题意:给你n个点代表treasure的位置,然后再给你m个点,每给一个点时,都已这个点画一个十字架,其中位于第一部分和第三部分的是Wang的treasure共有p个,第二部分和第四部分是Dong的 共有q个,最终求他俩的差值即p-q;
#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=;i<n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
}
for(i=;i<m;i++)
{
p=q=;
scanf("%d%d",&x,&y);
for(j=;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 ;
}

Distribution(F题)---第八届河南省程序设计大赛的更多相关文章

  1. 第八届河南省程序设计大赛-B.最大岛屿0000110011000000

    最大岛屿                                                                                           时间限制: ...

  2. NYOJ--1236--挑战密室(第八届河南省程序设计大赛)

    挑战密室 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 R组织的特工Dr. Kong 为了寻找丢失的超体元素,不幸陷入WTO密室.Dr. Kong必须尽快找到解锁密 ...

  3. nyoj 1239 引水project (河南省第八届acm程序设计大赛)

    题目1239 pid=1239" style="color:rgb(55,119,188)">题目信息 pid=1239" style="col ...

  4. nyoj1237 最大岛屿(河南省第八届acm程序设计大赛)

    题目1237 pid=1237" style="color:rgb(55,119,188)">题目信息 执行结果 本题排行 讨论区 最大岛屿 时间限制:1000 m ...

  5. nyoj 1238 最少换乘 (河南省第八届acm程序设计大赛)

    题目1238 题目信息 执行结果 本题排行 pid=1238" style="text-decoration:none; color:rgb(55,119,188)"&g ...

  6. NYOJ-712 探寻宝藏(第六届河南省程序设计大赛)

    探 寻 宝 藏 时间限制:1000 ms  |  内存限制:65535 KB 难度:5   描述 传说HMH大沙漠中有一个M*N迷宫,里面藏有许多宝物.某天,Dr.Kong找到了迷宫的地图,他发现迷宫 ...

  7. nyoj170 网络的可靠性(第三届河南省程序设计大赛)

    题目170 题目信息 执行结果 pid=170" style="text-decoration:none; color:rgb(55,119,188)">本题排行 ...

  8. 河南省第八届ACM程序设计大赛

    A:挑战密室 #include <iostream> #include <cstdio> #include <cstring> #include <algor ...

  9. 河南省第八届ACM程序设计大赛总结

    简单的对这次省赛做个总结:总体来说这个比赛过程中做的还算比较顺利,虽然中间多多少少遇到一些坑,正式比赛开始后,我们就开始找水题,当然了我首先把英文题目翻译了一遍,发现了一道水题,这道题目其实就是判断点 ...

随机推荐

  1. Python 编程技巧

    Python 生成器 Python 处理文件 Python 异常处理 Python 处理输入输出 Python 处理命令行参数 Python 对文件做校验 Python 对目录做遍历 Python 调 ...

  2. Android分包原理

    如果App引用的库太多,方法数超过65536后无法编译.这是因为单个dex里面不能有超过65536个方法.为什么有最大的限制呢,因为Android会把每一个类的方法id检索起来,存在一个链表结构里面. ...

  3. MQTT-C-UDP_PUB

    /** ****************************************************************************** * @file    apdu.c ...

  4. EXCEL数据匹配:The 'Microsoft.Jet.Oledb.4.0' provider is not registered on the local machin

    百度的处理结果: 作者:LisenYang http://blog.csdn.net/lisenyang/article/details/52106492 这篇博文里面说的,默认设置修改[启动32应用 ...

  5. C# - 获取类中属性的名称

    用反射控制的,不过获取属性名称的方法,用方法形式获取的,不知道消耗大不大 using System; using System.Collections.Generic; using System.Li ...

  6. Makefile 链接静态库

    Linux的静态库是以.a结尾的,要连接静态库有两种方法,一种是在编译命令最后直接加上库路径/库名称. 例如你的库在绝对目录/lib/libtest.a下面你就可以这样来编译$(CC) $(CFLAG ...

  7. 【Spring源码深度解析学习系列】复杂标签属性解析(四)

    一.创建用于属性承载的BeanDefinition BeanDefiniton是一个接口,在Spring中存在三种实现:RootBeanDefinition.ChildBeanDefinition.G ...

  8. chrome插件开发,易懂

  9. GOOGLE CODE ANDROID 开源项目 集合

    转:http://blog.csdn.net/dellheng/article/details/7163333 1.        ZXing  http://code.google.com/p/zx ...

  10. facebook login issue

    If enable the facebook account in settings, when change account can't open the session. -(void)fbRes ...