poj1262
来源:互联网 发布:网络压力测试 编辑:程序博客网 时间:2024/06/06 04:08
链接:http://poj.org/problem?id=1262
Input
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 629
Accepted: 268
Description
In a recent programming contest, one of the problems was about tiling floors with rectangular tiles. The input specification reads like this:
The input contains several floors. The first line of the input gives the number of floors.Each floor is described in several lines. The first line contains two positive integers: the length and width of the floor, in millimeters. A floor is at most 40 000 mm long or wide.The next line contains a single number: the number t of tiles (1 <= t <= 100). The following t lines each contain the description of a tile. A tile is given as four integers:
xl yl xh yh
where (xl, yl) are the coordinates of the lower left corner of the tile, and (xh, yh) are the coordinates of the upper rightmost corner of the tile. A tile always has a positive area. The order of the coordinates of the floor and those of the tile coincide, of course.You may assume that the tiles are mutually disjoint, and cover the floor, the whole floor,and nothing but the floor.The last line of this specification raised some problems. Not for the contestants, but for the judges. Some of the test cases consist of many tiles. How can we be sure that our input file meets this condition? What we need is a checking program that verifies this condition.
Problem
Given an input file in the above format, find out for each floor whether the tiles
1. are disjoint,
2. do not lie outside the floor,
3. do cover the floor.
Input
The input contains several floors. The first line of the input gives the number of floors. Each floor is described in several lines. The first line contains two positive integers: the length and width of the floor, in millimeters. A floor is at most 40 000 mm long or wide. The next line contains a single number: the number t of tiles (1 <= t <= 100). The following t lines each contain the description of a tile. A tile is given as four integers:
xl yl xh yh
where (xl, yl) are the coordinates of the lower left corner of the tile, and (xh, yh) are the coordinates of the upper rightmost corner of the tile. A tile always has a positive area. The order of the coordinates of the floor and those of the tile coincide, of course.
Output
For each floor the output contains a single line, containing one of the following words:
NONDISJOINT if overlapping tiles occur;
NONCONTAINED if no overlapping tiles occur,
but some tiles go outside the floor;
NONCOVERING if no overlapping tiles occur,
and no tiles go outside the floor,
but some parts of the floor are not covered;
OK if none of these is true.
Sample Input
4
4 3
2
0 0 2 2
1 1 5 5
4 3
2
0 0 2 2
-2 2 5 5
4 3
2
0 0 2 2
2 0 4 2
4 3
3
0 0 2 2
2 0 4 2
0 2 4 3
Sample Output
NONDISJOINT
NONCONTAINED
NONCOVERING
OK
Source
题目大意:给出地板的长度和宽度,及瓷砖的位置,按照瓷砖覆盖的情况输出答案:情况1.是否存在重叠情况:
2.是否有出界外的
3.是否有空隙,
4.在都满足1,2,3的情况下输出“OK”,
思路:按照题意,一一判断上述情况即可
#include<stdio.h>#include<math.h>#include<iostream>using namespace std;struct Tile{int x1,y1;int x2,y2;int s;}p[101];int main(){int n,i,j,k;int t1,t2,t3;int a,b,sum,m,c1,c2,t;while(scanf("%d",&n)!=EOF){ while(n--) { t1=t2=t3=0; sum=0; scanf("%d%d",&a,&b); scanf("%d",&m); t=(a>b? a:b); for(i=0;i<m;i++) { scanf("%d%d%d%d",&p[i].x1,&p[i].y1,&p[i].x2,&p[i].y2); c1=abs(p[i].x1-p[i].x2); c2=abs(p[i].y1-p[i].y2); p[i].s=c1*c2; sum+=p[i].s; if(p[i].x1<0||p[i].x2<0||p[i].y1 <0||p[i].y2 <0)//判断是否过界 t2=1; if(p[i].x1>t||p[i].x2>t||p[i].y1>t||p[i].y2>t) t2=1; } if(sum<a*b)//判断是否有空隙 t3=1; for(i=0;i<m;i++)//判断是否有重叠 { if(t1)break; for(j=i+1;j<m;j++) { if((p[j].x1>=p[i].x2)||(p[j].x2<=p[i].x1)||(p[j].y1>=p[i].y2)||(p[j].y2<=p[i].y1)) continue; else {t1=1; break; } } } // printf("t1=%d t2=%d t3=%d\n",t1,t2,t3);if(t1) printf("NONDISJOINT\n");else if(t2) printf("NONCONTAINED\n");else if(t3) printf("NONCOVERING\n");elseprintf("OK\n"); }}return 0;}
- poj1262
- Java监控文件变化
- struts标签库:logic:empty logic:notPresent struts-config.xml
- QEMU Emulator User Documentation
- 浅谈HTTP中Get与Post的区别
- jasperreport学习 之 javabean封装成list作为数据源
- poj1262
- Fragment 使用时的崩溃记录
- linux下编程实现mplayer播放器总结
- Linux SPI驱动
- 维护数据完整性
- VB中的选择结构
- Node.js 相关有用网站
- Android suspend/resume flow (上篇: User mode)
- 建立排序的单链表