思路
看到 $ N \leq 1000$,我们立马想到 Floyd,把每个人都当作点,把传递小丸子所需的时间当作边权去建边。
最后直接跑一遍 Floyd 就好了。
AC 代码
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3+10;
int x[N],y[N],t[N],r[N],n;
double dis[N][N],res;inline void floyd(){for (int k = 1; k <= n; k++){for (int i = 1; i <= n; i++){for (int j = 1; j <= n; j++){dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);}}}
}
int main(){// freopen("text.in","r",stdin);// freopen("text.out","w",stdout);ios::sync_with_stdio(0),cout.tie(0),cin.tie(0);cin>>n;for(int i = 1;i <= n;i++){cin>>x[i]>>y[i]>>t[i]>>r[i];}for(int i = 1;i <= n;i++){for(int j = 1;j <= n;j++){dis[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) / min(t[i], r[j]);}}floyd();sort(dis[1]+1,dis[1]+1+n);for(int i = 2;i <= n;i++){res = max(res,dis[1][i]+n-i);}cout<<fixed<<setprecision(6)<<res;return 0;
}