60pt求助
查看原帖
60pt求助
288716
lzqy_楼主2021/4/2 13:12

rt,就是floyd板子/kk

#include<bits/stdc++.h>
using namespace std;
const int maxn=210;
const long double cha=0.00000000001;
const int inf=16000000000;
struct str
{
	int w,h;
	long double p;
}a[maxn][maxn];
bool operator <(str a,str b)
{
	if(abs(a.p-b.p)>cha) 
		return a.p>b.p;
	return a.w<b.w;
}
bool operator >(str a,str b)
{
	if(abs(a.p-b.p)>cha) 
		return a.p<b.p;
	return a.w>b.w;
}
str operator +(str a,str b)
{
	a.w+=b.w,a.p*=b.p;
	return a;
}
int n,s,T;
int main()
{
	cin>>n>>s>>T;
	for(register int i=1;i<=n;i++)	
		for(register int j=1;j<=n;j++)
			cin>>a[i][j].w;
	for(register int i=1;i<=n;i++)	
		for(register int j=1;j<=n;j++)
			cin>>a[i][j].p,a[i][j].p=1-a[i][j].p;
	for(register int k=1;k<=n;k++)
		for(register int i=1;i<=n;i++)
			for(register int j=1;j<=n;j++)
				a[i][j]=min(a[i][k]+a[k][j],a[i][j]);
	cout<<a[s][T].w<<" "<<setprecision(4)<<fixed<<1-a[s][T].p<<endl;
	return 0;
}
2021/4/2 13:12
加载中...