# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
967050 | akacool445k | 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"
using namespace std;
// #define long long long long
#define ff first
#define ss second
const long long shrek = 1e5;
vector< vector<pair<long long, long long>>> adj(shrek);
double solve(long long n, long long m, long long k, long long h, vector<long long> x, vector<long long> y, vector<long long> c, vector<long long> arr) {
vector<long long> dist (n + 1);
for(long long i = 0; i < n; i++) dist[i] = -1;
for(long long i = 0; i < m; i++) {
adj[x[i]].push_back({y[i], c[i]});
adj[y[i]].push_back({x[i], c[i]});
}
priority_queue <pair<long long, long long>> q;
q.push({0, 0});
while(!q.empty()) {
pair<long long, long long> p = q.top();
q.pop();
if(dist[p.ss] != -1) continue;
dist[p.ss] = -p.ff;
for(auto x : adj[p.ss]) {
q.push({p.ff - x.ss, x.ff});
}
}
return dist[h];
}