Distribution(F题)---第八届河南省程序设计大赛
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 M 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题)---第八届河南省程序设计大赛的更多相关文章
- 第八届河南省程序设计大赛-B.最大岛屿0000110011000000
最大岛屿 时间限制: ...
- NYOJ--1236--挑战密室(第八届河南省程序设计大赛)
挑战密室 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 R组织的特工Dr. Kong 为了寻找丢失的超体元素,不幸陷入WTO密室.Dr. Kong必须尽快找到解锁密 ...
- nyoj 1239 引水project (河南省第八届acm程序设计大赛)
题目1239 pid=1239" style="color:rgb(55,119,188)">题目信息 pid=1239" style="col ...
- nyoj1237 最大岛屿(河南省第八届acm程序设计大赛)
题目1237 pid=1237" style="color:rgb(55,119,188)">题目信息 执行结果 本题排行 讨论区 最大岛屿 时间限制:1000 m ...
- nyoj 1238 最少换乘 (河南省第八届acm程序设计大赛)
题目1238 题目信息 执行结果 本题排行 pid=1238" style="text-decoration:none; color:rgb(55,119,188)"&g ...
- NYOJ-712 探寻宝藏(第六届河南省程序设计大赛)
探 寻 宝 藏 时间限制:1000 ms | 内存限制:65535 KB 难度:5 描述 传说HMH大沙漠中有一个M*N迷宫,里面藏有许多宝物.某天,Dr.Kong找到了迷宫的地图,他发现迷宫 ...
- nyoj170 网络的可靠性(第三届河南省程序设计大赛)
题目170 题目信息 执行结果 pid=170" style="text-decoration:none; color:rgb(55,119,188)">本题排行 ...
- 河南省第八届ACM程序设计大赛
A:挑战密室 #include <iostream> #include <cstdio> #include <cstring> #include <algor ...
- 河南省第八届ACM程序设计大赛总结
简单的对这次省赛做个总结:总体来说这个比赛过程中做的还算比较顺利,虽然中间多多少少遇到一些坑,正式比赛开始后,我们就开始找水题,当然了我首先把英文题目翻译了一遍,发现了一道水题,这道题目其实就是判断点 ...
随机推荐
- [Linux] 修改用户名密码
1. 普通用户或root用户修改自身登录密码:在终端使用passwd命令. linaro@linaro-ubuntu-desktop:~$ passwd Changing password for l ...
- api 25 PopupWindow会占据整个屏幕
解决方法:if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // Android 7.x中,PopupWindow高度为match_pa ...
- php技能评测
以下摘抄自:https://www.viphper.com/?p=1236 公司出了一些自我评测的PHP题目,现将题目和答案记录于此,以方便记忆. 1. 魔术函数有哪些,分别在什么时候调用?__con ...
- codeforces水题100道 第二十四题 Codeforces Beta Round #85 (Div. 2 Only) A. Petya and Strings (strings)
题目链接:http://www.codeforces.com/problemset/problem/112/A题意:忽略大小写,比较两个字符串字典序大小.C++代码: #include <cst ...
- iOS 沙盒目录结构及正确使用
前言:处于安全考虑,iOS系统的沙盒机制规定每个应用都只能访问当前沙盒目录下面的文件(也有例外,比如在用户授权情况下访问通讯录,相册等),这个规则展示了iOS系统的封闭性.在开发中常常需要数据存储的功 ...
- xp下对dinput8.dll 游戏键盘输入的模拟 非函数hook
https://www.xuebuyuan.com/833929.html 很多游戏或者3d模拟软件为了更好的支持外设使用directinput作为输入接口调用.那么如果要模拟鼠标或键盘来控制游戏或者 ...
- 通过orderby关键字,LINQ可以实现升序和降序排序。LINQ还支持次要排序。
通过orderby关键字,LINQ可以实现升序和降序排序.LINQ还支持次要排序. LINQ默认的排序是升序排序,如果你想使用降序排序,就要使用descending关键字. static void M ...
- Android JNI与多线程
Java通过JNI调用本地C++代码是在同一个线程中的同步调用. JNI中如果新建的线程调用java的代码,那么java代码是运行在JNI线程中的:但是,如果调用UI相关的代码时需要与java主线程通 ...
- ActiveMQ 消息持久化到数据库(Mysql、SQL Server、Oracle、DB2等)
ActiveMQ具体就不介绍了,直接介绍如何讲ActiveMQ持久化到本地数据库,以SQL Server 2008 R2为例1.下载ActiveMQ后直接解压,我下载的是apache-activemq ...
- Internet Explorer 9 已安装在此系统上
问题: win7系统,IE11浏览器,想换成IE9,安装IE9的时候,提示错误. 解决方案: 方案一: 1.打开 控制面板--程序--程序和功能--点击打开或者关闭Windows功能,找到Intern ...