程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> HDOJ 2478 Slides

HDOJ 2478 Slides

編輯:C++入門知識


維護次大和最大的左下角和右上角的坐標,再枚舉抽出哪一個矩陣。。。

Slides

Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 923 Accepted Submission(s): 311


Problem Description There are N slides lying on the table. Each of them is transparent and formed as a rectangle. In a traditional problem, one may have to calculate the intersecting area of these N slides. The definition of intersection area is such area which belongs to all of the slides.
But this time I want to take out some one of the N slides, so that the intersecting area of the left N-1 slides should be maximal. Tell me the maximum answer.

Input The first line of the input contains a single integer T, the number of test cases, followed by the input data for each test case. The first line of each test case contains a single integer N (1 <= N <= 100000), the number of rectangles. Followed by N lines, each line contains four integers x1, y1, x2, y2 (-10000 <= x1 < x2 <= 10000, -10000 <= y1 < y2 <= 10000), pair (x1, y1) gives out the bottom-left corner and pair (x2, y2) gives out the top-right corner of the rectangle.
Output There should be one line per test case containing the maximum intersecting area of corresponding N-1 slides.
Sample Input
2
2
0 0 2 2
1 1 2 2
3
0 0 2 2
1 0 3 2
1 1 3 3

Sample Output
4
2

Source 2008 Asia Regional Chengdu
#include 
#include 
#include 
#include 

using namespace std;

const int INF=0x3f3f3f3f;

int n;
int Lx1,Lx2,Ly1,Ly2,Rx1,Rx2,Ry1,Ry2;

struct Point
{
	int x,y;
}p[2][120000];

int main()
{
	int T_T;
	scanf("%d",&T_T);
while(T_T--)
{
	scanf("%d",&n);
	Lx1=Lx2=Ly1=Ly2=-INF;
	Rx1=Rx2=Ry1=Ry2=INF;
	for(int i=0;iLx1)
		{
			Lx2=Lx1; Lx1=a;
		}
		else if(a>Lx2)
		{
			Lx2=a;
		}
		if(b>Ly1)
		{
			Ly2=Ly1; Ly1=b;
		}
		else if(b>Ly2)
		{
			Ly2=b;
		}
		if(cLY&&RX>LX) ans=max(ans,(RY-LY)*(RX-LX));
	}
	printf("%d\n",ans);
}
	return 0;
}





  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved