1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| #include <bits/stdc++.h>
using namespace std; typedef long long ll; typedef unsigned long long ull; const int INF = 0x3f3f3f3f; const int N = 1e5 + 5; const int mod = 998244353; struct node{ int x1, y1, x2, y2; ll sum, s; }arc[5005]; int x01, x02, y01, y02; int main(){ int t, n; cin >> t; while(t--){ cin >> n; for (int i = 1; i <= n; i++){ arc[i].sum= 0; arc[i].s = 0; cin >> arc[i].x1 >> arc[i].y1 >> arc[i].x2 >> arc[i].y2; for (int j = 1; j < i; j++){ x01 = max(min(arc[i].x1, arc[i].x2), min(arc[j].x1, arc[j].x2)); x02 = min(max(arc[i].x1, arc[i].x2), max(arc[j].x1, arc[j].x2)); y01 = max(min(arc[i].y1, arc[i].y2), min(arc[j].y1, arc[j].y2)); y02 = min(max(arc[i].y1, arc[i].y2), max(arc[j].y1, arc[j].y2)); if (x01 < x02 && y01 < y02){ arc[i].sum++; arc[i].s += (x02 - x01) * (y02 - y01); arc[j].sum++; arc[j].s += (x02 - x01) * (y02 - y01); } } } for (int i = 1; i <= n; i++){ cout << arc[i].sum << ' ' << arc[i].s << "\n"; }
} return 0; }
|