ll n, m, k = 1, s, t = 2; cin >> n >> m >> s; for (int i = 0; i < m; i++) { int _a, _b, _d; cin >> _a >> _b >> _d; //不知道要不要算已经到t还往回走的路,现在是没算的 //if (_a != t) gf[_a].push_back({ _b,_d }); gg[_b].push_back({ _a, _d }); }
for (int i = 1; i <= n; i++) { ans[i] = g[i] = maxd; }
g[t] = 0; qg.push(t); while (!qg.empty()) { ll cur = qg.top(); qg.pop(); if (vg[cur]) continue; vg[cur] = 1; for (auto iter = gg[cur].begin(); iter != gg[cur].end(); iter++) { if (!vg[iter->b] && iter->d + g[cur] < g[iter->b]) { g[iter->b] = iter->d + g[cur]; qg.push(iter->b); } } }
//f[s] = 0; qf.push({ s,0 }); while (!qf.empty()) { edge cur = qf.top(); qf.pop();