# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061062 | Muhammet | Cyberland (APIO23_cyberland) | C++17 | 0 ms | 0 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 <bits/stdc++.h>
#include "cyberland.h"
#include "stub.cpp"
using namespace std;
#define ff first
#define ss second
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
if(*max_element(arr.begin(), arr.end()) == 1 and *min_element(arr.begin(), arr.end()) == 1){
vector <pair<int,int>> v[n];
for(int i = 0; i < m; i++){
v[x[i]].push_back({y[i],c[i]});
v[y[i]].push_back({x[i],c[i]});
}
vector <int> d(n,1e9);
d[0] = 0;
priority_queue <pair<int,int>> q;
q.push({0,0});
while(!q.empty()){
pair <int,int> w1 = q.top();
q.pop();
w1.ff *= (-1);
if(w1.ff != d[w1.ss]) continue;
for(auto [i,w] : v[w1.ss]){
if(d[i] > d[w1.ss] + w){
d[i] = d[w1.ss] + w;
q.push({-d[i],i});
}
}
}
return d[h];
}
return -1;
}