无心小男


私信TA

用户名:uq_50395433181

访问量:1636

签 名:

等  级
排  名 1329
经  验 2867
参赛次数 0
文章发表 4
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

#include<iostream>
//#include<bits/stdc++.h>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<malloc.h>
#include<sstream>
#include<string.h>
#include<ctime> 
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

bool cmp(int a, int b) {
    return a > b;
}

struct REC {
    int x1;
    int y1;
    int x2;
    int y2;
};

struct REC rec[10005];

int area_rec(struct REC a, struct REC b) {
    int area;
    int x1, y1;
    int x2, y2;
    x1 = max(a.x1, b.x1);
    y1 = max(a.y1, b.y1);
    x2 = min(a.x2, b.x2);
    y2 = min(a.y2, b.y2);
    if (x2 > x1 && y2 > y1) {
        area = (x2 - x1) * (y2 - y1);
    }
    else
        area = 0;
    return area;
}

int main() {
    int T;
    int n;
    int num[10005];
    int region[10005];
    memset(num, 0, sizeof(num));
    memset(region, 0, sizeof(region));
    cin >> T;
    while (T--) {
        
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> rec[i].x1 >> rec[i].y1 >> rec[i].x2 >> rec[i].y2;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j) { //自己和自己不做判定
                    int area = area_rec(rec[i], rec[j]);
                    if (area != 0) {
                        region[i]++;
                        num[i] += area;
                    }
                }
            }
        }
        for (int i = 0; i < n; i++) {
            cout << region[i] << " " << num[i] << endl;
        }
    }
    
    return 0;
}

QQ截图20210323142555.jpg

我打印出的结果是这样的,但是无法AC

 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区