QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#865753#9821. Kruidnotencocoa_chan#WA 4ms35052kbC++141.8kb2025-01-21 21:46:162025-01-21 21:46:16

Judging History

This is the latest submission verdict.

  • [2025-01-21 21:46:16]
  • Judged
  • Verdict: WA
  • Time: 4ms
  • Memory: 35052kb
  • [2025-01-21 21:46:16]
  • 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<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("%.8lf",s);
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 35052kb

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:

impossible

result:

wrong answer