Ideas
There are two cases of compliance with FJ: three straight lines parallel or two straight lines parallel and perpendicular to a straight line. As for the problem of the vertical and horizontal, you can reverse the cow's coordinates into the same way.
Three Parallel lines:
Record the horizontal axis of all points, if the number of different horizontal axis is less than or equal to 3, then meet the conditions. Two parallel perpendicular to a straight line:
Put all the ordinate and the number of them, also note all the appearance of the ordinate number, and then in accordance with the horizontal order, and then enumerate a horizontal axis A, indicating that the line x=a and the other two horizontal lines perpendicular, and then the line of all the ordinate CNT--, then see the number of vertical axis, if <=2, the explanation is established .
The standard process is much more refined than mine, so I'll put it on the mark ...
#include <cstdio> #include <cstring> #include <map> #include <algorithm> using namespace std;
const int MAXN = 1001000;
Pair<int,int> LIS[MAXN];
Map<int, int> cou;
int distinct;
int n;
VOID Inc (int x) {if (cou[x] = = 0) {distinct++;//different ordinate numbers} cou[x] = cou[x] + 1;}
void Dec (int x) {cou[x] = cou[x]-1;
if (cou[x] = = 0) distinct--;
} int Moo () {sort (lis, Lis + N);//Sort, place the same horizontal axis together distinct = 0;
Cou.clear ();
for (int i = 0; i < n; ++i) {Inc (Lis[i].second);
} if (distinct <= 3) return 1;//three parallel int i = 0, i1 = 0;
while (I < n) {while (I1 < n && lis[i].first = = Lis[i1].first) i1++;
for (int i2 = i; i2 < i1; ++i2) Dec (lis[i2].second);//delete all ordinate if on a vertical line (distinct <= 2) return 1;
for (int i2 = i; i2 < I1; ++i2) Inc (Lis[i2].second);
i = I1;
} return 0;
} int main () {scanf ("%d", &n);
for (int i = 0; i < n; ++i) scanf ("%d%d", &lis[i].first, &lis[i].second);
if (Moo ()) {puts ("1");
} else {for (int i = 0; i < n; ++i) {swap (Lis[i].first, lis[i].second);//Invert coordinates} if (Moo ()) puts ("1");
Else puts ("0");
} return 0;
}