ZOJ1139 POJ1468 Rectangles水题

Posted tigerisland45

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ZOJ1139 POJ1468 Rectangles水题相关的知识,希望对你有一定的参考价值。

Rectangles
Time Limit: 5000MS Memory Limit: 10000K
Total Submissions: 3519 Accepted: 1793

Description

A specialist in VLSI design testing must decide if there are some components that cover each other for a given design. A component is represented as a rectangle. Assume that each rectangle is rectilinearly oriented (sides parallel to the x and y axis), so that the representation of a rectangle consists of its minimum and maximum x and y coordinates.
Write a program that counts the rectangles that are entirely covered by another rectangle.

Input

The input contains the text description of several sets of rectangles. The specification of a set consists of the number of rectangles in the set and the list of rectangles given by the minimum and maximum x and y coordinates separated by white spaces, in the format:

nr_rectangles
xmin1 xmax1 ymin1 ymax1
xmin2 xmax2 ymin2 ymax2
...
xminn xmaxn yminn ymaxn

For each set,there will be less than 5000 rectangles.

Output

The output should be printed on the standard output. For each given input data set, print one integer number in a single line that gives the result (the number of rectangles that are covered).

Sample Input

3
100 101 100 101
0 3 0 101
20 40 10 400
4
10 20 10 20
10 20 10 20
10 20 10 20
10 20 10 20

Sample Output

0
4

Source

Southeastern Europe 2000

问题链接ZOJ1139 POJ1468 Rectangles
问题简述:(略)
问题分析
????判断矩形是否重叠,简单题不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C语言程序如下:

/* ZOJ1139 POJ1468 Rectangles */

#include <stdio.h>

#define N 10000
struct {
    int xmin, ymin, xmax, ymax;
} a[N];

int main(void)
{
    int n, i, j;
    while(scanf("%d", &n) != EOF) {
        for(i = 0; i < n; i++)
            scanf("%d%d%d%d", &a[i].xmin, &a[i].xmax, &a[i].ymin, &a[i].ymax);
        int cnt = 0;
        for(i = 0; i < n; i++)
            for(j = 0; j < n; j++)
                if(i != j && a[i].xmin >= a[j].xmin &&
                        a[i].xmax <= a[j].xmax &&
                        a[i].ymin >= a[j].ymin &&
                        a[i].ymax <= a[j].ymax) {
                    cnt++;
                    break;
                }
        printf("%d
", cnt);
    }

    return 0;
}

以上是关于ZOJ1139 POJ1468 Rectangles水题的主要内容,如果未能解决你的问题,请参考以下文章

[bzoj1468][poj1741]Tree_点分治

BZOJ1468: Tree(POJ1741)

ACM/ICPC 之 Floyd练习六道(ZOJ2027-POJ2253-POJ2472-POJ1125-POJ1603-POJ2607)

POJ1603 ZOJ1221 RiskFloyd算法

BZOJ.1468.Tree(点分治)

ACM/ICPC 之 BFS+状态压缩(POJ1324(ZOJ1361))