大佬求调!!!感觉没错而且样例可过但全wa,
查看原帖
大佬求调!!!感觉没错而且样例可过但全wa,
701120
mab123456楼主2025/1/26 01:40
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=1e5+5,inf=-0x3f;
ll n,m,a,b;
struct node{
	ll x;
	double w;
	bool operator<(const node&u)const
	{
		return u.w>w;
	}
};
vector<node>g[N];
double d[N];
void di(int x)
{
	for(int i=1;i<=n;i++)
	d[i]=inf;
	bitset<N>vis;
	priority_queue<node>pq;
	pq.push({x,d[x]=1});
	while(!pq.empty())
	{
		ll xx=pq.top().x;
		double yy=pq.top().w;
		pq.pop();
		if(vis[xx])
		continue;
		vis[xx]=true;
		for(const auto n1:g[xx])
		{
			ll xxx=n1.x;
			double yyy=n1.w;
			if(d[xxx]<d[xx]*yyy)
			{
				d[xxx]=d[xx]*yyy;
				if(!vis[xxx])pq.push({xxx,d[xxx]});
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	while(m--)
	{
		int x,y;
		double z;
		cin>>x>>y>>z;
		g[x].push_back({y,1-z/100});
		g[y].push_back({x,1-z/100});
	}
	di(1);
	cin>>a>>b;
	printf("%.8lf",100/d[b]);
	return 0;
}
2025/1/26 01:40
加载中...