class Solution {
public:
int networkDelayTime(vector<vector<int>>& times, int n, int k) {
vector<vector<pair<int, int>>> graph(n);
for (auto& t : times) {
int u = t0 - 1, v = t1 - 1;
graphu.emplace_back(v, t2);
}
priority_queue<pair<int, int>, vector<pair<int, int>>,
greater<pair<int, int>>>
pq;
pq.push({0, k-1});
vector<int> dist(n, INT_MAX - 10000);
vector<bool> st(n, false);
distk-1=0;
while (pq.size()) {
auto e = pq.top();
pq.pop();
int w = e.first, u = e.second;
if (stu)
continue;
stu = true;
for (auto& o : graphu) {
int v = o.first, ww = o.second;
if (!stv && distv > distu + ww) {
distv = distu + ww;
pq.push({distv, v});
}
}
}
int res = 0;
for (int i = 0; i < n; ++i) {
if (disti == INT_MAX - 10000)
return -1;
res = max(res, disti);
}
return res;
}
};