• 第八届河南省赛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;
    }
    

      

  • 相关阅读:
    IP地址加时间戳加3位随机数
    你会想造一艘船吗?
    提问的智慧
    建造者模式
    设计模式(一)
    jeesite中activiti中的流程表梳理
    如何读书、学习?
    zxing生成高容错率二维码,以及添加文字
    LVM磁盘划分
    阿里云盘扩容(SUSE Linux下)
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5096529.html
Copyright © 2020-2023  润新知