QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#865758#9821. Kruidnotencocoa_chan#WA 162ms56072kbC++141.8kb2025-01-21 21:51:182025-01-21 21:51:27

Judging History

This is the latest submission verdict.

  • [2025-01-21 21:51:27]
  • Judged
  • Verdict: WA
  • Time: 162ms
  • Memory: 56072kb
  • [2025-01-21 21:51:18]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long 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<=0.99995)
    {
        printf("impossible");
        return 0;
    }
    sort(u.begin(),u.end());
    w=lf(1.0);
    for(i=0;i<k;i++)
    {
        s+=lf(u[i].first)*u[i].second.second*w;
        w*=(lf(1.0)-u[i].second.second);
    }
    printf("%.8Lf",s);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 35024kb

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.36000000

result:

ok 

Test #2:

score: 0
Accepted
time: 3ms
memory: 35316kb

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: 162ms
memory: 56072kb

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.05646883

result:

wrong answer