正文
增加 5 行删除 5 行
47 行未改动484950515253545556575859606162636465666768697071727374757677783 行未改动47 行未改动fprintf(stderr,"%.3lf MB\n",(&MED-&MST)/1048576.0);read(n);read(st);read(ed);for(int i=0;i<=n;++i)read(l[i]),read(r[i]);l[0]=st,r[0]=st,l[n]=ed,r[n]=ed;ans=0;point now=(point){0,st};f[++tlf]=now,g[++tlg]=now;for(int i=1;i<=n;++i){while(tlf>hdf&&1ll*(l[i]-f[tlf].y)*(f[tlf].x-f[tlf-1].x)>=1ll*(f[tlf].y-f[tlf-1].y)*(i-f[tlf].x))tlf--;f[++tlf]=(point){i,l[i]};if(tlf>hdf&&tlg>hdg){while(hdg<tlg&&1ll*(f[hdf+1].y-g[hdg].y)*(g[hdg+1].x-g[hdg].x)>1ll*(g[hdg+1].y-g[hdg].y)*(f[hdf+1].x-g[hdg].x))ans+=dis(g[hdg],g[hdg+1]),hdg++;f[hdf]=g[hdg];}while(tlg>hdg&&1ll*(r[i]-g[tlg].y)*(g[tlg].x-g[tlg-1].x)<=1ll*(g[tlg].y-g[tlg-1].y)*(i-g[tlg].x))tlg--;g[++tlg]=(point){i,r[i]};if(tlf>hdf&&tlg>hdg){while(hdf<tlf&&1ll*(f[hdf+1].y-f[hdf].y)*(g[hdg+1].x-f[hdf].x)>1ll*(g[hdg+1].y-f[hdf].y)*(f[hdf+1].x-f[hdf].x))ans+=dis(f[hdf],f[hdf+1]),hdf++;g[hdg]=f[hdf];}}for(int i=hdf;i<tlf;++i)ans+=dis(f[i],f[i+1]);printf("%.11Lf\n",ans);3 行未改动47 行未改动484950515253545556575859606162636465666768697071727374757677783 行未改动47 行未改动fprintf(stderr,"%.3lf MB\n",(&MED-&MST)/1048576.0);read(n);read(st);read(ed);for(int i=0;i<=n;++i)read(l[i]),read(r[i]);l[0]=st,r[0]=st,l[n]=ed,r[n]=ed;ans=0;point now=(point){0,st};f[++tlf]=now,g[++tlg]=now;for(int i=1;i<=n;++i){while(tlf>hdf&&1ll*(l[i]-f[tlf].y)*(f[tlf].x-f[tlf-1].x)>=1ll*(f[tlf].y-f[tlf-1].y)*(i-f[tlf].x))tlf--;f[++tlf]=(point){i,l[i]};if(tlf>hdf&&tlg>hdg){while(hdg<tlg&&1ll*(f[hdf+1].y-g[hdg].y)*(g[hdg+1].x-g[hdg].x)>1ll*(g[hdg+1].y-g[hdg].y)*(f[hdf+1].x-g[hdg].x))ans+=dis(g[hdg],g[hdg+1]),hdg++;f[hdf]=g[hdg];}while(tlg>hdg&&1ll*(r[i]-g[tlg].y)*(g[tlg].x-g[tlg-1].x)<=1ll*(g[tlg].y-g[tlg-1].y)*(i-g[tlg].x))tlg--;g[++tlg]=(point){i,r[i]};if(tlf>hdf&&tlg>hdg){while(hdf<tlf&&1ll*(f[hdf+1].y-f[hdf].y)*(g[hdg+1].x-f[hdf].x)>1ll*(g[hdg+1].y-f[hdf].y)*(f[hdf+1].x-f[hdf].x))ans+=dis(f[hdf],f[hdf+1]),hdf++;g[hdg]=f[hdf];}}for(int i=hdf;i<tlf;++i)ans+=dis(f[i],f[i+1]);printf("%.11Lf\n",ans);3 行未改动