Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <deque>
- #include <unordered_set>
- #define fi first
- #define se second
- using namespace std;
- const int inf = 1e9;
- int main() {
- int n, m;
- cin >> n >> m;
- vector<vector<pair<int, int>>> g(n);
- for (int i = 0; i < m; i++) {
- int x, y, w;
- cin >> x >> y >> w;
- x--, y--;
- g[x].push_back({y, w});
- g[y].push_back({x, w});
- }
- vector<int> rst(n, inf);
- rst[0] = 0;
- set<pair<int, int>> red;
- for (int i = 0; i < n; i++) {
- red.insert({rst[i], i});
- }
- while (!red.empty()) {
- pair<int, int> mn = *red.begin();
- red.erase(red.begin());
- int h = mn.se;
- for (auto nxt : g[h]) {
- int e = nxt.fi;
- int w = nxt.se;
- if (red.count({rst[e], e})) {
- red.erase({rst[e], e});
- rst[e] = min(rst[h] + w, rst[e]);
- red.insert({rst[e], e});
- }
- }
- }
- for (int i = 0; i < n; i++) {
- cout << i + 1 << ": " << rst[i] << '\n';
- }
- return 0;
- }
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=osztmreojn
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment