题目链接:http://acm.uestc.edu.cn/#/problem/show/1265
思路:因为城市是正方形,所以说取x轴的最大差值和y轴的最大差值的最大值,然后平方
ac代码:
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define MAXN 1010000
#define LL long long
#define ll __int64
#define INF 0x7fffffff
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
#define mod 1000000007
using namespace std;
int main()
{
int n,i;
int a,b;
while(scanf("%d",&n)!=EOF)
{
int mx=-INF,my=-INF;
int mix=INF,miy=INF;
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
//printf("%d %d\n",a,b);
mx=max(mx,a);
mix=min(mix,a);
my=max(my,b);
miy=min(miy,b);
}
//printf("%lld %lld %lld %lld\n",mix,miy,mx,my);
LL ans=max(fabs(mix-mx),fabs(miy-my));
printf("%lld\n",ans*ans);
}
return 0;
}