zoukankan      html  css  js  c++  java
  • 第八届河南省赛F.Distribution(水题)

    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
    ",2*t1-N);
    		}
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    PHP加速器 eaccelerator 介绍
    详谈调用winpcap驱动写arp多功能工具
    VS、VC开发工具快捷键
    链表removeHead中的缺陷
    Effective C++ 小笔记:条款36
    Ubuntu grub系统引导菜单错误
    C++ 中的强制类型转换
    Latex WinEdt eps图片显示不出来 dvi pdf
    unsinged int,unsigned long,size_t还是std::size_t?
    privte的析构函数和构造函数
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5096529.html
Copyright © 2011-2022 走看看