10411: F.Distribution

Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 11  Solved: 8 [Submit][Status][Web Board]

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

HINT

 

Source

第八届河南省赛

题解:题目乱码了,意思是给你一些点,然后两条线,分割这些点,一个人要13区域的,一个人要24区域的,让求两个人得到的点数的差

输入:两个数N,M,代表N个点,M代表x,y的值;

代码:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
#define SI(x) scanf("%d",&x)
#define mem(x,y) memset(x,y,sizeof(x))
#define PI(x) printf("%d",x)
#define P_ printf(" ")
const int INF=0x3f3f3f3f;
typedef long long LL;
const int MAXN=100010;
struct Node{
int x,y;
Node init(){
scanf("%d%d",&x,&y);
}
};
Node dt[MAXN];
int main(){
int N,M,x,y;
while(~scanf("%d%d",&N,&M)){
for(int i=0;i<N;i++){
dt[i].init();
}
for(int i=0;i<M;i++){
SI(x);SI(y);
int t1=0,t2=0;
for(int j=0;j<N;j++){
if((dt[j].x>x&&dt[j].y>y)||(dt[j].x<x&&dt[j].y<y))t1++;
}
printf("%d\n",2*t1-N);
}
}
return 0;
}

  

第八届河南省赛F.Distribution(水题)的更多相关文章

  1. 第八届河南省赛B.最大岛屿(dfs)

    B.最大岛屿 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 30  Solved: 18 [Submit][Status][Web Board] De ...

  2. 第八届河南省赛G.Interference Signal(dp)

    G.Interference Signal Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 35  Solved: 17 [Submit][Status ...

  3. 第八届河南省赛D.引水工程(kruthcra+prime)

    D.引水工程 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 118  Solved: 41 [Submit][Status][Web Board] D ...

  4. 第八届河南省赛C.最少换乘(最短路建图)

    C.最少换乘 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 94  Solved: 25 [Submit][Status][Web Board] De ...

  5. POJ-2421Constructing Roads,又是最小生成树,和第八届河南省赛的引水工程惊人的相似,并查集与最小生成树的灵活与能用,水过~~~

    Constructing Roads Time Limit: 2000MS   Memory Limit: 65536K               Description There are N v ...

  6. 第七届河南省赛F.Turing equation(模拟)

    10399: F.Turing equation Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 151  Solved: 84 [Submit][St ...

  7. ZOJ 17届校赛 Knuth-Morris-Pratt Algorithm( 水题)

    In computer science, the Knuth-Morris-Pratt string searching algorithm (or KMP algorithm) searches f ...

  8. HDU 4730 We Love MOE Girls (2013成都网络赛,签到水题)

    We Love MOE Girls Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  9. hdu 5038 (2014北京网络赛G 排序水题)

    题意:有n个数字,带入10000 - (100 - ai) ^ 2公式得到n个数,输出n个数中频率最大的数,如果有并列就按值从小到大都输出输出,如果频率相同的数字是全部的n个数,就输出Bad....题 ...

随机推荐

  1. scrapy中运行爬虫时出现twisted critical unhandled error错误

    1. 试试这条命令: twisted critical unhandled error on scrapy tutorial python python27\scripts\pywin32_posti ...

  2. 关于scp 不需要密码

    运行 ssh-keygen -t rsa 会在用户目录~/.ssh/产生两个文件,id_rsa,id_rsa.pub   //      cat id_rsa.pub >~/.ssh/autho ...

  3. 【Linux指令】使用中学习(一)

    sed指令: 应用:对于大文件,比如10G的大文件,我遇到的是导出的数据库.sql文件,想要使用vim修改几乎是不可能的,用sed指令可以在不打开文件的情况下修改文件,下面是一些具体用法 删除文件特定 ...

  4. CentOS和Redhat发行版linux内核版本的对应关系

    由于Redhat和CentOS的发行版本现在众多,所以我们应该知道CentOS和Redhat及linux内核之间版本的对应关系对维护系统还是很有帮助的.对应的列表如下: Redhat 9.0————— ...

  5. asp.net的Master-Content结构简介

    在一个网站中,页面应该具有统一的布局方式,这些统一的布局内同将显示到所有的页面中,它提供了用户最基本的功能.Asp.Net2.0通过Master-Content结构提供了这样统一页面管理的机制. Ma ...

  6. Oracle EBS-SQL (SYS-12):查询各Profile的设置情况.sql

    SELECT pro.profile_option_name, pro.user_profile_option_name, lev.level_type TYPE, --lev.level_code, ...

  7. C语言入门(10)——if分支语句

    在我们写的函数中可以有多条语句,但这些语句总是从前到后顺序执行的.除了从前到后顺序执行之外,有时候我们需要检查一个条件,然后根据检查的结果执行不同的后续代码,在C语言中可以用分支语句实现,比如: if ...

  8. 简单实现计算Edit Distance算法

    最近因为工作需要,学习了NLP的相关知识,简单动手实现了一下计算Edit Distance的算法,就是计算一个字符串要变成另一个字符串需要的代价,这其中采用Levenshtein方式,即规定一个插入和 ...

  9. Dreamweaver中打开CodeSmith文件

    电脑环境:Windows2008+Dreamweaver 8英文版本 问题描述:Dreamweaver中默认打开文档时不支持打开CodeSmith模板文件对应的.cst后缀名文件,截图如下: 解决步骤 ...

  10. hdu-5082

    题意非常easy,就是给出父母的名字,然后依据父母的名字来给孩纸取名字! 能够将此题简化为: 孩纸的名字=父亲的frist name+字符串(_small_)+母亲额frist name; 然后将孩纸 ...