正文
增加 6 行删除 6 行
60 行未改动616263646566676869498 行未改动全部展开5685695705715725735745755765775785795805815825835845855865875885895905915925935944 行未改动59960060160260360460560660718 行未改动60 行未改动一道 Floyd 模版题。Floyd 的原理是动态规划。${{dp_k}_i}_j$ 表示只允许使用前$k$ 个节点作为中间节点时,从节点 $i$ 到节点 $j$ 的最短路径长度。那么转移方程就很好想了:498 行未改动全部展开#define endl '\n'typedef long long ll;typedef pair<ll, ll> PI;const ll N = 2e5 + 10, inf = 1e18;ll n, m, a, b, c[N];priority_queue<PI, vector<PI>, greater<PI> > q;vector<PI> g[N];ll dis[N];bool ok[N];void Dij(){for(int i = 1; i <= n; i++) dis[i] = inf, ok[i] = 0;dis[b] = 0;q.push({0, b});while (q.size()) {int x = q.top().second;q.pop();if (ok[x]) continue;ok[x] = 1;for(int i = 0; i < g[x].size(); i++){ll y = g[x][i].second, w = g[x][i].first;if (dis[y] > dis[x] + w)4 行未改动}}return;}int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin >> n >> m >> a >> b;for (int i = 1; i <= n; i++) {18 行未改动60 行未改动616263646566676869498 行未改动全部展开5685695705715725735745755765775785795805815825835845855865875885895905915925935944 行未改动59960060160260360460560660718 行未改动60 行未改动一道 Floyd 模版题。Floyd 的原理是动态规划。${{dp_k}_i}_j$ 表示只允许使用前$k$ 个节点作为中间节点时,从节点 $i$ 到节点 $j$ 的最短路径长度。那么转移方程就很好想了:498 行未改动全部展开#define endl '\n'typedef long long ll;typedef pair<ll, ll> PI;const ll N = 2e5 + 10, inf = 1e18;ll n, m, a, b, c[N];priority_queue<PI, vector<PI>, greater<PI> > q;vector<PI> g[N];ll dis[N];bool ok[N];void Dij(){for(int i = 1; i <= n; i++) dis[i] = inf, ok[i] = 0;dis[b] = 0;q.push({0, b});while (q.size()) {int x = q.top().second;q.pop();if (ok[x]) continue;ok[x] = 1;for(int i = 0; i < g[x].size(); i++){ll y = g[x][i].second, w = g[x][i].first;if (dis[y] > dis[x] + w)4 行未改动}}return;}int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin >> n >> m >> a >> b;for (int i = 1; i <= n; i++) {18 行未改动