在Subtask#1中的第一个点,以下代码在开O2后TLE寄了,没开的时候27ms过咧,有没有dalao看看为啥,还有就是能不能帮我看看怎么卡过第二个点((( 球球
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x;bool f;char ch;
for(f=0;!isdigit(ch=getchar());f=ch=='-');
for(x=ch-48;isdigit(ch=getchar());x=x*10+ch-48);
return f?-x:x;
}
inline void print(long long x,char las) {
if(!x) {
putchar('0'),putchar(las);
return ;
}
if(x<0) putchar('-'),x=-x;
int ls[23],k=0;
while(x) ls[++k]=x%10,x/=10;
while(k) putchar(ls[k--]+48);
putchar(las);
return ;
}
struct node {
long long x,y;
inline bool operator<(const node&ls) const {
return x!=ls.x ? x<ls.x : y<ls.y;
}
inline node operator -(const node&ls) const {
return {x-ls.x,y-ls.y};
}
inline long long operator*(const node&ls) const {
return x*ls.y-ls.x*y;
}
inline long long ks() {
return x*x+y*y;
}
}nd[50001];
int n=read(),st[50001],tp;
int main() {
for(int i=1;i<=n;i++) nd[i].x=read(),nd[i].y=read();
sort(nd+1,nd+n+1);
st[++tp]=1;
for(int i=2;i<=n;i++) {
while(tp>=2 && (nd[i]-nd[st[tp]])*(nd[st[tp]]-nd[st[tp-1]])>0) tp--;
st[++tp]=i;
}
for(int i=n-1;i>=1;i--) {
while(tp>=2 && (nd[i]-nd[st[tp]])*(nd[st[tp]]-nd[st[tp-1]])>0) tp--;
st[++tp]=i;
}
if(tp==2) {
print((nd[n]-nd[1]).ks(),'\n');
return 0;
}
long long ans=0;
for(int i=1;i<tp;i++)
for(int j=i+1;j<tp;j++) ans=max(ans,(nd[st[j]]-nd[st[i]]).ks());
print(ans,'\n');
return 0;
}