日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > php教程 > HDOJ 5128 The E-pang Palace 暴力枚舉+計算幾何

HDOJ 5128 The E-pang Palace 暴力枚舉+計算幾何

來源:程序員人生   發(fā)布時間:2014-12-09 08:34:31 閱讀次數(shù):3278次


枚舉出每個矩形,判斷相交

如果是回字型則輸出大的矩形的面積..........

The E-pang Palace

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)
Total Submission(s): 73    Accepted Submission(s): 26


Problem Description
E-pang Palace was built in Qin dynasty by Emperor Qin Shihuang in Xianyang, Shanxi Province. It was the largest palace ever built by human. It was so large and so magnificent that after many years of construction, it still was not completed. Building the great wall, E-pang Palace and Qin Shihuang's tomb cost so much labor and human lives that people rose to fight against Qin Shihuang's regime. 

Xiang Yu and Liu Bang were two rebel leaders at that time. Liu Bang captured Xianyang -- the capital of Qin. Xiang Yu was very angry about this, and he commanded his army to march to Xianyang. Xiang Yu was the bravest and the strongest warrior at that time, and his army was much more than Liu Bang's. So Liu Bang was frighten and retreated from Xianyang, leaving all treasures in the grand E-pang Palace untouched. When Xiang Yu took Xianyang, he burned E-pang Palce. The fire lasted for more than three months, renouncing the end of Qin dynasty.

Several years later, Liu Bang defeated Xiangyu and became the first emperor of Han dynasty. He went back to E-pang Palace but saw only some pillars left. Zhang Liang and Xiao He were Liu Bang's two most important ministers, so Liu Bang wanted to give them some awards. Liu Bang told them: "You guys can make two rectangular fences in E-pang Palace, then the land inside the fences will belongs to you. But the corners of the rectangles must be the pillars left on the ground, and two fences can't cross or touch each other." 

To simplify the problem, E-pang Palace can be consider as a plane, and pillars can be considered as points on the plane. The fences you make are rectangles, and you MUST make two rectangles. Please note that the rectangles you make must be parallel to the coordinate axes.

The figures below shows 3 situations which are not qualified(Thick dots stands for pillars):


Zhang Liang and Xiao He wanted the total area of their land in E-pang Palace to be maximum. Please bring your computer and go back to Han dynasty to help them so that you may change the history.
 

Input
There are no more than 15 test case.

For each test case:

The first line is an integer N, meaning that there are N pillars left in E-pang Palace(4 <=N <= 30).

Then N lines follow. Each line contains two integers x and y (0 <= x,y <= 200), indicating a pillar's coordinate. No two pillars has the same coordinate.

The input ends by N = 0.
 

Output
For each test case, print the maximum total area of land Zhang Liang and Xiao He could get. If it was impossible for them to build two qualified fences, print "imp".
 

Sample Input
8 0 0 1 0 0 1 1 1 0 2 1 2 0 3 1 3 8 0 0 2 0 0 2 2 2 1 2 3 2 1 3 3 3 0
 

Sample Output
2 imp
 

Source
2014ACM/ICPC亞洲區(qū)廣州站-重現(xiàn)賽(感謝華工和北京大學(xué))
 



#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <set> using namespace std; const int maxn = 31; int n,x[maxn],y[maxn]; bool vis[201][201]; struct Point { int x,y; }; struct MATRIX { Point p[4]; int area; }; vector<MATRIX> mat; bool inside(int& kind,Point p,MATRIX m) { int sx=m.p[0].x,dx=m.p[2].x; int sy=m.p[0].y,dy=m.p[2].y; if( (p.x>sx&&p.x<dx) && (p.y>sy&&p.y<dy) ) kind=1; if( (p.x>=sx&&p.x<=dx) && (p.y>=sy&&p.y<=dy) ) return true; return false; } int check(int a,int b) { MATRIX A=mat[a],B=mat[b]; int k0=0,k1=0,k2=0,k3=0; bool ok0=inside(k0,A.p[0],B); bool ok1=inside(k1,A.p[1],B); bool ok2=inside(k2,A.p[2],B); bool ok3=inside(k3,A.p[3],B); /// maybe A all in side B if(ok0||ok1||ok2||ok3) { if(k0==1&&k1==1&&k2==1&&k3==1) return B.area; else return ⑼99; } k0=0,k1=0,k2=0,k3=0; ok0=inside(k0,B.p[0],A); ok1=inside(k1,B.p[1],A); ok2=inside(k2,B.p[2],A); ok3=inside(k3,B.p[3],A); /// maybe B all in side A if(ok0||ok1||ok2||ok3) { if(k0==1&&k1==1&&k2==1&&k3==1) return A.area; else return ⑼99; } /// A out of B and B out of A if(ok0==false&&ok1==false&&ok2==false&&ok3==false) { return A.area+B.area; } return ⑼99; } int main() { while(scanf("%d",&n)!=EOF&&n) { ///init memset(vis,0,sizeof(vis)); mat.clear(); for(int i=0;i<n;i++) { cin>>x[i]>>y[i]; vis[x[i]][y[i]]=true; } /// find all SQR for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if(x[i]==x[j]) continue; if(y[i]==y[j]) continue; int sx=min(x[i],x[j]),dx=max(x[i],x[j]); int sy=min(y[i],y[j]),dy=max(y[i],y[j]); if(vis[sx][sy]&&vis[dx][sy]&&vis[sx][dy]&&vis[dx][dy]) { /// this is a sqrt MATRIX m; m.p[0].x=sx,m.p[0].y=sy; m.p[1].x=dx,m.p[1].y=sy; m.p[2].x=dx,m.p[2].y=dy; m.p[3].x=sx,m.p[3].y=dy; m.area=(dx-sx)*(dy-sy); mat.push_back(m); } } } int ans=⑴; int sz=mat.size(); for(int i=0;i<sz;i++) { for(int j=i+1;j<sz;j++) { /// 判斷 4 矩形相交 ans=max(ans,check(i,j)); } } if(ans<0) puts("imp"); else printf("%d ",ans); } return 0; }



生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 日韩欧美在线不卡 | 麻豆精品久久 | 黄网站在线免费看 | av中文在线资源 | 一区二区三区av在线 | 亚洲精品一区二区三区不 | 中文字幕一区在线观看视频 | 国产高清精品一区二区三区 | 综合久久五月天 | 久久免费看毛片 | 亚洲电影免费 | 日本不卡一 | 黄色片网址在线观看 | 精品色网| 日本免费在线视频 | 精品视频网站在线观看 | 国产精品综合 | 另类 欧美 日韩 国产 在线 | 嘿咻免费视频观看午夜 | 天天舔天天干天天操 | 欧美成人午夜电影 | 久久免费精品 | 久久91av | 精品美女一区二区 | 精国品产一区二区三区有限公司 | 伊人中文| 久久99精品久久久久久噜噜 | 久久久国产精品一区二区三区 | 国产精品99精品久久免费 | 亚洲欧美色图片 | 99久视频 | 久久精品国产综合 | 国产成人在线一区二区 | 疯狂做受xxxx国产 | 欧美视频一区二区在线观看 | 欧美日韩网站 | 精品国产91久久久久久 | 亚洲日本一区二区三区 | 国产视频在线免费观看 | 国产成人精品久久二区二区 | 国内毛片毛片 |