QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#726432 | #9581. 都市叠高 | lonelywolf# | AC ✓ | 24ms | 4200kb | C++20 | 27.5kb | 2024-11-09 00:25:35 | 2024-11-09 00:25:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using db = double;
mt19937 eng(time(0));
const db eps=1e-6;
const db pi=acos(-1);
int sgn(db k) {
if (k > eps) return 1;
else if (k < -eps) return -1;
return 0;
}
// -1: < | 0: == | 1: >
int cmp(db k1, db k2) { return sgn(k1 - k2); }
// k3 in [k1, k2]
int inmid(db k1, db k2, db k3) { return sgn(k1-k3) * sgn(k2-k3) <= 0; }
// 点 (x, y)
struct point{
db x, y;
point operator + (const point &k1) const { return (point){k1.x+x,k1.y+y}; }
point operator - (const point &k1) const { return (point){x-k1.x,y-k1.y}; }
point operator * (db k1) const { return (point){x*k1,y*k1}; }
point operator / (db k1) const { return (point){x/k1,y/k1}; }
int operator == (const point &k1) const { return cmp(x,k1.x)==0&&cmp(y,k1.y)==0; }
// 逆时针旋转 k1 弧度
point rotate(db k1) {return (point){x*cos(k1)-y*sin(k1),x*sin(k1)+y*cos(k1)};}
// 逆时针旋转 90°
point rotleft() { return (point){-y,x}; }
// 优先比较 x 坐标
bool operator < (const point k1) const {
int a=cmp(x,k1.x);
if (a==-1) return 1; else if (a==1) return 0; else return cmp(y,k1.y)==-1;
}
// 模长
db abs() { return sqrt(x*x+y*y); }
// 模长的平方
db abs2() { return x*x+y*y; }
// 与点 k1 的距离
db dis(point k1) {return ((*this)-k1).abs();}
// 化为单位向量, require: abs() > 0
point unit() {db w=abs(); return (point){x/w,y/w};}
// 读入
void scan() {double k1,k2; scanf("%lf%lf",&k1,&k2); x=k1; y=k2;}
// 输出
void print() {printf("%.11lf %.11lf\n",x,y);}
// 方向角 atan2(y, x)
db getw() {return atan2(y,x);}
// 将向量对称到 (-pi, pi] 半平面中
point getdel() {if (sgn(x)==-1||(sgn(x)==0&&sgn(y)==-1)) return (*this)*(-1); else return (*this);}
// (-pi, 0] -> 0, (0, pi] -> 1
int getP() const {return sgn(y)==1||(sgn(y)==0&&sgn(x)==-1);}
};
/* 点与线段的位置关系及交点 */
// k3 在 矩形 [k1, k2] 中
int inmid(point k1,point k2,point k3){ return inmid(k1.x,k2.x,k3.x) && inmid(k1.y,k2.y,k3.y); }
db cross(point k1,point k2) { return k1.x*k2.y-k1.y*k2.x; }
db dot(point k1,point k2) { return k1.x*k2.x+k1.y*k2.y; }
// 从 k1 转到 k2 的方向角
db rad(point k1,point k2) {return atan2(cross(k1,k2),dot(k1,k2)); }
// k1 k2 k3 逆时针 1 顺时针 -1 否则 0
int clockwise(point k1,point k2,point k3){
return sgn(cross(k2-k1,k3-k1));
}
// 按 (-pi, pi] 顺序进行极角排序
int cmpangle (point k1,point k2){
return k1.getP()< k2.getP()||(k1.getP()==k2.getP()&&sgn(cross(k1,k2))>0);
}
// 点 q 在线段 k1, k2 上
int onS(point k1,point k2,point q){return inmid(k1,k2,q)&&sgn(cross(k1-q,k2-k1))==0;}
// q 到直线 k1,k2 的投影
point proj(point k1,point k2,point q) {
point k=k2-k1; return k1+k*(dot(q-k1,k)/k.abs2());
}
// q 关于直线 k1,k2 的镜像
point reflect(point k1,point k2,point q) {return proj(k1,k2,q)*2-q;}
// 判断 直线 (k1, k2) 和 直线 (k3, k4) 是否相交
int checkLL(point k1,point k2,point k3,point k4){
return cmp(cross(k3-k1,k4-k1),cross(k3-k2,k4-k2))!=0;
}
// 求直线 (k1, k2) 和 直线 (k3, k4) 的交点
point getLL(point k1,point k2,point k3,point k4){
db w1=cross(k1-k3,k4-k3),w2=cross(k4-k3,k2-k3);
return (k1*w2+k2*w1)/(w1+w2);
}
int intersect(db l1,db r1,db l2,db r2){
if (l1>r1) swap(l1,r1); if (l2>r2) swap(l2,r2); return cmp(r1,l2)!=-1&&cmp(r2,l1)!=-1;
}
// 线段与线段相交判断(非严格相交)
int checkSS(point k1,point k2,point k3,point k4){
return intersect(k1.x,k2.x,k3.x,k4.x)&&intersect(k1.y,k2.y,k3.y,k4.y)&&
sgn(cross(k3-k1,k4-k1))*sgn(cross(k3-k2,k4-k2))<=0&&
sgn(cross(k1-k3,k2-k3))*sgn(cross(k1-k4,k2-k4))<=0;
}
// 点 q 到 直线 (k1, k2) 的距离
db disLP(point k1, point k2, point q) {
return fabs(cross(k1-q, k2-q)) / k1.dis(k2);
}
// 点 q 到 线段 (k1, k2) 的距离
db disSP(point k1,point k2,point q){
point k3=proj(k1,k2,q);
if (inmid(k1,k2,k3)) return q.dis(k3); else return min(q.dis(k1),q.dis(k2));
}
// 线段 (k1, k2) 到 线段 (k3, k4) 的距离
db disSS(point k1,point k2,point k3,point k4){
if (checkSS(k1,k2,k3,k4)) return 0;
else return min(min(disSP(k1,k2,k3),disSP(k1,k2,k4)),min(disSP(k3,k4,k1),disSP(k3,k4,k2)));
}
/* 直线与半平面交 */
// 直线 p[0] -> p[1]
struct line {
point p[2];
line() {}
line(point k1, point k2) {p[0]=k1; p[1]=k2;}
point& operator [] (int k) {return p[k];}
// k 严格位于直线左侧 / 半平面 p[0] -> p[1]
int include(point k){return sgn(cross(p[1]-p[0],k-p[0]))>0;}
// 方向向量
point dir() {return p[1]-p[0];}
// 向左平移 d, 默认为 eps
line push(db d = eps) {
point delta=(p[1]-p[0]).rotleft().unit()*d;
return {p[0]+delta,p[1]+delta};
}
};
// 直线与直线交点
point getLL(line k1,line k2){return getLL(k1[0],k1[1],k2[0],k2[1]);}
// 两直线平行
int parallel(line k1,line k2){return sgn(cross(k1.dir(),k2.dir()))==0;}
// 平行且同向
int sameDir(line k1,line k2){return parallel(k1,k2)&&sgn(dot(k1.dir(),k2.dir()))==1;}
// 同向则左侧优先,否则按极角排序,用于半平面交
int operator < (line k1,line k2){
if (sameDir(k1,k2)) return k2.include(k1[0]);
return cmpangle(k1.dir(),k2.dir());
}
// k3 (半平面) 包含 k1,k2 的交点, 用于半平面交
int checkpos(line k1,line k2,line k3) {return k3.include(getLL(k1,k2));}
// 求半平面交, 半平面是逆时针方向, 输出按照逆时针
vector<line> getHL(vector<line> L) {
sort(L.begin(),L.end()); deque<line> q;
for (int i = 0; i < (int)L.size(); i++) {
if (i&&sameDir(L[i],L[i-1])) continue;
while (q.size()>1&&!checkpos(q[q.size()-2],q[q.size()-1],L[i])) q.pop_back();
while (q.size()>1&&!checkpos(q[1],q[0],L[i])) q.pop_front();
q.push_back(L[i]);
}
while (q.size()>2&&!checkpos(q[q.size()-2],q[q.size()-1],q[0])) q.pop_back();
while (q.size()>2&&!checkpos(q[1],q[0],q[q.size()-1])) q.pop_front();
vector<line>ans; for (int i=0;i<q.size();i++) ans.push_back(q[i]);
return ans;
}
db closepoint(vector<point>&A,int l,int r){ // 最近点对 , 先要按照 x 坐标排序
if (r-l<=5){
db ans=1e20;
for (int i=l;i<=r;i++) for (int j=i+1;j<=r;j++) ans=min(ans,A[i].dis(A[j]));
return ans;
}
int mid=l+r>>1; db ans=min(closepoint(A,l,mid),closepoint(A,mid+1,r));
vector<point>B; for (int i=l;i<=r;i++) if (abs(A[i].x-A[mid].x)<=ans) B.push_back(A[i]);
sort(B.begin(),B.end(),[](point k1,point k2){return k1.y<k2.y;});
for (int i=0;i<B.size();i++) for (int j=i+1;j<B.size()&&B[j].y-B[i].y<ans;j++) ans=min(ans,B[i].dis(B[j]));
return ans;
}
/* 圆基础操作 */
// 圆 (o, r)
struct circle{
point o; db r;
void scan(){o.scan(); scanf("%lf",&r);}
int inside(point k){return cmp(r,o.dis(k));}
};
// 两圆位置关系(两圆公切线数量)
int checkposCC(circle k1,circle k2) {
if (cmp(k1.r,k2.r)==-1) swap(k1,k2);
db dis=k1.o.dis(k2.o); int w1=cmp(dis,k1.r+k2.r),w2=cmp(dis,k1.r-k2.r);
if (w1>0) return 4; else if (w1==0) return 3; else if (w2>0) return 2;
else if (w2==0) return 1; else return 0;
}
// 直线与圆交点,沿 k2->k3 方向给出, 相切给出两个
vector<point> getCL(circle k1,point k2,point k3){
point k=proj(k2,k3,k1.o); db d=k1.r*k1.r-(k-k1.o).abs2();
if (sgn(d)==-1) return {};
point del=(k3-k2).unit()*sqrt(max((db)0.0,d)); return {k-del,k+del};
}
// 两圆交点,沿圆 k1 逆时针给出, 相切给出两个
vector<point> getCC(circle k1,circle k2){
int pd=checkposCC(k1,k2); if (pd==0||pd==4) return {};
db a=(k2.o-k1.o).abs2(),cosA=(k1.r*k1.r+a-k2.r*k2.r)/(2*k1.r*sqrt(max(a,(db)0.0)));
db b=k1.r*cosA,c=sqrt(max((db)0.0,k1.r*k1.r-b*b));
point k=(k2.o-k1.o).unit(),m=k1.o+k*b,del=k.rotleft()*c;
return {m-del,m+del};
}
// 点到圆的切点,沿圆 k1 逆时针给出, 注意未判位置关系!!
vector<point> TangentCP(circle k1,point k2){
db a=(k2-k1.o).abs(), b=k1.r*k1.r/a, c=sqrt(max((db)0.0,k1.r*k1.r-b*b));
point k=(k2-k1.o).unit(), m=k1.o+k*b, del=k.rotleft()*c;
return {m-del, m+del};
}
// 外公切线
vector<line> TangentoutCC(circle k1,circle k2){
int pd=checkposCC(k1,k2); if (pd==0) return {};
if (pd==1){point k=getCC(k1,k2)[0]; return {(line){k,k}};}
if (cmp(k1.r,k2.r)==0){
point del=(k2.o-k1.o).unit().rotleft().getdel();
return {(line){k1.o-del*k1.r,k2.o-del*k2.r},(line){k1.o+del*k1.r,k2.o+del*k2.r}};
} else {
point p=(k2.o*k1.r-k1.o*k2.r)/(k1.r-k2.r);
vector<point>A=TangentCP(k1,p),B=TangentCP(k2,p);
vector<line>ans; for (int i=0;i<A.size();i++) ans.push_back((line){A[i],B[i]});
return ans;
}
}
// 内公切线
vector<line> TangentinCC(circle k1,circle k2){
int pd=checkposCC(k1,k2); if (pd<=2) return {};
if (pd==3){point k=getCC(k1,k2)[0]; return {(line){k,k}};}
point p=(k2.o*k1.r+k1.o*k2.r)/(k1.r+k2.r);
vector<point>A=TangentCP(k1,p),B=TangentCP(k2,p);
vector<line>ans; for (int i=0;i<A.size();i++) ans.push_back((line){A[i],B[i]});
return ans;
}
// 所有公切线
vector<line> TangentCC(circle k1,circle k2){
int flag=0; if (k1.r<k2.r) swap(k1,k2),flag=1;
vector<line>A=TangentoutCC(k1,k2),B=TangentinCC(k1,k2);
for (line k:B) A.push_back(k);
if (flag) for (line &k:A) swap(k[0],k[1]);
return A;
}
// 圆 k1 与三角形 k2 k3 k1.o 的有向面积交
db getarea(circle k1,point k2,point k3){
point k=k1.o; k1.o=k1.o-k; k2=k2-k; k3=k3-k;
int pd1=k1.inside(k2),pd2=k1.inside(k3);
vector<point>A=getCL(k1,k2,k3);
if (pd1>=0){
if (pd2>=0) return cross(k2,k3)/2;
return k1.r*k1.r*rad(A[1],k3)/2+cross(k2,A[1])/2;
} else if (pd2>=0){
return k1.r*k1.r*rad(k2,A[0])/2+cross(A[0],k3)/2;
}else {
int pd=cmp(k1.r,disSP(k2,k3,k1.o));
if (pd<=0) return k1.r*k1.r*rad(k2,k3)/2;
return cross(A[0],A[1])/2+k1.r*k1.r*(rad(k2,A[0])+rad(A[1],k3))/2;
}
}
// 多边形与圆面积交
db getarea(vector<point> A, circle c) {
int n = A.size();
if(n <= 2) return 0.0;
A.push_back(A[0]);
db res = 0.0;
for(int i = 0; i < n; i++) {
point k1 = A[i], k2 = A[i+1];
res += getarea(c, k1, k2);
}
return fabs(res);
}
// 三角形外接圆
circle getcircle(point k1,point k2,point k3){
db a1=k2.x-k1.x,b1=k2.y-k1.y,c1=(a1*a1+b1*b1)/2;
db a2=k3.x-k1.x,b2=k3.y-k1.y,c2=(a2*a2+b2*b2)/2;
db d=a1*b2-a2*b1;
point o=(point){k1.x+(c1*b2-c2*b1)/d,k1.y+(a1*c2-a2*c1)/d};
return (circle){o,k1.dis(o)};
}
// 最小圆覆盖
circle getScircle(vector<point> A){
shuffle(A.begin(), A.end(), eng);
circle ans=(circle){A[0],0};
for (int i=1;i<A.size();i++)
if (ans.inside(A[i])==-1){
ans=(circle){A[i],0};
for (int j=0;j<i;j++)
if (ans.inside(A[j])==-1){
ans.o=(A[i]+A[j])/2; ans.r=ans.o.dis(A[i]);
for (int k=0;k<j;k++)
if (ans.inside(A[k])==-1)
ans=getcircle(A[i],A[j],A[k]);
}
}
return ans;
}
/* 多边形 */
// 多边形有向面积
db area(vector<point> A){
db ans=0;
for (int i=0;i<A.size();i++) ans+=cross(A[i],A[(i+1)%A.size()]);
return ans/2;
}
// 判断是否为逆时针凸包
int checkconvex(vector<point>A) {
int n=A.size(); A.push_back(A[0]); A.push_back(A[1]);
for (int i=0;i<n;i++) if (sgn(cross(A[i+1]-A[i],A[i+2]-A[i]))==-1) return 0;
return 1;
}
// 点与简单多边形位置关系:2 内部 1 边界 0 外部
int contain(vector<point>A,point q) {
int pd=0; A.push_back(A[0]);
for (int i=1;i<A.size();i++){
point u=A[i-1],v=A[i];
if (onS(u,v,q)) return 1; if (cmp(u.y,v.y)>0) swap(u,v);
if (cmp(u.y,q.y)>=0||cmp(v.y,q.y)<0) continue;
if (sgn(cross(u-v,q-v))<0) pd^=1;
}
return pd<<1;
}
// flag=0 不严格 flag=1 严格
vector<point> ConvexHull(vector<point> A, int flag = 1) {
int n = A.size();
if(n == 1) return A;
if(n == 2) {
if(A[0] == A[1]) return {A[0]};
else return A;
}
vector<point> ans(n * 2);
sort(A.begin(), A.end()); int now = -1;
for(int i = 0; i < A.size(); i++) {
while (now > 0 && sgn(cross(ans[now]-ans[now-1], A[i]-ans[now-1])) < flag) now--;
ans[++now] = A[i];
} int pre = now;
for(int i = n - 2; i >= 0; i--) {
while (now > pre && sgn(cross(ans[now]-ans[now-1], A[i]-ans[now-1])) < flag) now--;
ans[++now] = A[i];
}
ans.resize(now);
return ans;
}
// 凸包直径
db convexDiameter(vector<point>A){
int now=0,n=A.size(); db ans=0;
for (int i=0;i<A.size();i++){
now=max(now,i);
while (1){
db k1=A[i].dis(A[now%n]),k2=A[i].dis(A[(now+1)%n]);
ans=max(ans,max(k1,k2)); if (k2>k1) now++; else break;
}
}
return ans;
}
// 直线切凸包,保留 k1,k2,p 逆时针的所有点
vector<point> convexcut(vector<point>A,point k1,point k2){
int n=A.size(); A.push_back(A[0]); vector<point>ans;
for (int i=0;i<n;i++){
int w1=clockwise(k1,k2,A[i]),w2=clockwise(k1,k2,A[i+1]);
if (w1>=0) ans.push_back(A[i]);
if (w1*w2<0) ans.push_back(getLL(k1,k2,A[i],A[i+1]));
}
return ans;
}
// 多边形 A 和 直线 (线段) k1->k2 严格相交, 注释部分为线段
int checkPoS(vector<point>A,point k1,point k2) {
struct ins{
point m,u,v;
int operator < (const ins& k) const {return m<k.m;}
}; vector<ins>B;
//if (contain(A,k1)==2||contain(A,k2)==2) return 1;
vector<point>poly=A; A.push_back(A[0]);
for (int i=1;i<A.size();i++) if (checkLL(A[i-1],A[i],k1,k2)){
point m=getLL(A[i-1],A[i],k1,k2);
if (inmid(A[i-1],A[i],m)/*&&inmid(k1,k2,m)*/) B.push_back((ins){m,A[i-1],A[i]});
}
if (B.size()==0) return 0; sort(B.begin(),B.end());
int now=1; while (now<B.size()&&B[now].m==B[0].m) now++;
if (now==B.size()) return 0;
int flag=contain(poly,(B[0].m+B[now].m)/2);
if (flag==2) return 1;
point d=B[now].m-B[0].m;
for (int i=now;i<B.size();i++){
if (!(B[i].m==B[i-1].m)&&flag==2) return 1;
int tag=sgn(cross(B[i].v-B[i].u,B[i].m+d-B[i].u));
if (B[i].m==B[i].u||B[i].m==B[i].v) flag+=tag; else flag+=tag*2;
}
//return 0;
return flag==2;
}
int checkinp(point r,point l,point m){
if (cmpangle(l,r)){return cmpangle(l,m)&&cmpangle(m,r);}
return cmpangle(l,m)||cmpangle(m,r);
}
// 快速检查线段是否和多边形严格相交
int checkPosFast(vector<point>A,point k1,point k2){
if (contain(A,k1)==2||contain(A,k2)==2) return 1; if (k1==k2) return 0;
A.push_back(A[0]); A.push_back(A[1]);
for (int i=1;i+1<A.size();i++)
if (checkLL(A[i-1],A[i],k1,k2)){
point now=getLL(A[i-1],A[i],k1,k2);
if (inmid(A[i-1],A[i],now)==0||inmid(k1,k2,now)==0) continue;
if (now==A[i]){
if (A[i]==k2) continue;
point pre=A[i-1],ne=A[i+1];
if (checkinp(pre-now,ne-now,k2-now)) return 1;
} else if (now==k1){
if (k1==A[i-1]||k1==A[i]) continue;
if (checkinp(A[i-1]-k1,A[i]-k1,k2-k1)) return 1;
} else if (now==k2||now==A[i-1]) continue;
else return 1;
}
return 0;
}
/* 普通凸包中的二分 */
// 求经过点 x 切凸包 A 的两个切点,返回下标。方向:A 上 [fi, se] 为点 x 能看到的区域。
// 需要保证 x 严格在凸包 A 外侧,A 的点数 >= 3
// 需要保证 A 是严格凸包,即无三点共线
pair<int, int> getTangentCoP(const vector<point>& A, point x) {
int sz = A.size(); assert(sz >= 3);
int res[2];
int flag = 1;
if(clockwise(A[sz - 1], A[0], x) == -1) flag = -1;
int l = 0, r = sz - 1, ans = 0;
while(l < r) {
int mid = ((l + r) >> 1);
if(clockwise(A[mid], A[mid + 1], x) == flag && clockwise(A[0], A[mid + 1], x) == flag)
ans = mid + 1, l = mid + 1;
else r = mid;
} res[0] = ans;
l = ans, r = sz - 1, ans = sz - 1;
while(l < r) {
int mid = ((l + r) >> 1);
if(clockwise(A[mid], A[mid + 1], x) == flag)
ans = mid, r = mid;
else l = mid + 1;
} res[1] = ans;
if(flag == -1) swap(res[0], res[1]);
return {res[0], res[1]};
}
// 判断点是否在凸多边形 A 内部,flag = 1 严格,0 不严格
bool containCoP(const vector<point>& A, point x, int flag = 1) {
int sz = A.size(); assert(sz >= 3);
if(!flag && (onS(A[0], A[1], x) || onS(A[sz-1], A[0], x))) return 1;
if(!(clockwise(A[0],A[1],x)==1 && clockwise(A[sz-1],A[0],x)==1)) return 0;
int l = 1, r = sz - 1, ans = 1;
while(l < r) {
int mid = l + r >> 1;
if(clockwise(A[0], A[mid], x) == 1) ans = mid, l = mid + 1;
else r = mid;
}
return clockwise(A[ans], A[ans + 1], x) >= flag;
}
/* 上下凸包中的二分 */
// 拆分凸包成上下凸壳 凸包尽量都随机旋转一个角度来避免出现相同横坐标
// 尽量特判只有一个点的情况 凸包逆时针
void getUDP(vector<point>A,vector<point>&U,vector<point>&D){
db l=1e100,r=-1e100;
for (int i=0;i<A.size();i++) l=min(l,A[i].x),r=max(r,A[i].x);
int wherel,wherer;
for (int i=0;i<A.size();i++) if (cmp(A[i].x,l)==0) wherel=i;
for (int i=A.size();i;i--) if (cmp(A[i-1].x,r)==0) wherer=i-1;
U.clear(); D.clear(); int now=wherel;
while (1){D.push_back(A[now]); if (now==wherer) break; now++; if (now>=A.size()) now=0;}
now=wherel;
while (1){U.push_back(A[now]); if (now==wherer) break; now--; if (now<0) now=A.size()-1;}
}
// 需要保证凸包点数大于等于 3, 2 内部 ,1 边界 ,0 外部
int containCoP(const vector<point>&U,const vector<point>&D,point k){
db lx=U[0].x,rx=U[U.size()-1].x;
if (k==U[0]||k==U[U.size()-1]) return 1;
if (cmp(k.x,lx)==-1||cmp(k.x,rx)==1) return 0;
int where1=lower_bound(U.begin(),U.end(),(point){k.x,-1e100})-U.begin();
int where2=lower_bound(D.begin(),D.end(),(point){k.x,-1e100})-D.begin();
int w1=clockwise(U[where1-1],U[where1],k),w2=clockwise(D[where2-1],D[where2],k);
if (w1==1||w2==-1) return 0; else if (w1==0||w2==0) return 1; return 2;
}
// d 是方向 , 输出上方切点和下方切点
pair<point,point> getTangentCow(const vector<point> &U,const vector<point> &D,point d){
if (sgn(d.x)<0||(sgn(d.x)==0&&sgn(d.y)<0)) d=d*(-1);
point whereU,whereD;
if (sgn(d.x)==0) return {U[0],U[U.size()-1]};
int l=0,r=U.size()-1,ans=0;
while (l<r){int mid=l+r>>1; if (sgn(cross(U[mid+1]-U[mid],d))<=0) l=mid+1,ans=mid+1; else r=mid;}
whereU=U[ans]; l=0,r=D.size()-1,ans=0;
while (l<r){int mid=l+r>>1; if (sgn(cross(D[mid+1]-D[mid],d))>=0) l=mid+1,ans=mid+1; else r=mid;}
whereD=D[ans]; return {whereU,whereD};
}
// 先检查 contain, 逆时针给出
pair<point,point> getTangentCoP(const vector<point>&U,const vector<point>&D,point k){
db lx=U[0].x,rx=U[U.size()-1].x;
if (k.x<lx){
int l=0,r=U.size()-1,ans=U.size()-1;
while (l<r){int mid=l+r>>1; if (clockwise(k,U[mid],U[mid+1])==1) l=mid+1; else ans=mid,r=mid;}
point w1=U[ans]; l=0,r=D.size()-1,ans=D.size()-1;
while (l<r){int mid=l+r>>1; if (clockwise(k,D[mid],D[mid+1])==-1) l=mid+1; else ans=mid,r=mid;}
point w2=D[ans]; return {w1,w2};
} else if (k.x>rx){
int l=1,r=U.size(),ans=0;
while (l<r){int mid=l+r>>1; if (clockwise(k,U[mid],U[mid-1])==-1) r=mid; else ans=mid,l=mid+1;}
point w1=U[ans]; l=1,r=D.size(),ans=0;
while (l<r){int mid=l+r>>1; if (clockwise(k,D[mid],D[mid-1])==1) r=mid; else ans=mid,l=mid+1;}
point w2=D[ans]; return {w2,w1};
} else {
int where1=lower_bound(U.begin(),U.end(),(point){k.x,-1e100})-U.begin();
int where2=lower_bound(D.begin(),D.end(),(point){k.x,-1e100})-D.begin();
if ((k.x==lx&&k.y>U[0].y)||(where1&&clockwise(U[where1-1],U[where1],k)==1)){
int l=1,r=where1+1,ans=0;
while (l<r){int mid=l+r>>1; if (clockwise(k,U[mid],U[mid-1])==1) ans=mid,l=mid+1; else r=mid;}
point w1=U[ans]; l=where1,r=U.size()-1,ans=U.size()-1;
while (l<r){int mid=l+r>>1; if (clockwise(k,U[mid],U[mid+1])==1) l=mid+1; else ans=mid,r=mid;}
point w2=U[ans]; return {w2,w1};
} else {
int l=1,r=where2+1,ans=0;
while (l<r){int mid=l+r>>1; if (clockwise(k,D[mid],D[mid-1])==-1) ans=mid,l=mid+1; else r=mid;}
point w1=D[ans]; l=where2,r=D.size()-1,ans=D.size()-1;
while (l<r){int mid=l+r>>1; if (clockwise(k,D[mid],D[mid+1])==-1) l=mid+1; else ans=mid,r=mid;}
point w2=D[ans]; return {w1,w2};
}
}
}
// 三维计算几何
struct P3{
db x,y,z;
P3 operator + (P3 k1){return (P3){x+k1.x,y+k1.y,z+k1.z};}
P3 operator - (P3 k1){return (P3){x-k1.x,y-k1.y,z-k1.z};}
P3 operator * (db k1){return (P3){x*k1,y*k1,z*k1};}
P3 operator / (db k1){return (P3){x/k1,y/k1,z/k1};}
db abs2(){return x*x+y*y+z*z;}
db abs(){return sqrt(x*x+y*y+z*z);}
P3 unit(){return (*this)/abs();}
int operator < (const P3 k1) const{
if (cmp(x,k1.x)!=0) return x<k1.x;
if (cmp(y,k1.y)!=0) return y<k1.y;
return cmp(z,k1.z)==-1;
}
int operator == (const P3 k1){
return cmp(x,k1.x)==0&&cmp(y,k1.y)==0&&cmp(z,k1.z)==0;
}
void scan(){
double k1,k2,k3; scanf("%lf%lf%lf",&k1,&k2,&k3);
x=k1; y=k2; z=k3;
}
};
P3 cross(P3 k1,P3 k2){return (P3){k1.y*k2.z-k1.z*k2.y,k1.z*k2.x-k1.x*k2.z,k1.x*k2.y-k1.y*k2.x};}
db dot(P3 k1,P3 k2){return k1.x*k2.x+k1.y*k2.y+k1.z*k2.z;}
//p=(3,4,5),l=(13,19,21),theta=85 ans=(2.83,4.62,1.77)
P3 turn3D(db k1,P3 l,P3 p){
l=l.unit(); P3 ans; db c=cos(k1),s=sin(k1);
ans.x=p.x*(l.x*l.x*(1-c)+c)+p.y*(l.x*l.y*(1-c)-l.z*s)+p.z*(l.x*l.z*(1-c)+l.y*s);
ans.y=p.x*(l.x*l.y*(1-c)+l.z*s)+p.y*(l.y*l.y*(1-c)+c)+p.z*(l.y*l.z*(1-c)-l.x*s);
ans.z=p.x*(l.x*l.z*(1-c)-l.y*s)+p.y*(l.y*l.z*(1-c)+l.x*s)+p.z*(l.x*l.x*(1-c)+c);
return ans;
}
typedef vector<P3> VP;
typedef vector<VP> VVP;
db Acos(db x){return acos(max(-(db)1,min(x,(db)1)));}
// 球面距离 , 圆心原点 , 半径 1
db Odist(P3 a,P3 b){db r=Acos(dot(a,b)); return r;}
db r; P3 rnd;
vector<db> solve(db a,db b,db c){
db r=sqrt(a*a+b*b),th=atan2(b,a);
if (cmp(c,-r)==-1) return {0};
else if (cmp(r,c)<=0) return {1};
else {
db tr=pi-Acos(c/r); return {th+pi-tr,th+pi+tr};
}
}
vector<db> jiao(P3 a,P3 b){
// dot(rd+x*cos(t)+y*sin(t),b) >= cos(r)
if (cmp(Odist(a,b),2*r)>0) return {0};
P3 rd=a*cos(r),z=a.unit(),y=cross(z,rnd).unit(),x=cross(y,z).unit();
vector<db> ret = solve(-(dot(x,b)*sin(r)),-(dot(y,b)*sin(r)),-(cos(r)-dot(rd,b)));
return ret;
}
db norm(db x,db l=0,db r=2*pi){ // change x into [l,r)
while (cmp(x,l)==-1) x+=(r-l); while (cmp(x,r)>=0) x-=(r-l);
return x;
}
db disLP(P3 k1,P3 k2,P3 q){
return (cross(k2-k1,q-k1)).abs()/(k2-k1).abs();
}
db disLL(P3 k1,P3 k2,P3 k3,P3 k4){
P3 dir=cross(k2-k1,k4-k3); if (sgn(dir.abs())==0) return disLP(k1,k2,k3);
return fabs(dot(dir.unit(),k1-k2));
}
VP getFL(P3 p,P3 dir,P3 k1,P3 k2){
db a=dot(k2-p,dir),b=dot(k1-p,dir),d=a-b;
if (sgn(fabs(d))==0) return {};
return {(k1*a-k2*b)/d};
}
VP getFF(P3 p1,P3 dir1,P3 p2,P3 dir2){// 返回一条线
P3 e=cross(dir1,dir2),v=cross(dir1,e);
db d=dot(dir2,v); if (sgn(abs(d))==0) return {};
P3 q=p1+v*dot(dir2,p2-p1)/d; return {q,q+e};
}
// 3D Covex Hull Template
db getV(P3 k1,P3 k2,P3 k3,P3 k4){ // get the Volume
return dot(cross(k2-k1,k3-k1),k4-k1);
}
db rand_db(){return 1.0*rand()/RAND_MAX;}
VP convexHull2D(VP A,P3 dir){
P3 x={(db)rand(),(db)rand(),(db)rand()}; x=x.unit();
x=cross(x,dir).unit(); P3 y=cross(x,dir).unit();
P3 vec=dir.unit()*dot(A[0],dir);
vector<point>B;
for (int i=0;i<A.size();i++) B.push_back((point){dot(A[i],x),dot(A[i],y)});
B=ConvexHull(B); A.clear();
for (int i=0;i<B.size();i++) A.push_back(x*B[i].x+y*B[i].y+vec);
return A;
}
namespace CH3{
VVP ret; set<pair<int,int> >e;
int n; VP p,q;
void wrap(int a,int b){
if (e.find({a,b})==e.end()){
int c=-1;
for (int i=0;i<n;i++) if (i!=a&&i!=b){
if (c==-1||sgn(getV(q[c],q[a],q[b],q[i]))>0) c=i;
}
if (c!=-1){
ret.push_back({p[a],p[b],p[c]});
e.insert({a,b}); e.insert({b,c}); e.insert({c,a});
wrap(c,b); wrap(a,c);
}
}
}
VVP ConvexHull3D(VP _p){
p=q=_p; n=p.size();
ret.clear(); e.clear();
for (auto &i:q) i=i+(P3){rand_db()*1e-4,rand_db()*1e-4,rand_db()*1e-4};
for (int i=1;i<n;i++) if (q[i].x<q[0].x) swap(p[0],p[i]),swap(q[0],q[i]);
for (int i=2;i<n;i++) if ((q[i].x-q[0].x)*(q[1].y-q[0].y)>(q[i].y-q[0].y)*(q[1].x-q[0].x)) swap(q[1],q[i]),swap(p[1],p[i]);
wrap(0,1);
return ret;
}
}
VVP reduceCH(VVP A){
VVP ret; map<P3,VP> M;
for (VP nowF:A){
P3 dir=cross(nowF[1]-nowF[0],nowF[2]-nowF[0]).unit();
for (P3 k1:nowF) M[dir].push_back(k1);
}
for (pair<P3,VP> nowF:M) ret.push_back(convexHull2D(nowF.second,nowF.first));
return ret;
}
// 把一个面变成 ( 点 , 法向量 ) 的形式
pair<P3,P3> getF(VP F){
return {F[0],cross(F[1]-F[0],F[2]-F[0]).unit()};
}
// 3D Cut 保留 dot(dir,x-p)>=0 的部分
VVP ConvexCut3D(VVP A,P3 p,P3 dir){
VVP ret; VP sec;
for (VP nowF: A){
int n=nowF.size(); VP ans; int dif=0;
for (int i=0;i<n;i++){
int d1=sgn(dot(dir,nowF[i]-p));
int d2=sgn(dot(dir,nowF[(i+1)%n]-p));
if (d1>=0) ans.push_back(nowF[i]);
if (d1*d2<0){
P3 q=getFL(p,dir,nowF[i],nowF[(i+1)%n])[0];
ans.push_back(q); sec.push_back(q);
}
if (d1==0) sec.push_back(nowF[i]); else dif=1;
dif|=(sgn(dot(dir,cross(nowF[(i+1)%n]-nowF[i],nowF[(i+1)%n]-nowF[i])))==-1);
}
if (ans.size()>0&&dif) ret.push_back(ans);
}
if (sec.size()>0) ret.push_back(convexHull2D(sec,dir));
return ret;
}
db vol(VVP A){
if (A.size()==0) return 0; P3 p=A[0][0]; db ans=0;
for (VP nowF:A)
for (int i=2;i<nowF.size();i++)
ans+=abs(getV(p,nowF[0],nowF[i-1],nowF[i]));
return ans/6;
}
VVP init(db INF) {
VVP pss(6,VP(4));
pss[0][0] = pss[1][0] = pss[2][0] = {-INF, -INF, -INF};
pss[0][3] = pss[1][1] = pss[5][2] = {-INF, -INF, INF};
pss[0][1] = pss[2][3] = pss[4][2] = {-INF, INF, -INF};
pss[0][2] = pss[5][3] = pss[4][1] = {-INF, INF, INF};
pss[1][3] = pss[2][1] = pss[3][2] = {INF, -INF, -INF};
pss[1][2] = pss[5][1] = pss[3][3] = {INF, -INF, INF};
pss[2][2] = pss[4][3] = pss[3][1] = {INF, INF, -INF};
pss[5][0] = pss[4][0] = pss[3][0] = {INF, INF, INF};
return pss;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<point> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i].x >> a[i].y;
}
vector<db> dp(n + 1);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
dp[i] = max(dp[i], dp[j - 1] + (a[j] - a[i]).abs());
}
}
cout << fixed << setprecision(10);
cout << dp[n] << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4000kb
input:
7 1 0 0 1 0 0 1 1 1 2 3 2 3 3
output:
5.6568542495
result:
ok found '5.6568542', expected '5.6568542', error '0.0000000'
Test #2:
score: 0
Accepted
time: 21ms
memory: 4036kb
input:
4741 583042625 -288151442 901234470 -999760464 -974135773 -819820344 562644007 892707743 -120734580 -288167839 -14369253 88358276 -150949453 -39424771 -947214734 -826830020 578141361 443534304 -783950948 394211236 861595911 -751206580 570425640 624990919 484450011 -470115909 -417437663 22205205 -278...
output:
2798587991989.8886718750
result:
ok found '2798587991989.8886719', expected '2798587991989.8847656', error '0.0000000'
Test #3:
score: 0
Accepted
time: 10ms
memory: 3996kb
input:
3213 522199909 514991717 -232609361 652684240 279847038 136749526 -736646400 628493330 -94229099 39044538 -309386930 -566589012 -743178071 977659303 331655367 709620221 819648050 -137222273 -483906372 -718154516 289043195 250752012 -411924666 177871816 398984540 805195900 703931330 342254199 -856530...
output:
1901931022047.7792968750
result:
ok found '1901931022047.7792969', expected '1901931022047.7783203', error '0.0000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 4020kb
input:
968 -385563683 -522813287 209254780 602611305 -135909694 -189263722 -560221149 430227148 418701856 300906413 142373383 -917649276 -660279103 -422510383 250385700 -352334214 -985948308 243315304 799743397 -952922578 812232051 936938663 -90803222 792720350 -471673653 862670783 7848186 -382327569 92478...
output:
578491625641.7517089844
result:
ok found '578491625641.7517090', expected '578491625641.7514648', error '0.0000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
953 -478762162 556782215 -449686486 216328565 -44170762 669873691 842648553 921608634 881686869 -879142568 -310705987 -181489994 830441179 -110797482 975426657 191561809 82154355 -747749350 119879969 -758174233 205946922 -841205703 891282338 -293121292 -291513482 -926248534 -259415843 314744581 3087...
output:
548515721178.3259277344
result:
ok found '548515721178.3259277', expected '548515721178.3260498', error '0.0000000'
Test #6:
score: 0
Accepted
time: 14ms
memory: 4080kb
input:
3759 676737194 -980777589 217638142 6869120 -125418314 123963171 -204688896 541552947 561865563 -55462182 -80455900 430710337 340645278 -696579669 -661503371 -541055133 657844506 925334877 -489646017 70483090 -318494961 -564680191 -435702114 715003944 -923874337 999952827 58509157 -824102071 9650985...
output:
2206491871737.3510742188
result:
ok found '2206491871737.3510742', expected '2206491871737.3500977', error '0.0000000'
Test #7:
score: 0
Accepted
time: 4ms
memory: 4044kb
input:
1756 -794562341 189757398 613043582 723208622 -995430439 -983183746 -535180678 -268843337 683710261 474028965 -174478855 -923623466 452080293 -168429630 -313866124 -797744543 -708963290 -458862788 -848064376 -580578604 -698772531 -480867166 -740904810 993663858 -257651595 -845175149 -899827563 -9812...
output:
1036498275809.2386474609
result:
ok found '1036498275809.2386475', expected '1036498275809.2416992', error '0.0000000'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3952kb
input:
787 -7090150 526856296 983585064 864606987 791966318 -932273401 790414531 -962590263 -298101553 -750297443 -864851403 961707825 -645715752 242258574 -483808865 31609614 63153566 875139392 718544175 497170780 300611334 -673086931 295953448 -659892820 -332147467 -908330117 604437152 -278539108 -177244...
output:
462688629311.4662475586
result:
ok found '462688629311.4662476', expected '462688629311.4662476', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 4076kb
input:
76 511351388 148937608 -765051015 -436970176 723116524 762293974 290499914 -661458121 -191417042 623970973 960822261 485952766 447507820 400688682 982713215 -633842708 -563958099 -645550204 712420915 515241338 -472445700 615252228 -855194394 -847734315 676479200 -957203437 -929157866 -35201369 29763...
output:
47060424949.1604080200
result:
ok found '47060424949.1604080', expected '47060424949.1604080', error '0.0000000'
Test #10:
score: 0
Accepted
time: 7ms
memory: 3992kb
input:
2509 429840249 87593961 -781144839 -367765668 -319100136 175507520 463740161 532062477 428212053 -868971808 61501828 -545909867 -519549565 -244091284 486389381 656285616 776861744 -111829692 -320014746 -596760388 -211217331 -796722466 -291157077 -954656509 -498870218 875167125 -956272747 745584318 -...
output:
1488779644671.2143554688
result:
ok found '1488779644671.2143555', expected '1488779644671.2136230', error '0.0000000'
Test #11:
score: 0
Accepted
time: 21ms
memory: 4036kb
input:
4731 828324934 -115821941 675339843 -390622205 374490228 -604641993 85274428 -930782926 716769527 77537703 -574045032 741753635 112560584 -500472256 -157434361 641494473 -223609765 528249214 -321457473 -430476260 -2160243 867435391 669146114 -913381923 92191218 895944136 237650254 -912799227 -540384...
output:
2771456417007.1083984375
result:
ok found '2771456417007.1083984', expected '2771456417007.1044922', error '0.0000000'
Test #12:
score: 0
Accepted
time: 8ms
memory: 4004kb
input:
2760 931337814 119511454 -683347917 427882185 -845680099 875219814 910511178 497271414 -833608505 482037885 229853403 577013667 -967753092 772130182 -905618087 -641860421 -198207627 653599444 111134339 979416572 48472787 -645149240 326126778 85163773 -975853866 -895943279 862569427 478859966 7644324...
output:
1641981837161.2351074219
result:
ok found '1641981837161.2351074', expected '1641981837161.2368164', error '0.0000000'
Test #13:
score: 0
Accepted
time: 15ms
memory: 4016kb
input:
4003 983856092 962653762 -169717046 290127957 214476265 604057342 -116309577 -929446895 759766456 -655349372 -595770198 -900469809 -994470686 -679537359 -993120731 -838206636 617489925 728379838 -898230109 -131869360 855913649 333137607 -539802443 630567246 -675704464 -730433814 54881080 178614628 9...
output:
2391581010099.9155273438
result:
ok found '2391581010099.9155273', expected '2391581010099.9208984', error '0.0000000'
Test #14:
score: 0
Accepted
time: 23ms
memory: 4052kb
input:
4920 458810846 768039107 -973153299 -975967643 620026181 105318199 -884989267 -935367768 -794733144 -816152705 852418155 -54565141 536602110 578446188 526335127 12333718 818975064 -742380096 -362961964 -480086991 718783650 -718763047 -123356688 -474099282 767340203 512795977 208913084 -64359025 -551...
output:
2909986192315.9829101562
result:
ok found '2909986192315.9829102', expected '2909986192315.9892578', error '0.0000000'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3980kb
input:
1046 -483174906 743758038 270841702 -357341440 301435128 -626986752 -250629309 -896040099 -519419913 576584022 745499607 -360035440 779733802 442199952 -189533140 122145670 -312698604 484253998 128579649 -136096115 -137667474 349635592 631315914 -626501353 -23143982 -877863376 724371001 328904162 -4...
output:
625073963650.6860351562
result:
ok found '625073963650.6860352', expected '625073963650.6859131', error '0.0000000'
Test #16:
score: 0
Accepted
time: 3ms
memory: 4120kb
input:
1673 -58998695 -877506047 -550919131 355648990 56181074 263557853 879381988 162999407 -852744941 -400470924 419415386 755724169 -217894954 -590650944 536947380 380279126 942725019 -478245969 -295346374 735788196 81372161 33933949 -762951402 -640855171 378338763 440745243 -212678146 -652416425 686472...
output:
999411208969.8660888672
result:
ok found '999411208969.8660889', expected '999411208969.8656006', error '0.0000000'
Test #17:
score: 0
Accepted
time: 19ms
memory: 4140kb
input:
5000 34688642 -851839419 395784949 -667081997 -155389155 -624068418 -758711821 119194510 -812775173 -992436155 -592596572 851861070 -179673992 974613003 520596304 -485749861 -265233646 -115838823 -222234500 -573799007 -887109945 608830643 -906910755 483106217 384264657 -597593284 476657007 940783 -9...
output:
2958177763313.7758789062
result:
ok found '2958177763313.7758789', expected '2958177763313.7758789', error '0.0000000'
Test #18:
score: 0
Accepted
time: 23ms
memory: 4056kb
input:
5000 -492673762 -496405053 764822338 111401587 774345046 -588077735 -972693439 959995351 -573156496 -729349041 645305810 326664422 -561855978 -477016787 461011057 697257071 377733217 -416669921 -204150537 784674141 -642123788 695471214 801626277 -968584097 68483816 -329331824 982358552 945230774 818...
output:
2981535748184.3906250000
result:
ok found '2981535748184.3906250', expected '2981535748184.3950195', error '0.0000000'
Test #19:
score: 0
Accepted
time: 23ms
memory: 4132kb
input:
5000 390029247 153996608 -918017777 838007668 -244043252 -257119758 813324945 390730779 -38570526 -761229221 -116791808 634492154 760994742 19475923 991360398 -119735998 -632455126 -665623518 -481033868 -394909798 140919454 -974798424 510163308 -715241704 -542264319 -61070363 -511939904 -353569028 -...
output:
2961773410701.6196289062
result:
ok found '2961773410701.6196289', expected '2961773410701.6206055', error '0.0000000'
Test #20:
score: 0
Accepted
time: 23ms
memory: 4200kb
input:
5000 -432300451 509430974 -600857890 -140418957 442601156 -464218867 61286241 -768468380 201048150 -203174812 826143280 404262799 673780049 567846134 983652653 525213848 600446325 -671487323 -462949905 963563350 628995403 -888157854 218700340 -166932017 898865049 207191097 288728935 590720963 -50838...
output:
2959320564556.7397460938
result:
ok found '2959320564556.7397461', expected '2959320564556.7426758', error '0.0000000'
Test #21:
score: 0
Accepted
time: 23ms
memory: 4116kb
input:
5000 450402558 -840167367 -231820501 586187125 -627664644 -428228185 142271917 367299755 735634121 59912302 64045662 469000739 291598063 -935661158 -780965301 -291779221 -409742018 -920440920 965199471 -216020590 -587961356 -801517283 465294457 -156679415 583084208 423575055 794430480 -759956341 -19...
output:
2944171196056.3139648438
result:
ok found '2944171196056.3139648', expected '2944171196056.3115234', error '0.0000000'
Test #22:
score: 0
Accepted
time: 24ms
memory: 4120kb
input:
5000 -76959846 -779700294 380306679 -340361999 58979764 -392237502 -314799493 -201964817 -729779910 28032122 -454962165 -56195909 -142461426 -387290947 -493705752 891227711 823159433 778727982 983283434 899362766 -48007905 -471786920 173831488 391630272 -322631221 691836515 -699867976 236211152 -130...
output:
2940327848374.5527343750
result:
ok found '2940327848374.5527344', expected '2940327848374.5571289', error '0.0000000'
Test #23:
score: 0
Accepted
time: 23ms
memory: 4136kb
input:
5000 805743163 -181176136 454376774 681211377 988713965 -599336611 -823748404 638836024 -490161233 586086531 782940218 251631822 -524643413 -133888029 -553290999 74234642 -533873706 529774386 -998632604 -332098675 735035338 -385146349 -412598775 350005371 -638412062 960097976 -194166431 -819498858 -...
output:
2966669430514.9433593750
result:
ok found '2966669430514.9433594', expected '2966669430514.9365234', error '0.0000000'
Test #24:
score: 0
Accepted
time: 23ms
memory: 4120kb
input:
5000 -311553829 469225525 -933496047 -592182543 -29674334 -268378634 -985852520 -225395842 44424737 849173645 20842600 21402468 -906825400 657571974 -266031450 -742758427 455937953 228943287 724484066 783284681 -776888715 -593473073 -460971951 603347764 -954192903 -528550773 68445323 -170176161 2475...
output:
2988672312355.4711914062
result:
ok found '2988672312355.4711914', expected '2988672312355.4750977', error '0.0000000'
Test #25:
score: 0
Accepted
time: 21ms
memory: 4116kb
input:
5000 866116474 824659891 -564458658 429390833 656970075 -232387951 505198569 910372293 579010708 817293465 963777688 86140408 416025321 616007597 -325616697 440248505 -311160598 -20010310 742568030 -101331964 -236935264 -506832502 -752434920 -848342550 435058963 -850223901 574146868 825991332 314947...
output:
2970856061325.5483398438
result:
ok found '2970856061325.5483398', expected '2970856061325.5502930', error '0.0000000'
Test #26:
score: 0
Accepted
time: 17ms
memory: 4104kb
input:
5000 -196228170 -181402541 328251238 624722764 682518931 783857631 969228879 547715844 -149364638 823684584 833196798 -913952210 -554264004 62726516 426420047 664711179 986117749 -418659204 -692340474 725195722 206423874 963934566 -850621504 688322091 -92095128 -259681786 220754482 52318280 -1634237...
output:
2958713299148.4448242188
result:
ok found '2958713299148.4448242', expected '2958713299148.4531250', error '0.0000000'
Test #27:
score: 0
Accepted
time: 0ms
memory: 4000kb
input:
1 127346 9458760
output:
0.0000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #28:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
2 438580 2370872 28759 -23894729
output:
26268798.0148167796
result:
ok found '26268798.0148168', expected '26268798.0148168', error '0.0000000'
Test #29:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
1 -1000000000 -1000000000
output:
0.0000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #30:
score: 0
Accepted
time: 0ms
memory: 4016kb
input:
2 1000000000 1000000000 -1000000000 1000000000
output:
2000000000.0000000000
result:
ok found '2000000000.0000000', expected '2000000000.0000000', error '0.0000000'
Test #31:
score: 0
Accepted
time: 0ms
memory: 4012kb
input:
3 0 0 1000000000 0 0 -1000000000
output:
1414213562.3730950356
result:
ok found '1414213562.3730950', expected '1414213562.3730950', error '0.0000000'
Test #32:
score: 0
Accepted
time: 0ms
memory: 4000kb
input:
4 1000000000 -1000000000 -1000000000 1000000000 0 0 1 -1
output:
2828427126.1604037285
result:
ok found '2828427126.1604037', expected '2828427126.1604037', error '0.0000000'
Test #33:
score: 0
Accepted
time: 0ms
memory: 4016kb
input:
5 -1000000000 -1000000000 1000000000 1000000000 -999999999 -1000000000 1000000000 999999999 -1000000000 -999999999
output:
5656854248.0781669617
result:
ok found '5656854248.0781670', expected '5656854248.0781670', error '0.0000000'
Test #34:
score: 0
Accepted
time: 0ms
memory: 4008kb
input:
10 273241060 -360748081 471537720 -647375704 -621925837 -22138471 904859645 820290727 -957530763 778258426 -370148620 -907251774 -188377660 -769041435 -987499732 546366365 -383619133 527915296 979817147 -791689541
output:
7313810466.4649772644
result:
ok found '7313810466.4649773', expected '7313810466.4649782', error '0.0000000'
Test #35:
score: 0
Accepted
time: 23ms
memory: 4200kb
input:
4999 1000000000 -1000000000 -1000000000 1000000000 1000000000 -999999999 -999999999 999999999 999999999 -1000000000 -1000000000 999999999 1000000000 -999999998 -999999998 999999998 999999999 -999999998 -999999999 1000000000 999999998 -999999997 -999999999 999999997 1000000000 -999999997 -999999998 1...
output:
7068239218923.5156250000
result:
ok found '7068239218923.5156250', expected '7068239218923.4824219', error '0.0000000'
Test #36:
score: 0
Accepted
time: 17ms
memory: 4052kb
input:
5000 513113832 317022344 -195627208 -861058397 -701102409 683872039 -232916858 -895311518 -709902748 -699035285 -101259535 -574097202 -441586520 -975050457 -932883145 -160150630 942128621 -594109340 -995714416 343225158 836636759 -111350445 237289348 -92696394 -246927599 -109448224 -215232650 -15016...
output:
2931001916139.3344726562
result:
ok found '2931001916139.3344727', expected '2931001916139.3334961', error '0.0000000'
Test #37:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
4 0 0 1 0 0 1 1 1
output:
2.0000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Extra Test:
score: 0
Extra Test Passed