# bzoj1052 [HAOI2007]覆盖问题 - 贪心

4
0 1
0 -1
1 0
-1 0

1

100%的数据，N<=20000

## 题解

 1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cstdlib>
5 #include<set>
6 #include<ctime>
7 #include<queue>
8 #include<cmath>
9 #include<algorithm>
10 #define inf 1000000000
11 #define ll long long
12 using namespace std;
14 {
15     int x=0,f=1;char ch=getchar();
16     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
17     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
18     return x*f;
19 }
20 int n,L,mid;
21 struct data{int x[20005],y[20005],top;}a,b;
22 void cut(data &a,int x1,int y1,int x2,int y2)
23 {
24     int tot=0;
25     for(int i=1;i<=a.top;i++)
26         if(a.x[i]<x1||a.x[i]>x2||a.y[i]<y1||a.y[i]>y2)
27         {
28             tot++;
29             a.x[tot]=a.x[i];
30             a.y[tot]=a.y[i];
31         }
32     a.top=tot;
33 }
34 void solve(data &a,int fc)
35 {
36     int x1=inf,y1=inf,x2=-inf,y2=-inf;
37     for(int i=1;i<=a.top;i++)
38     {
39         x1=min(a.x[i],x1),x2=max(a.x[i],x2);
40         y1=min(a.y[i],y1),y2=max(a.y[i],y2);
41     }
42     if(fc==1)
43         cut(a,x1,y1,x1+mid,y1+mid);
44     if(fc==2)
45         cut(a,x2-mid,y1,x2,y1+mid);
46     if(fc==3)
47         cut(a,x1,y2-mid,x1+mid,y2);
48     if(fc==4)
49         cut(a,x2-mid,y2-mid,x2,y2);
50 }
51 bool jud()
52 {
53     data b;
54     for(int x=1;x<=4;x++)
55         for(int y=1;y<=4;y++)
56         {
57             b.top=a.top;
58             for(int i=1;i<=b.top;i++)
59                 b.x[i]=a.x[i],b.y[i]=a.y[i];
60             solve(b,x);solve(b,y);
61             int x1=inf,y1=inf,x2=-inf,y2=-inf;
62             for(int i=1;i<=b.top;i++)
63             {
64                 x1=min(b.x[i],x1),x2=max(b.x[i],x2);
65                 y1=min(b.y[i],y1),y2=max(b.y[i],y2);
66             }
67             if(x2-x1<=mid&&y2-y1<=mid)return 1;
68         }
69     return 0;
70 }
71 int main()
72 {
74     for(int i=1;i<=a.top;i++)
84 }