版本比较
大白都能看懂的黑题题解
正文
增加 24 行删除 24 行
69 行未改动707172737474757677788 行未改动878889909191929394959697989910010197989910010110210310410510610610710810911022 行未改动13313413513613713813914013713813914014114214314414514614614714814915044 行未改动1951961971981991992002012022032032042052062072082072082092102112122132142152162162172182192202192202212222232244 行未改动22923023123223323423523323423523623723823924024124224324424524524624724824917 行未改动69 行未改动 ff string readString(){char c;string s="";while(true){c=getch();if(c!=' '&&c!='\n'&&c!='\r') break;}while(c!=' '&&c!='\n'&&c!='\r') s+=c,c=getch();return s;} ff void putch(char c){Put[cnt++]=c;if(cnt==Msize)flush();} ff void putInt(int x){char sout[20];int top=0;if(x<0) putch('-'),x=-x;if(x==0) putch('0');while(x) sout[++top]=(x%10+'0'),x/=10;while(top) putch(sout[top--]);} ff void putChar(char c){putch(c);} ff void putString(string s){for(int i=0;i<s.size();i++){putch(s[i]);}} ff void putString(string s){for(int i=0;i<s.size();i++){putch(s[i]);}} struct Basic{ Basic &operator>>(int &A){A=IO::readInt();return (*this);} Basic &operator>>(char &A){A=IO::readChar();return (*this);} Basic &operator>>(string& A){A=IO::readString();return (*this);}8 行未改动struct point{ int x,y;}a[N],b[N],k;int n,m,cnt,T;bool cmp(point a,point b){//坐标排序,找到最坐下的点 bool cmp(point a,point b){//坐标排序,找到最坐下的点 if(a.y!=b.y){ return a.y<b.y; } return a.x<b.x;}bool cmp1(point a,point b){//斜率计算 point la={a.x-k.x,a.y-k.y};//相对位置(a和p[1]) point lb={b.x-k.x,b.y-k.y};//相对位置(b和p[1]) int isline=la.x*lb.y-la.y*lb.x;//判断斜率 if(isline==0){//三点共线 bool cmp1(point a,point b){//斜率计算 point la={a.x-k.x,a.y-k.y};//相对位置(a和p[1]) point lb={b.x-k.x,b.y-k.y};//相对位置(b和p[1]) int isline=la.x*lb.y-la.y*lb.x;//判断斜率 if(isline==0){//三点共线 double lena=sqrt((a.x-k.x)*(a.x-k.x)+(a.y-k.y)*(a.y-k.y)); double lenb=sqrt((b.x-k.x)*(b.x-k.x)+(b.y-k.y)*(b.y-k.y)); return lena<lenb; }else{ return isline>0;//斜率更小 return isline>0;//斜率更小 }}bool check1(point a,point b){ int isline=(a.x-0)*(b.y-0)-(a.y-0)*(b.x-0);22 行未改动 t[++len]=1,t[++len]=2; for(int i=3;i<=n;i++){ while(len>1){ int p1=t[len],p2=t[len-1],pi=i; point la={p[pi].x-p[p2].x,p[pi].y-p[p2].y};//新点与上上个点的相对位置 point lb={p[p1].x-p[p2].x,p[p1].y-p[p2].y};//上个点与上上个点的相对位置 int isline=la.x*lb.y-la.y*lb.x;//判断斜率 if(isline>=0){//拥有最优解,最后一个点出栈; point la={p[pi].x-p[p2].x,p[pi].y-p[p2].y};//新点与上上个点的相对位置 point lb={p[p1].x-p[p2].x,p[p1].y-p[p2].y};//上个点与上上个点的相对位置 int isline=la.x*lb.y-la.y*lb.x;//判断斜率 if(isline>=0){//拥有最优解,最后一个点出栈; len--; }else{ break; } } t[++len]=i;//新点构成凸包 t[++len]=i;//新点构成凸包 } n=len; for(int i=1;i<=len;i++){ //cout<<t[i]<<" ";44 行未改动 }//cout<<endl; return l-1;}bool query1(point u){ //如果该点y坐标为负,显然不在凸包内,因为起始点的y坐标是所有点内最低的 //如果该点y坐标为负,显然不在凸包内,因为起始点的y坐标是所有点内最低的 if(u.y<0){ return 1; } //如果该点斜率比第二个要大,说明在凸包内 //如果该点斜率比第二个要大,说明在凸包内 int isline1=u.x*s[2].y-u.y*s[2].x; //cout<<"ask"<<isline1<<" "<<isline2<<" "<<u*s[2]<<" "<<s[cnt]*u<<endl; if(isline1==0){ double lena=sqrt((u.x-0)*(u.x-0)+(u.y-0)*(u.y-0)); double lenb=sqrt((s[2].x-0)*(s[2].x-0)+(s[2].y-0)*(s[2].y-0)); double lena=sqrt((u.x-0)*(u.x-0)+(u.y-0)*(u.y-0)); double lenb=sqrt((s[2].x-0)*(s[2].x-0)+(s[2].y-0)*(s[2].y-0)); //cout<<"ask"<<lena<<" "<<lenb<<" "<<calc(u,O)<<" "<<calc(s[2],O)<<endl; if(lena>lenb){ return true; } }else if(isline1>0){ return true; } //如果该点斜率比第cnt个要大,说明在凸包内 //如果该点斜率比第cnt个要大,说明在凸包内 int isline2=s[cnt].x*u.y-s[cnt].y*u.x; if(isline2==0){ double lena=sqrt((u.x-0)*(u.x-0)+(u.y-0)*(u.y-0)); double lenb=sqrt((s[cnt].x-0)*(s[cnt].x-0)+(s[cnt].y-0)*(s[cnt].y-0)); double lena=sqrt((u.x-0)*(u.x-0)+(u.y-0)*(u.y-0)); double lenb=sqrt((s[cnt].x-0)*(s[cnt].x-0)+(s[cnt].y-0)*(s[cnt].y-0)); //cout<<"ask"<<lena<<" "<<lenb<<" "<<calc(u,O)<<" "<<calc(s[cnt],O)<<endl; if(lena>lenb){ return true; }4 行未改动 int w=half(u); //cout<<"ask1"<<w<<" ";// cout<<"928374"<<" "<<w<<" ";// cout<<w<<endl; point la={u.x-s[w].x,u.y-s[w].y};//点与右点的相对位置 point lb={s[w+1].x-s[w].x,s[w+1].y-s[w].y};//左点与右点的相对位置 int isline3=la.x*lb.y-la.y*lb.x;//判断斜率 point la={u.x-s[w].x,u.y-s[w].y};//点与右点的相对位置 point lb={s[w+1].x-s[w].x,s[w+1].y-s[w].y};//左点与右点的相对位置 int isline3=la.x*lb.y-la.y*lb.x;//判断斜率 return isline3>0;}signed main(){ cin>>n>>m>>T; for(int i=1;i<=n;i++){ cin>>a[i].x>>a[i].y; } for(int i=1;i<=m;i++){ cin>>b[i].x>>b[i].y; b[i].x*=-1,b[i].y*=-1;//基于最终的式子,b要取负 b[i].x*=-1,b[i].y*=-1;//基于最终的式子,b要取负 }// for(int i=1;i<=m;i++){// cout<<"b:"<<b[i].x<<" "<<b[i].y<<endl;// }17 行未改动