Submission #1265102

#TimeUsernameProblemLanguageResultExecution timeMemory
1265102lunarechoCyberland (APIO23_cyberland)C++20
8 / 100
17 ms6728 KiB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
    vector<pair<int,ll>> adj[N];
    for(int i=0;i<M;++i)
    {
        adj[x[i]].push_back({y[i], c[i] * 1LL});
        adj[y[i]].push_back({x[i], c[i] * 1LL});
    }
    vector<ll> dist(N, INF);
    dist[0] = 0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<>> pq;
    pq.push({dist[0], 0});
    while(!pq.empty())
    {
        auto [w, u] = pq.top();
        pq.pop();
        if(w > dist[u])
            continue;
        for(auto [v, we] : adj[u])
        {
            if(dist[v] > w + we)
            {
                dist[v] = w + we;
                pq.push({dist[v], v});
            }
        }
    }
    if(dist[H] == -1)
        return (double)-1;
    else
        return (double)dist[H];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...