QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#865742 | #9821. Kruidnoten | cocoa_chan# | WA | 186ms | 52656kb | C++14 | 1.8kb | 2025-01-21 21:40:04 | 2025-01-21 21:40:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double lf;
const ll inf=1e18;
ll n,m,i,j,k,l,r,x,y,z,t,dp[1100000],dp2[1100000],chk[1100000],chk2[1100000];
lf s,w,ww;
pair<ll,ll> pp;
priority_queue<pair<ll,ll>> pq;
vector<pair<ll,ll>> v[1100000];
vector<pair<ll,pair<ll,lf>>> u;
int main()
{
scanf("%lld %lld %lld",&n,&m,&k);
for(i=1;i<=m;i++)
{
scanf("%lld %lld %lld",&x,&y,&z);
v[x].push_back({y,z});
v[y].push_back({x,z});
}
for(i=1;i<=n;i++)
{
dp[i]=inf;
dp2[i]=inf;
}
dp[1]=0;
pq.push({-dp[1],1});
while(!pq.empty())
{
pp=pq.top();
pq.pop();
x=pp.second;
if(chk[x])
continue;
chk[x]=1;
for(auto xx:v[x])
{
if(dp[xx.first]>dp[x]+xx.second)
{
dp[xx.first]=dp[x]+xx.second;
pq.push({-dp[xx.first],xx.first});
}
}
}
dp2[n]=0;
pq.push({-dp2[n],n});
while(!pq.empty())
{
pp=pq.top();
pq.pop();
x=pp.second;
if(chk2[x])
continue;
chk2[x]=1;
for(auto xx:v[x])
{
if(dp2[xx.first]>dp2[x]+1)
{
dp2[xx.first]=dp2[x]+xx.second;
pq.push({-dp2[xx.first],xx.first});
}
}
}
for(i=1;i<=k;i++)
{
scanf("%lld %lf",&x,&w);
ww=max(ww,w);
u.push_back({dp[x]+dp2[x],{x,w}});
}
if(ww<1.0)
{
printf("impossible");
return 0;
}
sort(u.begin(),u.end());
w=1.0;
for(i=0;i<k;i++)
{
s+=lf(u[i].first)*u[i].second.second*w;
w*=(1.0-u[i].second.second);
}
printf("%lf",s);
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 37580kb
input:
5 5 3 1 2 6 3 1 4 4 5 2 1 4 1 3 4 5 2 1.0 3 0.4 5 0.1
output:
12.360000
result:
ok
Test #2:
score: 0
Accepted
time: 4ms
memory: 35708kb
input:
6 5 2 1 2 1 1 3 1 4 5 3 5 6 1 6 3 2 1 0.6283 4 0.3142
output:
impossible
result:
ok
Test #3:
score: -100
Wrong Answer
time: 186ms
memory: 52656kb
input:
100000 200000 100000 44294 64249 1692 7378 18852 7776 39463 38431 606 20000 70894 1855 62415 45345 9503 19929 34981 6932 98404 3420 3525 30677 84948 610 83203 65436 1971 42386 1615 2626 4856 41088 2980 4134 38076 4919 54304 58830 4748 58403 57894 3416 56050 5645 9798 51747 94712 5267 21906 92401 581...
output:
35404.056469
result:
wrong answer