rt,这是一份神奇代码,能通过标准版,但弱化版中,这份代码被弱化了(...
#include <bits/stdc++.h>
int main() {
std::ios::sync_with_stdio(0);
std::cin.tie(nullptr);
int n, m, s;
std::cin >> n >> m >> s;
struct Edg {
int v, w;
};
std::map<int, std::vector<Edg>> mp;
for(int i = 1; i <= m; ++i) {
int ui, vi, wi;
std::cin >> ui >> vi >> wi;
mp[ui].push_back({vi, wi});
}
int dis[100003] = {0};
bool vis[100003] = {0};
memset(dis, 0x3f, sizeof(dis));
dis[s] = 0;
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> pq;
pq.push({0, s});
while(!pq.empty()) {
int pnt = pq.top().second;
pq.pop();
if(vis[pnt] == 1) continue;
vis[pnt] = 1;
for(auto j : mp[pnt]) {
if(dis[j.v] > dis[pnt] + j.w) {
dis[j.v] = dis[pnt] + j.w;
pq.push({dis[j.v], j.v});
}
}
}
for(int i = 1; i <= n; ++i) {
std::cout << dis[i] << ' ';
}
return 0;
}
Dijkstra 算法的代码,有哪位大佬能帮忙看看stO...