日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

1069: [SCOI2007]最大土地面积|旋转卡壳

發(fā)布時(shí)間:2024/1/17 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1069: [SCOI2007]最大土地面积|旋转卡壳 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

旋轉(zhuǎn)卡殼就是先求出凸包。然后在凸包上枚舉四邊形的對(duì)角線兩側(cè)分別找面積最大的三角形
因?yàn)樵趦蓚?cè)找面積最大的三角形的頂點(diǎn)是單調(diào)的所以復(fù)雜度就是n2
單調(diào)的這個(gè)性質(zhì)能夠自行繪圖感受一下,似乎比較顯然

#include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<vector> #include<cmath> #include<queue> #include<set> #include<map> #define ll long long #define N 2002 using namespace std; struct W{double x,y;}a[N],st[N]; int n,top; W operator-(W a,W b) {return (W){a.x-b.x,a.y-b.y}; } double dis(W a,W b) {return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } double operator*(W a,W b) {return a.x*b.y-a.y*b.x; } bool operator<(W c,W d) {double t=(c-a[1])*(d-a[1]);if(t==0)return dis(c,a[1])<dis(d,a[1]);return t<0; } void Graham() {int k=1;for(int i=2;i<=n;i++)if(a[k].y>a[i].y||(a[k].y==a[k].y&&a[k].x>a[i].x))k=i;swap(a[k],a[1]);sort(a+1,a+n+1);st[++top]=a[1],st[++top]=a[2];for(int i=3;i<=n;i++){while(top>1&&(a[i]-st[top-1])*(st[top]-st[top-1])<=0)top--;st[++top]=a[i];} } double Rotating_caliper() {double mx=0;st[top+1]=a[1];int a,b;for(int x=1;x<=top;x++){a=x%top+1,b=(x+2)%top+1;for(int y=x+2;y<=top;y++){while(a%top+1!=y&&(st[y]-st[x])*(st[a+1]-st[x])>(st[y]-st[x])*(st[a]-st[x]))a=a%top+1;while(b%top+1!=x&&(st[b+1]-st[x])*(st[y]-st[x])>(st[b]-st[x])*(st[y]-st[x]))b=b%top+1;mx=max(mx,(st[y]-st[x])*(st[a]-st[x])+(st[b]-st[x])*(st[y]-st[x]));}}return mx; } int main() {scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lf%lf",&a[i].x,&a[i].y);Graham();printf("%.3lf",Rotating_caliper()/2);return 0; }

總結(jié)

以上是生活随笔為你收集整理的1069: [SCOI2007]最大土地面积|旋转卡壳的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。