LOADING

加载过慢请开启缓存,浏览器默认开启

daily 2

2023/5/24 daily

CF 671A
只有第一次是有区别的,剩下都是两倍到筒子的距离

void solve(){
  double ax,ay,bx,by,tx,ty;
  cin>>ax>>ay>>bx>>by>>tx>>ty;
  int n;
  cin>>n;
  auto dis=[&](double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  };
  double justA=1e16,justB=1e16,justAB=1e16,sum=0;
  for(int i=1;i<=n;++i){
      double x,y;
      cin>>x>>y;
      auto dt=dis(tx,ty,x,y);
      auto da=dis(ax,ay,x,y)-dt;
      auto db=dis(bx,by,x,y)-dt;
      sum+=2*dt;
      justAB=min(justAB,min(justA+db,justB+da));
      justA=min(justA,da);
      justB=min(justB,db);
  }
  cout.precision(10);
  cout<<sum+std::min({justA,justB,justAB})<<'\n';
  return;
}