Topic Description
"I'm super big sand Tea"--mato_no1
In order to prove that he is a super large sand tea, Mato god Benniu decided to show his fork (cross type) how understanding.
The Mato God Benniu has a planar rectangular coordinate system with a number of segments that ensure that these segments are at least parallel to one axis. Mato God Benniu need to point out how large these segments constitute the largest cross type.
A shape is called a cross of the size R (r is a positive integer), when and only if the shape has a central point, it exists on a segment, and the segment that extends from the point to the top and bottom of the length of R is covered by the existing segment.
You can assume that no two collinear line segments have a common point and no overlapping segments. train of Thought
Violent judgment
Sort the length of a segment from large to small
Obviously, if the ans > len/2 then all of the line segments will not meet the conditions, so the direct break off will be OK
#include <stdio.h> #include <algorithm> using namespace std; #define MAXN 100001 struct ARR {int x1, y1, x2, Y2, W;}
A[MAXN];
Arr B[MAXN];
int abs (int x) {if (x < 0) return-x;
return x;
int CMP (arr A, arr b) {return A.W > B.W;} int minn (int a, int b, int c,int d) {int t = 0x7fffffff;
if (a < T) T = A;
if (b < T) T = B;
if (C < T) T = C;
if (D < T) T = D;
return t;
int main () {int n;
scanf ("%d", &n);
int L = 0, r = 0;
for (int i = 1; I <= n; i++) {int x1, y1, x2, y2;
scanf ("%d%d%d%d", &x1, &y1, &x2, &y2);
if (x1 = = x2) {int w = ABS (Y1-Y2);
if (y1 > y2) {y1 ^= y2; y2 ^= y1; y1 ^= y2;}
A[++l] = (arr) {x1, y1, x2, Y2, w};
else {int w = ABS (X1-X2);
if (X1 > x2) {x1 ^= x2; x2 ^= x1; x1 ^= x2;} B[++r] = (arr) {x1, y1, x2, y2, w};
} sort (A + 1, a + L + 1, CMP);
Sort (b + 1, B + R + 1, CMP);
int ans = 0; for (int i = 1; I <= R i++) {for (int j = 1; J <= L; j +) {if A[J].W/2 < an
s) break;
if (B[i].x1 < a[j].x1 && b[i].x2 > a[j].x2 && b[i].y1 > A[j].y1 && b[i].y2 < A[j].y2)
{int x = a[j].x1, y = b[i].y1;
int t = Minn (a[j].y2-y, Y-a[j].y1, B[i].x2-x, x-b[i].x1); ans = ans > t?
Ans:t;
} if (B[i].w/2 < ans) break;
} if (ans = = 0) printf ("Human intelligence is really terrible\n");
else printf ("%d\n", ans); }