ABC324第F题为什么WA
  • 板块学术版
  • 楼主high_sky
  • 当前回复7
  • 已保存回复7
  • 发布时间2023/10/14 22:00
  • 上次更新2023/11/2 13:46:38
查看原帖
ABC324第F题为什么WA
701202
high_sky楼主2023/10/14 22:00
#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,怎么改正?

2023/10/14 22:00
加载中...