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

      

  • 相关阅读:
    图像滤镜艺术---乐高像素拼图特效滤镜的代码实现
    假设你也23
    seajs载入流程图
    android 怎样将主菜单图标改成按安装时间排序
    热力学第一定律的社会学思考
    Django创建数据表
    KeyPress 和KeyDown 、KeyPress之间的区别
    Delphi 制作自定义数据感知控件并装入包(dpk文件)中(与DBText类似的数据感知控件)
    Delphi中的窗体创建与销毁
    Delphi ADOQuery连接数据库的查询、插入、删除、修改
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5096529.html
Copyright © 2011-2022 走看看