# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976625 | rakhim_ova | Cyberland (APIO23_cyberland) | C++17 | 27 ms | 6744 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF=1e13;
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) {
int n=N, m=M, k=K, h=H;
double res=-1;
vector<vector<pair<int, double>>> adj(n);
for(int i=0; i<m; i++){
adj[x[i]].push_back({y[i], c[i]});
adj[y[i]].push_back({x[i], c[i]});
}
vector<double> d(n, INF);
vector<bool> ch(n, false);
priority_queue<pair<double, int>> pq;
d[0]=0;
pq.push({0, 0});
while(!pq.empty()){
int t=pq.top().second; pq.pop();
if(ch[t]) continue;
ch[t]=true;
for(auto x: adj[t]){
if(d[t]+x.second<d[x.first]){
// cout << t << ' ' << x.first << ' ' << d[t]+x.second << '\n';
pq.push({-(d[t]+x.second), x.first});
d[x.first]=d[t]+x.second;
}
}
}
if(d[h]==INF){
return -1;
}
// for(auto x: d) cout << x << ' ';
// cout << '\n';
return d[h];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |