【链接】
https://codeforces.com/problemset/problem/1028/C
【题意】
找一个点,使得至少与(n-1)个矩形有交
【思路】
每两个矩形求交会有一个面积并,但是要判断是否合法。暴力枚举每个矩形,计算不包含这个矩形的前后缀,求解。
【代码】
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5+3;struct node{int x1, y1, x2, y2;node operator + (const node &r)const {return { max(x1, r.x1), max(y1, r.y1), min(x2, r.x2), min(y2, r.y2)};}
}k[maxn],A[maxn],B[maxn];int main() {int n;scanf("%d", &n);for (int i = 1; i <= n; i++) {scanf("%d%d%d%d", &k[i].x1, &k[i].y1, &k[i].x2, &k[i].y2);}A[1] = k[1]; B[n] = k[n];for (int i = 2; i <= n; i++) {A[i] = A[i - 1] + k[i];}for (int i = n - 1; i; i--) {B[i] = B[i + 1] + k[i];}for (int i = 1; i <= n; i++) {node now;if (i == 1)now = B[2];else if (i == n)now = A[n - 1];else now = A[i - 1] + B[i + 1];if (now.x1 <= now.x2&&now.y1 <= now.y2) {printf("%d %d", now.x1, now.y1);return 0;}}return 0;
}