最远曼哈顿距离有两个性质:
1: 对每一个点(x,y) 分别计算 +x+y , -x+y , x-y , -x-y 然后统计每种组合的最大值就能够了, 不会对结果产生影响
2: 去掉绝对值 , 设正号为0负号为1 则 两个点的符号是能够通过异或的得到的.
如两个点 P(x,y) 和 Q(a,b) 若去掉绝对值符号后P的两个坐标为 -x +y 既相应数字 10 那么Q相应的数字则为 01 既 +a -b 两个点的曼哈顿距离为 -x +y +a -b
/* ***********************************************
Author :CKboss
Created Time :2015年03月13日 星期五 20时17分17秒
File Name :CF491B.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
const LL INF=1LL<<60;
LL n,m;
LL C,H;
LL a00,a01,a10,a11;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
cin>>n>>m;
cin>>C;
bool first=true;
while(C--)
{
LL x,y;
cin>>x>>y;
if(first)
{
first=false;
a00=x+y; a10=-x+y; a01=x-y; a11=-x-y;
}
else
{
a00=max(a00,x+y); a10=max(a10,-x+y);
a01=max(a01,x-y); a11=max(a11,-x-y);
}
}
LL d=INF,pos,cnt=1;
cin>>H;
while(H--)
{
LL x,y;
cin>>x>>y;
/// four director
LL mx = max( max( x+y+a11, -x-y+a00 ) , max( -x+y+a01 , x-y+a10 ) );
if(mx<d) { d=mx; pos = cnt; }
cnt++;
}
cout<<d<<endl<<pos<<endl;
return 0;
}