UVA 10927 Bright Lights
来源:互联网 发布:pyqt5 windows 安装 编辑:程序博客网 时间:2024/05/16 02:04
还是扫描线。Rank 15 耶~
给你一些柱子还有柱子的高度,问你从0 0 哪些看不到。
直接极角排序,然后相同角度按从近到远的距离排,然后保存共线最大高度,扫一遍即可。
第二次输出排序忘排 y 了,WA了几次 = =。。还以为是比较猥琐的错误呢,比如1个数的话不是“are” 是 “is” 什么的,不过这个题没有。。。 = =。。我想太多了。
#include <map>#include <set>#include <queue>#include <stack>#include <math.h>#include <time.h>#include <stdio.h>#include <stdlib.h>#include <iostream>#include <limits.h>#include <string.h>#include <string>#include <algorithm>#define MID(x,y) ( ( x + y ) >> 1 )#define L(x) ( x << 1 )#define R(x) ( x << 1 | 1 )#define BUG puts("here!!!")#define STOP system("pause")using namespace std;const int MAX = 100010;struct point {int x,y,h; double t;};point p[MAX];point out[MAX];bool cmp(point a,point b){if( a.t == b.t )return a.x*1ll*a.x + a.y*1ll*a.y < b.x*1ll*b.x + b.y*1ll*b.y;return a.t < b.t;}bool cmp1(point a,point b){if( a.x == b.x ) return a.y < b.y;return a.x < b.x;}int main(){int n, ind = 1;while( ~scanf("%d", &n) && n ){for(int i=0; i<n; i++){scanf("%d%d%d", &p[i].x, &p[i].y, &p[i].h);p[i].t = atan2(p[i].y, p[i].x);}sort(p, p+n, cmp);int cnt = 0;int h = p[0].h;for(int i=1; i<n; i++){if( p[i].t == p[i-1].t ){if( p[i].h <= h )out[cnt++] = p[i];h = max(h, p[i].h);}elseh = p[i].h;}printf("Data set %d:\n", ind++);if( cnt == 0 ){printf("All the lights are visible.\n");continue;}sort(out, out+cnt, cmp1);printf("Some lights are not visible:\n");for(int i=0; i<cnt-1; i++)printf("x = %d, y = %d;\n", out[i].x, out[i].y);printf("x = %d, y = %d.\n", out[cnt-1].x, out[cnt-1].y);}return 0;}
- UVA 10927 Bright Lights
- UVa 1560 - Extended Lights Out
- UVA 1560 - Extended Lights Out(高斯消元)
- uva 1560 - Extended Lights Out(枚举 | 高斯消元)
- Lights
- Lights
- uva 11605 - Lights inside a 3d Grid(概率)
- UVa 11605 - Lights inside a 3d Grid 期望
- UVA 11605 - Lights inside a 3d Grid 概率
- UVa 11605 - Lights inside a 3D Grid
- UVa 11605 - Lights inside a 3d Grid
- UVa 11605 : Lights inside a 3d Grid(期望)
- bright项目文件。
- A bright new day...
- 1700:忙碌的Bright
- Bright and Airy Attic Room
- TO BE A BRIGHT FOOL!
- UVA 11605 - Lights inside a 3d Grid(概率+数学)
- 网站seo为什么要对关键词优化分析
- Oracle、SQL server、MySQL数据库中分页查询的SQL语句
- AVI文件格式
- 利用WinDbg+Virtual PC调试驱动程序
- 【EXCEL精品收藏】EXCEL中最简单的个税计算公式(含2011年9月1日新标准)
- UVA 10927 Bright Lights
- ZOJ 1093 Monkey and Banana【DP】
- 并查集的应用——Ubiquitous Religions
- ORACLE数据类型
- 面试题
- 1. 介绍 Metro
- Silverlight企业应用开发实践-AgileEAS.NET平台5.0 Silverlight支撑预览
- 在Keil MDK环境下使用STM32 V3.4库“小”教程 简介和第一步(转)
- Eclipse插件加载失败的解决办法