题目连接

题目描述

One day , Wang and Dong in the Dubai desertexpedition, discovered an ancient castle. Fortunately, they found a map of thecastle.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.

Wang will save the treasures in I and III ,while those situated in II and IV will betaken away by Dong. Wangfirst draw a horizontal line, Dong after the draw a vertical line.

They drewseveral pairs of  lines. For each pair, Wangwants to know the difference between their treasures.

It's guaranteed that all the reasures will lie on neither of the linesdrew by them.

输入

the first line contains two integers N and M, where N is the number of treasures on the map and M indicates how many times they are going to draw the lines. The 2nd to (N+1)-th lines Xi, Yi contain the co-ordinates of the treasures and the last M lines consist of the M pairs integers (X, Y) which means that the two splitting lines intersect at point (X, Y).
( 0 < N, M ≤ 100, 0 ≤ Xi, Yi, X,Y ≤ 1000 )

输出

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

样例输入

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

样例输出

-6
4
4
题意大概: 在一个平面上有N个点,有M次划分,既是以M次划分的点为分割点,画一个水平线和垂直线划分为四个区域,数一数一三界限和二四界限的点的差额既是所求的结果。代码如下:
#include<stdio.h>
#include<string.h>
#include<iostream>using namespace std;struct node{int x;int y;
}loc[105];int main(){int n,m;while(scanf("%d %d",&n,&m)!=EOF){memset(loc,0,sizeof(loc));//int i;for(int i=0; i<n; ++i){scanf("%d %d", &loc[i].x, &loc[i].y );}for(int i=0; i<m; ++i ){int a,b,s=0,s2=0,s4=0;scanf("%d %d",&a,&b);for(int j=0; j<n; ++j){if(loc[j].x>a && loc[j].y>b )//四界限的点数 s4++;else if(loc[j].x<a && loc[j].y<b)//二界限的点数 s2++;elses++;}printf("%d\n",s2+s4-s);//两人的差额 }}return 0;
}

NYOJ_5743Distribution(第八届河南省程序设计大赛)相关推荐

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

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

  2. 第八届河南省程序设计大赛~~挑战密室 nyoj 1236

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

  3. NYOJ - [第八届河南省程序设计大赛]Distribution(水题)

    题目链接:http://nyoj.top/problem/1241 内存限制:64MB 时间限制:2000ms 题目描述 One day , Wang and Dong in the Dubai de ...

  4. NYOJ - [第八届河南省程序设计大赛]引水工程(最小生成树)

    题目链接:http://nyoj.top/problem/1239 内存限制:64MB 时间限制:2000ms 题目描述 南水北调工程是优化水资源配置.促进区域协调发展的基础性工程,是新中国成立以来投 ...

  5. 第八届河南省程序设计大赛 引水工程 Prim算法

    引水工程 时间限制:2000 ms  |  内存限制:65535 KB 难度:3 描述 南水北调工程是优化水资源配置.促进区域协调发展的基础性工程,是新中国成立以来投资额最大.涉及面最广的战略性工程, ...

  6. 第八届河南省程序设计大赛D引水工程(最小生成树)

    题目描述 南水北调工程是优化水资源配置.促进区域协调发展的基础性工程,是新中国成立以来投资额最大.涉及面最广的战略性工程,事关中华民族长远发展."南水北调工程",旨在缓解中国华北和 ...

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

    题目1237 题目信息 执行结果 本题排行 讨论区 最大岛屿 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描写叙述 神奇的海洋.惊险的探险之路,打捞海底宝藏,激烈的海战,海 ...

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

    题目1239 题目信息 运行结果 本题排行 讨论区 引水工程 时间限制:2000 ms  |  内存限制:65535 KB 难度:3 描述 南水北调工程是优化水资源配置.促进区域协调发展的基础性工程, ...

  9. nyoj 543 遥控器 第五届河南省程序设计大赛

    题目: 遥 控 器 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 Dr.Kong有一台高级电视机,这台电视机可以接受100个频道(从0到99编号).电视的配套遥控器有1 ...

最新文章

  1. 权限表管理之删除权限表数据
  2. Xamarin.Android部署失败
  3. Java对C语言Dll的加载 和 回调函数的使用
  4. 算法打卡39:喷水装置
  5. 宝山一模能用计算机吗,宝山区一模各科试卷(含答案)
  6. java的语法知识_Java语法知识点
  7. [Java基础]HashSet集合概述和特点
  8. POJ2689-Prime Distance【质数,数论】
  9. BeyondCompared4提示“缺少评估信息或损坏” 一条命令解决
  10. Netty工作笔记0065---WebSocket长连接开发4
  11. 445端口的简单利用
  12. LINUX上基于ASM的ORACLE11的安装
  13. 4.(地图数据篇)nginx代理地图服务--离线部署地图服务
  14. ssb门限_ssb单边带的产生方法
  15. iOS开发 ----- 加载动画之牛顿摆的实现
  16. 程序猿的情怀 语录(三)
  17. app小游戏需实名防沉迷
  18. ZUFE 2017院赛 - Problem K: Jelly与狗头人的地下世界 (DP)
  19. 2021高考汕头一中成绩查询,2021汕头市地区高考成绩排名查询,汕头市高考各高中成绩喜报榜单...
  20. 图像 引言 深度学习_深度学习算法对磁共振图像序列的识别

热门文章

  1. 第六届北京八大处新春祈福庙会大年初一迎客
  2. CMDB 设计(二)实现host、ip存储
  3. 【树莓派编程】检测有没有物体移动 +人脸识别
  4. IT 人士如何避免中年危机?
  5. CentOS 6.7 FTP安装配置之pure-ftpd
  6. SpringMVC中的数据校验
  7. github 使用记录
  8. php sockent通信
  9. Spread for WinRT 7新功能使用指南
  10. [链接]C++和Python版本的委托