[c++] Easy to understand Dijkstra's algorithm
\ntypedef pair<int, int> pii;\n\nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int n, int k) {\n        vector<vector<pii> > g
```\ntypedef pair<int, int> pii;\n\nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int n, int k) {\n        vector<vector<pii> > g(n + 1);\n        for (const auto& t : times) {\n            g[t[0]].emplace_back(t[1], t[2]);\n        }\n        const int inf = 1e9;\n        vector<int> dist(n + 1, inf);\n\t\tvector<bool> vis(n + 1, false);\n        dist[k] = 0;\n        priority_queue<pii, vector<pii>, greater<pii> > pq;\n        pq.emplace(0, k);\n        int u, v, w;\n        while (!pq.empty()) {\n            u = pq.top().second; pq.pop();\n\t\t\tif (vis[u]) continue;\n\t\t\tvis[u] = true;\n            for (auto& to : g[u]) {\n                v = to.first, w = to.second;\n                if (dist[v] > dist[u] + w) {\n                    dist[v] = dist[u] + w;\n                    pq.emplace(dist[v], v);\n                }\n            }\n        }\n        int ans = *max_element(dist.begin() + 1, dist.end());\n        return ans == inf ? -1 : ans;\n    }\n};\n```
[]