CARVIEW |
Select Language
HTTP/2 200
date: Wed, 15 Oct 2025 01:41:22 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=1543e22a46cc5f33e66700a34b3e8a946bf36db236d3d66bb15159c2ee1c98c3a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22bZwcWh9PgssrL25qOt9C_LAgDD8F98zw%22%3B%7D; HttpOnly; Path=/
cf-ray: 98eb9d1dcfb8999b-BLR
Дейкстра - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <vector>
- #include <deque>
- #include <map>
- #include <cmath>
- #include <random>
- #define se second
- #define fi first
- #define mp make_pair
- #define pb push_back
- typedef long long ll;
- typedef long double ld;
- using namespace std;
- const int inf = (int)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(make_pair(y, W));
- g[y].push_back(make_pair(x, W));
- }
- int start;
- cin >> start;
- start--;
- vector<int> w(n, inf);
- w[start] = 0;
- set<pair<int, int>> st;
- for (int i = 0; i < n; i++) {
- st.insert({w[i], i});
- }
- while (!st.empty()) {
- pair<int, int> cur_pair = *st.begin();
- st.erase(cur_pair);
- int cur_rst = cur_pair.first;
- int cur = cur_pair.second;
- for (auto e : g[cur]) {
- int nxt = e.first;
- int cur_nxt_w = e.second;
- if (w[nxt] > w[cur] + cur_nxt_w) {
- st.erase({w[nxt], nxt});
- w[nxt] = w[cur] + cur_nxt_w;
- st.insert({w[nxt], nxt});
- }
- }
- }
- for (auto e : w) cout << e << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⚡ Crypto Swap Glitch ✅ Working ⚡
JavaScript | 10 sec ago | 0.24 KB
-
💵 Make 3000$ in 20 minutes 💵
JavaScript | 21 sec ago | 0.24 KB
-
🔥 Exchange profit method
JavaScript | 30 sec ago | 0.24 KB
-
🚨 Free Crypto Method 🚨
JavaScript | 49 sec ago | 0.24 KB
-
💡 Instant BTC Profit Method ✅ Working
JavaScript | 58 sec ago | 0.24 KB
-
📝 MAKE $2500 IN 15 MIN ✅ Working
JavaScript | 1 min ago | 0.24 KB
-
🚀 Swapzone +37% glitch
JavaScript | 1 min ago | 0.24 KB
-
💎 ChangeNOW Exploit
JavaScript | 1 min ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand