南邮 OJ 1608 Slides
来源:互联网 发布:windows dream scence 编辑:程序博客网 时间:2024/06/11 15:23
Slides
总提交 : 29 测试通过 : 11
比赛描述
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.
输入
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 ≤ 100) , 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.
输出
There should be one line per test case containing the maximum intersecting area of corresponding N - 1 slides.
样例输入
2
2
0 0 2 2
1 1 2 2
3
0 0 2 2
1 0 3 2
1 1 3 3
样例输出
4
2
题目来源
ICPC
#include<iostream>#define N 100using namespace std;__int64 x1[N];__int64 y1[N];__int64 x2[N];__int64 y2[N];int main(){//freopen("test.txt","r",stdin);//WA1__int64 t,n,i,j,maxX1,maxY1,minX2,minY2,area,maxArea;scanf("%I64d",&t);while(t--){scanf("%I64d",&n);for(i=0; i<n; i++){scanf("%I64d%I64d%I64d%I64d",x1+i,y1+i,x2+i,y2+i);}maxArea = 0;for(i=0;i<n;i++){maxX1 = maxY1 = INT_MIN;minX2 = minY2 = INT_MAX;for(j=0;j<n;j++){if(j==i){continue;}if(x1[j] > maxX1){maxX1 = x1[j];}if(y1[j] > maxY1){maxY1 = y1[j];}if(x2[j] < minX2){minX2 = x2[j];}if(y2[j] < minY2){minY2 = y2[j];}}if(minY2>maxY1 && minX2>maxX1){area = (minY2-maxY1)*(minX2-maxX1);if(area > maxArea){maxArea = area;}}}printf("%I64d\n",maxArea);}}
- 南邮 OJ 1608 Slides
- Lecture Slides
- Hbase slides
- hdu2478 Slides
- slides - Sun开源Java
- Sicily 1799. Slides
- CTS training slides
- POJ-1486-Sorting Slides
- poj1486 - Sorting Slides
- poj 1486 Sorting Slides
- POJ1486:Sorting Slides
- HDOJ 2478 Slides
- Slides中插入脚注
- POJ 1486 Sorting Slides
- POJ-1486-Sorting Slides
- 开源slides工具
- Sicily 1913. Slides
- poj1486 Sorting Slides
- 欢迎使用CSDN-markdown编辑器
- Android桌面悬浮窗效果实现,仿360手机卫士悬浮窗效果(转)
- 读书笔记——《程序员自我修养》——编译和链接
- 老罗[android源代码分析] 读书笔记-安卓的消息队列
- 社説 20150806 原爆忌 被爆地訪問で核軍縮に弾みを
- 南邮 OJ 1608 Slides
- 数字阶梯求和_1051
- Swift开发教程--火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法
- 服务器-TCP 在 EPOLL 模型中的注意细节
- Effective Java笔记-第7章:方法
- JavaWeb 过滤器实现30天内自动登录
- 机器学习经典书籍
- CodeForces 567A Lineland Mail 贪心
- Hdu 5349 MZL's simple problem 2015ACM多校对抗赛第五场