#include<cmath>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;

struct edge {
int x,y,next;
edge(){}
edge(int _x,int _y,int _nt):x(_x),y(_y),next(_nt){}
} e[ 1000005 ];
inline void addedge(int x,int y) {
}
bool ins[2000];
int inc[2000],dfn[2000],low[2000],SCC,T;
stack<int>sta;
void tarjan(int x){
dfn[x] = low[x] = ++T;
sta.push(x); ins[x] = 1;
for (int i = head[x]; i; i = e[i].next) {
int y = e[i].y;
if( ! dfn[y] ) {
tarjan(y);
low[x] = min(low[x], low[y]);
}else if( ins[y] && dfn[y] < low[x]) low[x] = dfn[y];
}
if( low[x] == dfn[x] ){
SCC++;
while(1) {
int y = sta.top(); sta.pop(); ins[y] = 0;
inc[y] = SCC;
if (x == y ) break;
}
}
}
struct point {
int x,y;
point(){}
point(int _x,int _y):x(_x),y(_y){}
} a[2005],s[3];
int dis(point a,point b) {
return abs(a.x-b.x) + abs(a.y-b.y);
}
int N,A,B;
int e1[2005][2],e2[2005][2];
int d1[2005],d2[2005],d12;
bool judge(int d) {
tot = 0;

for (int i = 1; i <= A; i++) {
}
for (int i = 1; i <= B; i++) {
}
for (int i = 1; i <= N; i++) for (int j = i+1; j <= N; j++) {
if ( d1[i] + d1[j] > d ) {
}
if ( d2[i] + d2[j] > d ) {
}
if ( d1[i] + d12 + d2[j] > d ) {
}
if ( d2[i] + d12 + d1[j] > d ) {
}
}
SCC = 0; T = 0;
memset(ins,0,sizeof ins);
memset(dfn,0,sizeof dfn);
for (int i = 1; i <= N<<1; i++) if( ! dfn[i] ) tarjan(i);
for (int i = 1; i <= N; i++)
if( inc[i] == inc[i+N] ) return 0;
return 1;
}
int main() {
scanf("%d%d%d",&N,&A,&B);
scanf("%d%d%d%d",&s[1].x,&s[1].y,&s[2].x,&s[2].y);
int L = 0x3f3f3f3f,R = -1 ,mid,ans;
d12 = dis(s[1],s[2]);
for (int i = 1; i <= N; i++) {
scanf("%d%d",&a[i].x,&a[i].y);
d1[i] = dis(a[i], s[1]);
d2[i] = dis(a[i], s[2]);
L = min(L,min(d1[i],d2[i]));
R = max(R,max(d1[i],d2[i]));
}
L <<= 1, (R<<=1)+= d12, ans = 0x3f3f3f3f;
for (int i = 1; i <= A; i++) scanf("%d%d",&e1[i][0],&e1[i][1]);
for (int i = 1; i <= B; i++) scanf("%d%d",&e2[i][0],&e2[i][1]);
while( L <= R) {
int mid = (L + R) >> 1;
if( judge(mid) ) ans = mid,R=mid-1;
else L = mid + 1;
}
if( ans == 0x3f3f3f3f ) ans = -1;
printf("%d\n",ans);
}

• 本文已收录于以下专栏：

举报原因： 您举报文章：Poj2749 Building Roads 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)