hdu 1152 Brownie Points I
来源:互联网 发布:淘宝下载新版下载安装 编辑:程序博客网 时间:2024/05/19 16:51
题目地址:
http://acm.hdu.edu.cn/showproblem.php?pid=1152
题目描述:
Brownie Points I
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 480 Accepted Submission(s): 293
Problem Description
Stan and Ollie play the game of Odd Brownie Points. Some brownie points are located in the plane, at integer coordinates. Stan plays first and places a vertical line in the plane. The line must go through a brownie point and may cross many (with the same x-coordinate). Then Ollie places a horizontal line that must cross a brownie point already crossed by the vertical line.
Those lines divide the plane into four quadrants. The quadrant containing points with arbitrarily large positive coordinates is the top-right quadrant.
The players score according to the number of brownie points in the quadrants. If a brownie point is crossed by a line, it doesn't count. Stan gets a point for each (uncrossed) brownie point in the top-right and bottom-left quadrants. Ollie gets a point for each (uncrossed) brownie point in the top-left and bottom-right quadrants.
Your task is to compute the scores of Stan and Ollie given the point through which they draw their lines.
Those lines divide the plane into four quadrants. The quadrant containing points with arbitrarily large positive coordinates is the top-right quadrant.
The players score according to the number of brownie points in the quadrants. If a brownie point is crossed by a line, it doesn't count. Stan gets a point for each (uncrossed) brownie point in the top-right and bottom-left quadrants. Ollie gets a point for each (uncrossed) brownie point in the top-left and bottom-right quadrants.
Your task is to compute the scores of Stan and Ollie given the point through which they draw their lines.
Input
Input contains a number of test cases. The data of each test case appear on a sequence of input lines. The first line of each test case contains a positive odd integer 1 < n < 200000 which is the number of brownie points. Each of the following n lines contains two integers, the horizontal (x) and vertical (y) coordinates of a brownie point. No two brownie points occupy the same place. The input ends with a line containing 0 (instead of the n of a test).
Output
For each test case of input, print a line with two numbers separated by a single space. The first number is Stan's score, the second is the score of Ollie when their lines cross the point whose coordinates are given at the center of the input sequence of points for this case.
Sample Input
113 23 33 43 62 -21 -30 0-3 -3-3 -2-3 -43 -70
Sample Output
6 3
题意:
两个玩家重新设定坐标系,1、3象限的点的数量为玩家1的分数,2、4象限点为玩家2的分数。
题解:
注意中间点,就是题目给处顺序点的中间点,不许经过sort找中间点。然后就是象限问题了。
代码:
#include<stdio.h>#include<stdlib.h>#include<iostream>using namespace std;typedef struct coor{ int x; int y; coor() { x=0; y=0; }}coor,* coorlink;coor coors[200000+5];int main(){ int n=0; while(scanf("%d",&n)!=EOF&&n>0) { for(int i=0;i<=n-1;i++) { scanf("%d%d",&coors[i].x,&coors[i].y); } int stan=0,ollie=0; coor mid=coors[(n-1)/2]; for(int i=0;i<=n-1;i++) { if((coors[i].x<mid.x&&coors[i].y<mid.y)||(coors[i].x>mid.x&&coors[i].y>mid.y)) { stan++; } if((coors[i].x<mid.x&&coors[i].y>mid.y)||(coors[i].x>mid.x&&coors[i].y<mid.y)) { ollie++; } } printf("%d %d\n",stan,ollie); } return(0);}
0 0
- HDU 1152 Brownie Points I
- hdu 1152 Brownie Points I
- hdu 1152 Brownie Points I
- 【数学 象限】HDU 1152 Brownie Points I
- HDOJ 1152 Brownie Points I(水题)
- HDU 1156 Brownie Points II
- poj 2460 Brownie Points I 坐标判断
- zoj 2554 Brownie Points
- 10865 - Brownie Points
- UVa10865 - Brownie Points
- poj2464 Brownie Points II
- zoj2554 Brownie Points
- poj 2464 Brownie Points II
- POJ_2464 Brownie Points II 线段树
- poj2464 Brownie Points II 树状数组
- UVA 10869 - Brownie Points II(树状数组)
- uva 10869 - Brownie Points II(树状数组)
- UVA10869 - Brownie Points II(线段树)
- CoreText实现图文混排和点击事件
- VGA时序及其原理
- 复制linux虚拟机时网卡信息不正确的解决办法
- ACM 杂题 hdu4915 Parenthese sequence
- P2P软件的昨天 今天 明天 P2P技术在中国 P2P软件正式进入第三代 P2P将颠覆下一代互联网游戏规则 P2P商业化的思考 C#下用P2P技术实现点对点聊天 P2P流媒体播放:下一代P
- hdu 1152 Brownie Points I
- ElasticSearch集群安装及配置方法
- html常用标签2
- 耿建玲SQL视频总结
- windows下,Python中获取本地磁盘卷标的方法
- Leetcode--Roman to Integer
- 旋转数组的最小数字
- 从Javaweb到Android的尝试
- PAT1077. Kuchiguse (20)