hdu5258简单枚举

百度之星复赛第一题。不明白这么水的题为何一堆人没过。。。这些人是咋晋级复赛的呢。。。

/*
 * Author    : ben
 */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;
typedef struct Bang {
    int x1, x2;
    int y1, y2;
    Bang(int xx1 = 0, int yy1 = 0, int xx2 = 0, int yy2 = 0) {
        x1 = xx1;
        x2 = xx2;
        y1 = yy1;
        y2 = yy2;
    }
} Bang;
Bang heng[30], shu[30];
int N, M, ans;
bool isCross(const Bang &b1, const Bang &b2) {
    if (b2.x1 >= b1.x1 && b2.x1 <= b1.x2) {
        if (b1.y1 >= b2.y1 && b1.y1 <= b2.y2) {
            return true;
        }
    }
    return false;
}
void work() {
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int a = 0; a < M; a++) {
                if (!isCross(heng[i], shu[a]) || !isCross(heng[j], shu[a])) {
                    continue;
                }
                for (int b = a + 1; b < M; b++) {
                    if (isCross(heng[i], shu[b]) && isCross(heng[j], shu[b])) {
                        ans++;
                    }
                }
            }
        }
    }
}

int main() {
    int T, n;
    int x1, x2, y1, y2;
    scanf("%d", &T);
    for (int t = 1; t <= T; t++) {
        N = 0;
        M = 0;
        ans = 0;
        scanf("%d", &n);
        for (int i = 0; i < n; i++) {
            scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
            if (x1 == x2) {
                shu[M++] = Bang(x1, min(y1, y2), x2, max(y1, y2));
            } else {
                heng[N++] = Bang(min(x1, x2), y1, max(x1, x2), y2);
            }
        }
        work();
        printf("Case #%d:\n%d\n", t, ans);
    }
    return 0;
}

 

posted @ 2015-06-06 20:59  moonbay  阅读(207)  评论(0编辑  收藏  举报