#include <iostream>
#include <vector>
#include <queue>
//#include <unordered_map>
#include <iomanip>
#define d long double
#define N 200005
using namespace std;
int n,m;
d vis[N];
struct edge{
int v;
d beauty;
d count;
};
vector<edge>a[N];
struct node{
int u;
d beauty;
d count;
bool operator>(const node& adv) const {
return beauty * adv.count < adv.beauty * count;
}
};
//unordered_map<pair<int,int>,bool>mp;
priority_queue<node,vector<node>,greater<node>>q;
d ans=0;
int main(){
cin >> n >>m;
for (int i =1;i <= m;i++){
int nu,nv;
d nb,nc;
cin >> nu >> nv >> nb >> nc;
a[nu].push_back((edge){nv,nb,nc});
}
q.push((node){1,0,0});
vis[1] = 0;
while(!q.empty()) {
node t = q.top();
q.pop();
if(t.u == n) ans = max(ans,t.beauty / t.count);
for (auto i:a[t.u]){
// if(vis[i.v])continue;
// vis[i.v] = 1;
d temp = (t.beauty + i.beauty) / (t.count + i.count);
if(vis[i.v] > temp)continue;
vis[i.v] = temp;
q.push((node){i.v,t.beauty + i.beauty,t.count + i.count});
}
}
cout << fixed << setprecision(15) << ans;
return 0;
}
为什么 WA,怎么改正?