满足三个条件之一就可以了,也不必是最小的集合。即任意两点在同一水平或垂直线上,或者在一个长方形框架上,但是还有其他的点在这个框架的内部或者边缘上,但是由于限制了点最多不能超过2*100000,所以不能强行填满。
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<set>
#define X first
#define Y second
using namespace std;
typedef pair<int,int>ii;//pair <int,int>是一个键值对// 键是int类型,值是int类型
set<ii>s;//然后这种类型的变量组成一个set,也就是集合//这个集合的变量叫s
ii a[10020];
int n;
void F(int l,int r)
{
if(l+1==r)
return;
int m=l+r>>1;
for(int i=l;i<r;i++)
s.insert(ii(a[m].X,a[i].Y));
F(l,m),F(m,r);
}
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d %d",&a[i].X,&a[i].Y),s.insert(a[i]);
sort(a,a+n);
F(0,n);
printf("%d\n",s.size());
for(set<ii>::iterator i=s.begin();i!=s.end();i++)
printf("%d %d\n",i->X,i->Y);
return 0;
}