http://www.lydsy.com/JudgeOnline/problem.php?id=1340

const int N = 1009, M = int(4e6) + 9; //struct Network_Flow{ int D[N], hd[N], suc[M], to[M], cap[M]; int n, m, s, t; inline void ae(int x, int y, int c){ suc[m] = hd[x], hd[x] = m, to[m] = y, cap[m++] = c, suc[m] = hd[y], hd[y] = m, to[m] = x, cap[m++] = 0; } inline void aee(int x, int y, int c){ suc[m] = hd[x], hd[x] = m, to[m] = y, cap[m++] = c, suc[m] = hd[y], hd[y] = m, to[m] = x, cap[m++] = c; } #define v to[i] #define c cap[i] #define f cap[i^1] LL sap(){ LL z=0; static int cnt[N],cur[N],pre[N]; fill(D,D+n,n),fill(cnt,cnt+n,0);cnt[n]=n; int u=s;cur[s]=hd[s];while (D[s]){ #define i cur[u] if (u==t){ int d=INF;for(u=s;u!=t;u=v)checkMin(d,c); z+=d;for(u=s;u!=t;u=v)f+=d,c-=d;u=s; } #undef i int i;for(i=cur[u];i;i=suc[i]){ if(D[u]+1==D[v]&&c){cur[u]=i,cur[v]=hd[v],pre[v]=u,u=v;break;} } if (!i){ if (!--cnt[D[u]])break; D[u]=1;REP_G(i,u)if(c)checkMax(D[u],D[v]);--D[u]; ++cnt[D[u]];if(u==s)cur[u]=hd[u];else u=pre[u]; } } return z; } #undef f #undef c #undef v //} G; int L, W; int xx[N], yy[N]; void init(){ RD(L, W); RD(n); REP_1(i, n) RD(xx[i], yy[i]); s = 0, t = 2*n + 1, m = 2; REP_1(i, n){ ae(2*i-1,2*i,1); if (yy[i] <= 100) ae(s, 2*i-1, INF); if (yy[i] >= W - 100) ae(2*i, t, INF); FOR_1(j, i+1, n) if (sqr(xx[i]-xx[j]) + sqr(yy[i]-yy[j]) <= sqr(200)){ ae(2*i, 2*j-1, INF); ae(2*j, 2*i-1, INF); } } n = t + 1; } int main(){ #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif init(); OT(sap()); }