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;
    }
    

      

  • 相关阅读:
    VC:文件串行化(CFileDialog类、CFile类、CArchive类、Edit控件)
    实例说明optimize table在优化mysql时很重要
    文件备份,同步工具rsync服务器端的安装及配置
    log4cxx does not compile on kernel 2.6.29.6
    CentOS桌面安装
    编译 apachelog4cxx0.10.0inputstreamreader.cpp:66: error: ‘memmove’ was not declared in this sco
    解决/usr/bin/ld: cannot find lmysqlclient错误
    mysql 复制表数据,表结构的3种方法
    php 动态添加OPENSSL模块
    mysql开启慢查询方法
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5096529.html
Copyright © 2011-2022 走看看