题目链接:http://nyoj.top/problem/1241

  • 内存限制:64MB 时间限制:2000ms

题目描述

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.

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.

输入描述

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个画线的交点坐标,输出每次画线后区域(I+III)-(II+IV)的结果。
思路:直接判断就行了。

#include <bits/stdc++.h>
using namespace std;
struct edge {int x, y;
}e[105];
int main() {int n, m, x, y;scanf("%d%d", &n, &m);for (int i = 0; i < n; i++)scanf("%d%d", &e[i].x, &e[i].y);while (m--) {int a = 0, b = 0;scanf("%d%d", &x, &y);for (int i = 0; i < n; i++) {if (e[i].x > x && e[i].y > y || e[i].x < x && e[i].y < y)a++;else b++;}printf("%d\n", a - b);}return 0;
}

NYOJ - [第八届河南省程序设计大赛]Distribution(水题)相关推荐

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

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

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

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

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

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

  4. NYOJ - [第五届河南省程序设计大赛]最强DE战斗力(大数)

    题目链接:http://nyoj.top/problem/541 内存限制:64MB 时间限制:1000ms 题目描述 春秋战国时期,赵国地大物博,资源非常丰富,人民安居乐业.但许多国家对它虎视眈眈, ...

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

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

  6. 湖南省第十一届程序设计大赛 (水题)聊天止于呵呵

    模拟题老师基本上都不讲,因为只要足够细心,大家都能做对.集训到今天就结束了.这次下来, 发现自己做模拟题已经很有手感了,相较于之前,真的有很大的成长. 简单的分析下这道题, 1.首先,要找出总共有多少 ...

  7. NYOJ_5743Distribution(第八届河南省程序设计大赛)

    题目连接 题目描述 One day , Wang and Dong in the Dubai desertexpedition, discovered an ancient castle. Fortu ...

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

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

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

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

最新文章

  1. easyexcel生成excel_阿里JAVA解析Excel工具easyexcel
  2. 常见硬件术语大全(上)
  3. emwin自定义消息问题
  4. jQuery动态加载select下拉列表
  5. python tornade 表单和模板
  6. Fiddler的安装与使用
  7. 数值积分方法的总结(从简单梯形积分到龙贝格积分、自适应积分、高斯积分等)
  8. 码农小汪-synchronized
  9. 计算机网络实验二 VLAN间路由
  10. webstorm设置黑色背景
  11. 使用TextMeshPro实现打字机效果
  12. mac mysql 自动启动_Mac设置Mysql开机启动
  13. 86. 闭锁 CountDownLatch
  14. Snow Boots
  15. generator详解
  16. android ev3 蓝牙连接,手机蓝牙遥控EV3教程
  17. 在Ubuntu系统上在线下载/删除/查看软件包信息apt命令
  18. mysql mvcc
  19. 【一起入门MachineLearning】中科院机器学习第*课-支持向量机SVM
  20. App Key 和 App Secret 有什么用?

热门文章

  1. 四面深信服(长沙)软件测试工程师10k,大概是长沙双休犯法吧笑
  2. 服务器保存时提示文档未保存,Word文档保存时常遇到的问题及其解决方法
  3. 【面试题】面向对象与面向过程的区别
  4. 阿里达摩院人工智能科学家杨红霞离职,AI商用是难题
  5. Hadoop与spark性能比较试验
  6. mysql emoy表情_“笑哭”emoji表情过时了,一波“捂脸”大军正在路上
  7. 利用SQL语句创建、修改、删除、查看与使用数据库
  8. 《赋能:打造应对不确定性的敏捷团队》
  9. 支持M1芯片Mac电脑的 Adobe Photoshop 2021 for Mac 中文版本
  10. Kubernetes部署失败的10个最常见原因