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

      

  • 相关阅读:
    浅谈jQuery easyui datagrid操作单元格样式
    关于翻页之后表格重新加载,之前选中的项丢失的问题处理
    jquery操作复选框(checkbox)的12个小技巧总结
    项目管理学习笔记之四.风险管理
    c#基于udp实现的p2p语音聊天工具
    漫说好管理vs.坏管理
    linux安装tomcat
    wifi共享精灵2014.04.25.001已经更新,wifi热点中文名走起!
    NYOJ 589 糖果
    MacBook Pro安装Photoshop且支持Retina有你们说的那么困难吗!
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5096529.html
Copyright © 2011-2022 走看看