Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
using namespace std;
const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
bool f(int a){
if((a)>5000){
return false;
}else{
return true;
}
}
bool z[5001][5001];
vi xz,yz;
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n;
while(1){
cin >> n;if(n==0)break;
xz.clear();
yz.clear();
rep(i,0,5001){
rep(j,0,5001){
z[i][j]=false;
}
}
rep(i,0,n){
int x,y;
cin >> x >> y;
z[x][y]=1;
xz.pb(x);
yz.pb(y);
}
int ans=0;
rep(i,0,n){
rep(j,0,n){
if(i==j)continue;
int X=abs(xz[i]-xz[j]);
int Y=abs(yz[i]-yz[j]);
int an=X*X+Y*Y;
if(ans>an)continue;
if(f(xz[i]+Y)&&f(yz[i]+X)&&f(xz[j]+Y)&&f(yz[j]+X)){
if((z[xz[i]+Y][yz[i]+X]&&z[xz[j]+Y][yz[j]+X])){
ans=max(ans,an);
}
}
}
}
cout << ans << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.