HDU5128 The E-pang Palace
题目大意:
坐标系中有N个整点,用它们中的一些做顶点连两个长方形,使得长方形不出现cross或touch(如图)的情况,输出两个长方形的所占面积的最大值,如果不存在满足要求的长方形,就输出imp。
(4 <=N <= 30)(T<=15)(0 <= x,y <= 200).
思路:
数据范围很仁慈,暗示了这是一道枚举题。先记录能组成的每一个矩形,在判断两两是否可行,可行就更新ans。
注意:包含也是满足题意的,而且所占面积只是是大长方形的!!
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdlib> 5 6 using namespace std; 7 8 int n,cor[100][2],cnt; 9 10 struct node 11 { 12 long long area; 13 int weizhi[5][2]; 14 }juxing[500000]; 15 16 int main() 17 { 18 scanf("%d",&n); 19 while(n) 20 { 21 cnt=0; 22 memset(juxing,0,sizeof(0)); 23 memset(cor,0,sizeof(0)); 24 for(int i=1;i<=n;i++)scanf("%d%d",&cor[i][0],&cor[i][1]); 25 if(n<8) 26 { 27 printf("imp\n"); 28 scanf("%d",&n); 29 continue; 30 } 31 for(int i=1;i<=n;i++) 32 for(int j=i+1;j<=n;j++) 33 for(int k=j+1;k<=n;k++) 34 for(int g=k+1;g<=n;g++) 35 { 36 if(cor[i][0]==cor[j][0]) 37 { 38 if((cor[i][1]==cor[k][1])&&(cor[g][1]==cor[j][1])&&(cor[g][0]==cor[k][0])) 39 { 40 cnt++; 41 juxing[cnt].area=(cor[i][1]-cor[j][1])*(cor[i][0]-cor[k][0]); 42 juxing[cnt].weizhi[1][1]=cor[i][1];juxing[cnt].weizhi[1][0]=cor[i][0]; 43 juxing[cnt].weizhi[2][1]=cor[k][1];juxing[cnt].weizhi[2][0]=cor[k][0]; 44 juxing[cnt].weizhi[3][1]=cor[j][1];juxing[cnt].weizhi[3][0]=cor[j][0]; 45 juxing[cnt].weizhi[4][1]=cor[g][1];juxing[cnt].weizhi[4][0]=cor[g][0]; 46 } 47 if((cor[i][1]==cor[g][1])&&(cor[k][0]==cor[g][0])&&(cor[k][1]==cor[j][1])) 48 { 49 cnt++; 50 juxing[cnt].area=(cor[i][1]-cor[j][1])*(cor[i][0]-cor[g][0]); 51 juxing[cnt].weizhi[1][1]=cor[i][1];juxing[cnt].weizhi[1][0]=cor[i][0]; 52 juxing[cnt].weizhi[2][1]=cor[g][1];juxing[cnt].weizhi[2][0]=cor[g][0]; 53 juxing[cnt].weizhi[3][1]=cor[j][1];juxing[cnt].weizhi[3][0]=cor[j][0]; 54 juxing[cnt].weizhi[4][1]=cor[k][1];juxing[cnt].weizhi[4][0]=cor[k][0]; 55 } 56 } 57 if(cor[i][0]==cor[k][0]) 58 { 59 if((cor[i][1]==cor[j][1])&&(cor[g][1]==cor[k][1])&&(cor[g][0]==cor[j][0])) 60 { 61 cnt++; 62 juxing[cnt].area=(cor[i][1]-cor[k][1])*(cor[i][0]-cor[j][0]); 63 juxing[cnt].weizhi[1][1]=cor[i][1];juxing[cnt].weizhi[1][0]=cor[i][0]; 64 juxing[cnt].weizhi[2][1]=cor[j][1];juxing[cnt].weizhi[2][0]=cor[j][0]; 65 juxing[cnt].weizhi[3][1]=cor[k][1];juxing[cnt].weizhi[3][0]=cor[k][0]; 66 juxing[cnt].weizhi[4][1]=cor[g][1];juxing[cnt].weizhi[4][0]=cor[g][0]; 67 } 68 if((cor[i][1]==cor[g][1])&&(cor[j][1]==cor[k][1])&&(cor[j][0]==cor[g][0])) 69 { 70 cnt++; 71 juxing[cnt].area=(cor[i][1]-cor[k][1])*(cor[i][0]-cor[g][0]); 72 juxing[cnt].weizhi[1][1]=cor[i][1];juxing[cnt].weizhi[1][0]=cor[i][0]; 73 juxing[cnt].weizhi[2][1]=cor[g][1];juxing[cnt].weizhi[2][0]=cor[g][0]; 74 juxing[cnt].weizhi[3][1]=cor[k][1];juxing[cnt].weizhi[3][0]=cor[k][0]; 75 juxing[cnt].weizhi[4][1]=cor[j][1];juxing[cnt].weizhi[4][0]=cor[j][0]; 76 } 77 } 78 if(cor[i][0]==cor[g][0]) 79 { 80 if((cor[i][1]==cor[j][1])&&(cor[k][1]==cor[g][1])&&(cor[k][0]==cor[j][0])) 81 { 82 cnt++; 83 juxing[cnt].area=(cor[i][1]-cor[j][1])*(cor[i][0]-cor[k][0]); 84 juxing[cnt].weizhi[1][1]=cor[i][1];juxing[cnt].weizhi[1][0]=cor[i][0]; 85 juxing[cnt].weizhi[2][1]=cor[j][1];juxing[cnt].weizhi[2][0]=cor[j][0]; 86 juxing[cnt].weizhi[3][1]=cor[g][1];juxing[cnt].weizhi[3][0]=cor[g][0]; 87 juxing[cnt].weizhi[4][1]=cor[k][1];juxing[cnt].weizhi[4][0]=cor[k][0]; 88 } 89 if((cor[i][1]==cor[k][1])&&(cor[j][1]==cor[g][1])&&(cor[j][0]==cor[k][0])) 90 { 91 cnt++; 92 juxing[cnt].area=(cor[i][1]-cor[j][1])*(cor[i][0]-cor[k][0]); 93 juxing[cnt].weizhi[1][1]=cor[i][1];juxing[cnt].weizhi[1][0]=cor[i][0]; 94 juxing[cnt].weizhi[2][1]=cor[k][1];juxing[cnt].weizhi[2][0]=cor[k][0]; 95 juxing[cnt].weizhi[3][1]=cor[g][1];juxing[cnt].weizhi[3][0]=cor[g][0]; 96 juxing[cnt].weizhi[4][1]=cor[j][1];juxing[cnt].weizhi[4][0]=cor[j][0]; 97 } 98 } 99 } 100 if(cnt<=1) 101 { 102 printf("imp\n"); 103 scanf("%d",&n); 104 continue; 105 } 106 long long ans=0; 107 for(int i=1;i<=cnt;i++) 108 for(int j=i+1;j<=cnt;j++) 109 { 110 int ximax=max(juxing[i].weizhi[1][0],juxing[i].weizhi[2][0]); 111 int ximin=min(juxing[i].weizhi[1][0],juxing[i].weizhi[2][0]); 112 int yimax=max(juxing[i].weizhi[1][1],juxing[i].weizhi[3][1]); 113 int yimin=min(juxing[i].weizhi[1][1],juxing[i].weizhi[3][1]); 114 int xjmax=max(juxing[j].weizhi[1][0],juxing[j].weizhi[2][0]); 115 int xjmin=min(juxing[j].weizhi[1][0],juxing[j].weizhi[2][0]); 116 int yjmax=max(juxing[j].weizhi[1][1],juxing[j].weizhi[3][1]); 117 int yjmin=min(juxing[j].weizhi[1][1],juxing[j].weizhi[3][1]); 118 if((ximin>xjmax)||(xjmin>ximax)||(yimin>yjmax)||(yjmin>yimax)) 119 { 120 if(ans<juxing[i].area+juxing[j].area)ans=juxing[i].area+juxing[j].area; 121 } 122 if((ximin>xjmin)&&(ximax<xjmax)&&(yimin>yjmin)&&(yimax<yjmax)) 123 { 124 if(ans<juxing[j].area)ans=juxing[j].area; 125 } 126 if((ximin<xjmin)&&(ximax>xjmax)&&(yimin<yjmin)&&(yimax>yjmax)) 127 { 128 if(ans<juxing[i].area)ans=juxing[i].area; 129 } 130 } 131 if(ans==0) 132 { 133 printf("imp\n"); 134 scanf("%d",&n); 135 continue; 136 } 137 printf("%I64d\n",ans); 138 scanf("%d",&n); 139 } 140 return 0; 141 }
View Code
转载于:https://www.cnblogs.com/LiqgNonqfu/p/9795182.html
HDU5128 The E-pang Palace相关推荐
- Hdu5128 - The E-pang Palac
Hdu5128 - The E-pang Palace 题意:给定n个点,要求从这n个点当中选择8个点作为顶点来构成2个不相交(不能有任何一个点公共)的矩形,如果无法选出两个这样的矩形的话输出imp, ...
- UVALive 7070 The E-pang Palace 暴力
The E-pang Palace Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/problem ...
- 2019ICPC南京网络赛A题 The beautiful values of the palace(三维偏序)
2019ICPC南京网络赛A题 The beautiful values of the palace https://nanti.jisuanke.com/t/41298 Here is a squa ...
- 2021EC-final博弈论E题Prof. Pang and Poker
题目链接:Problem - E - Codeforces 题目意思:有三个人玩游戏,Alice,Bob,还有Prof. Pang.Alice和Bob分别有n,m张扑克,Pang只有一张,出牌顺序是A ...
- NBUT 1578-The smart Big Pang Pang【博弈论】 难度:**
题意: Today,Big Pang Pang and Captain want to plan a game,the rule is simple.Now,they starting with tw ...
- HDOJ 5128 The E-pang Palace
这题虽然是暴力,但是我确实学到了....每句对角线的高端做法. 参考博客: https://blog.csdn.net/ck_boss/article/details/41720811 我自己的代码: ...
- HDU5128The E-pang Palace(计算几何暴力枚举)
The E-pang Palace 题解:预处理出所有矩形,然后枚举满足情况的两两矩形即可.因为是矩形,所以我们只需要存对角的两个点即可.就是要注意嵌套也是满足的. 代码 #include<bi ...
- 会自我演变的空间机器,Fun Palace是什么? | 建筑·人工智能专栏
科技是答案,但原来的问题是什么? --塞德里克·普莱斯 "Technology is the answer, but what was the question?" (Cedri ...
- 我的pang友齐大福
这是赵天霸本周第三次被老板骂哭了. "请问,你是不是猪?我把你招来是来干什么的,你能不能给我复述一遍?" 有一秒钟,赵天霸以为他的确需要一个回答."你把我招来是为了给你骂 ...
最新文章
- MATLAB“figure”使用详解
- ZOJ Problem Set - 3329 One Person Game
- java死锁以及解决方案
- TestNG 入门教程
- PHP的数据类型转换
- X509证书认证流程介绍
- 大话数据结构 :排序
- simplis汉化包_Simtrix.simplis仿真_中文教程
- 辐流式重力浓缩池计算_注册考试重点!平流式、竖流式、辐流式、斜板式4大沉淀池构型...
- Apache 及 Nginx 配置
- 二、fragment使用
- hdu acm 1016
- delphi 实现科学计数法
- 美团成都一面面经及详细答案
- Docker:(四)docker网络模式
- php7米酷cms,米酷CMS6.2修改版 支持PHP7 独家首发 - 百码云
- Pycharm使用远程服务器解释器
- 三种升糖之王,糖友尽量少碰
- 这次彻底读透 Redis
- EVE-NG物理机启动报错
热门文章
- 16.火星文转换 C#
- 1-3分钟教你如何开通微信支付0.2%费率,适用于公众号小程序和收款码
- 利用PPT的平滑变换功能以及Onekey插件做变形金刚变身的过程
- 《Learning Scrapy》(中文版)第10章 理解Scrapy的性能
- PHICOMM(斐讯)N1盒子 - Armbian5.77(Debian 9)基本配置
- 「实战案例」基于Python语言开发的信用评分卡
- m3u8中ts文件无损批量合并与转换方法
- vscode配置(复制直接用)
- 物联网卡设置_物联卡中心:物联网卡这样设置一下上网全程4G,建议收藏!
- css -- 为什么:last-child 无效?