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 ;
}

最新文章

  1. [原创]html5游戏_五线谱打音符
  2. 15 Examples To Master Linux Command Line History
  3. MongoDB安装(Linux)
  4. 简单的网页布局效果html5+CSS3
  5. ClientScriptManager与ScriptManager向客户端注册脚本的区别
  6. WWDC2014开源
  7. Eclipse 4.3正式版发布
  8. php常量作用
  9. 数据库DML操作(DCL了解)
  10. 有var和没有var的本质区别
  11. Java_面向对象
  12. P4630 [APIO2018] Duathlon 铁人两项
  13. 入门html第一次copy小米首页布局
  14. Struts框架(6)---action接收请求参数
  15. 转:The Difference Between a LayoutTransform and a RenderTransform
  16. leaflet实用插件整理
  17. 设计模式学习心得&lt;抽象工厂模式 Abstract Factory&gt;
  18. Jmeter(二十八)_Docker+Jmeter+Gitlab+Jenkins+Ant(容器化的接口自动化持续集成平台)
  19. 【.NET线程--进阶(一)】--线程方法详解
  20. netstat 在windows下和Linux下查看网络连接和端口占用

热门文章

  1. WAF Bypass数据库特性(Mysql探索篇)
  2. JavaWeb学习总结(十七)EL表达式
  3. date 类型转为varchar
  4. 一个汉字转拼音的php类
  5. 关于vc工程包含多个lib库老是提示无法打开问题
  6. 《转载》Jenkins持续集成-自动化部署脚本的实现《python》
  7. Web负载均衡与分布式架构
  8. 【Java知识点专项练习】之 volatile 关键字的功能
  9. SqlServer 连接远程服务器数据库 实现跨服务器联合查询
  10. 为什么WAN口IP和外网IP不一样(不一致)?