#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; }
我打印出的结果是这样的,但是无法AC
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:529 |
点我有惊喜!你懂得!浏览:2073 |
C语言考试练习题_排列 (C++代码)浏览:631 |
【数组的距离】 (C语言代码)浏览:728 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:519 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:567 |
WU-格式化数据输出 (C语言代码)浏览:1748 |
三角形 (C++代码)记忆化搜索浏览:1222 |
蛇行矩阵 (C语言代码)浏览:524 |
简单的a+b (C语言代码)浏览:415 |