2019 杭电多校第八场 HDU - 6665 Calabash and Landlord 两矩形分平面

题目链接:https://vjudge.net/problem/HDU-6665

题解:

2019 杭电多校第八场 HDU - 6665 Calabash and Landlord 两矩形分平面_第1张图片

#include 
using namespace std;
int main() {
    int x11, x12, y11, y12;
    int x21, x22, y21, y22;
    int x1, y1, x2, y2;
    int T;
    scanf("%d", &T);
    while(T--) {
        scanf("%d %d %d %d %d %d %d %d", &x11, &y11, &x12, &y12, &x21, &y21, &x22, &y22);
            if(x11 == x21 && x12 == x22 && y11 == y21 && y12 == y22) {
                printf("2\n");
                continue;
            }
            if(x12 <= x21 || x22 <= x11 || y12 <= y21 || y22 <= y11) {
                printf("3\n");
                continue;
            }
            
            
            if((x11 > x21 && x12 < x22 && y11 > y21 && y12 < y22) || (x11 < x21 && x12 > x22 && y11 < y21 && y12 > y22)) {
                printf("3\n");
                continue;
            }
            // 
            if((x11 == x21 && y11 >= y21 && x12 < x22 && y12 <= y22) || (x11 == x21 && y11 <= y21 && x12 > x22 && y12 >= y22)) {
                printf("3\n");
                continue;
            }
            if((x11 > x21 && y11 >= y21 && x12 == x22 && y12 <= y22) || (x11 < x21 && y11 <= y21 && x12 == x22 && y12 >= y22)) {
                printf("3\n");
                continue;
            }
            if((x11 >= x21 && y11 == y21 && x12 <= x22 && y12 < y22) || (x11 <= x21 && y11 == y21 && x12 >= x22 && y12 > y22)) {
                printf("3\n");
                continue;
            }
            if((x11 >= x21 && y11 > y21 && x12 <= x22 && y12 == y22) || (x11 <= x21 && y11 < y21 && x12 >= x22 && y12 == y22)) {
                printf("3\n");
                continue;
            }
            
            
            if((x11 > x21 && y11 < y21 && x12 < x22 && y12 > y22) || (x11 < x21 && y11 > y21 && x12 > x22 && y12 < y22)) {
                printf("6\n");
                continue;
            }
            
            if((x12 < x22 && y12 == y22 && x11 > x21 && y11 < y21) || (x12 > x22 && y12 == y22 && x11 < x21 && y11 > y21)) {
                printf("5\n");
                continue;
            }
            if((x12 < x22 && y12 > y22 && x11 > x21 && y11 == y21) || (x12 > x22 && y12 < y22 && x11 < x21 && y11 == y21)) {
                printf("5\n");
                continue;
            }
            
            if((x12 == x22 && y12 < y22 && x11 < x21 && y11 > y21) || (x12 == x22 && y12 > y22 && x11 > x21 && y11 < y21)) {
                printf("5\n");
                continue;
            }
            if((x12 > x22 && y12 < y22 && x11 == x21 && y11 > y21) || (x12 < x22 && y12 > y22 && x11 == x21 && y11 < y21)) {
                printf("5\n");
                continue;
            }
            
            
            printf("4\n");
         
    }
    return 0;
}

 

你可能感兴趣的:(计算几何)