QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#865746#9821. Kruidnotencocoa_chan#WA 165ms55756kbC++141.8kb2025-01-21 21:41:042025-01-21 21:41:09

Judging History

This is the latest submission verdict.

  • [2025-01-21 21:41:09]
  • Judged
  • Verdict: WA
  • Time: 165ms
  • Memory: 55756kb
  • [2025-01-21 21:41:04]
  • Submitted

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("%.8lf",s);
}

詳細信息

Test #1:

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

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: 1ms
memory: 35776kb

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: 165ms
memory: 55756kb

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