正文
增加 9 行删除 9 行
56 行未改动5758596061626364656667686970717273747576777879808182838485868788899091929394959697989956 行未改动g[a].emplace_back(b, c, p);g[b].emplace_back(a, c, p);s[a][c] += p, s[b][c] += p;}cnt = n;for (int y = 1; y <= n; ++ y )for (auto e : g[y]) {int x = get<0>(e), c = get<1>(e), w = get<2>(e);int id = get(y, c);add(x, id, 0);add(id, x, s[y][c] - w);add(y, x, w);add(y, x, s[y][c] - w);}memset(dis, 0x3f, sizeof dis);dis[1] = 0;q.emplace(0, 1);while (q.size()) {int u = q.top().second;q.pop();if (st[u]) continue;st[u] = true;for (auto e : h[u]) {int v = e.first, w = e.second;if (dis[v] > dis[u] + w) {dis[v] = dis[u] + w;q.emplace(dis[v], v);}}}cout << (dis[n] < 1e18 ? dis[n] : -1);return 0;}```56 行未改动5758596061626364656667686970717273747576777879808182838485868788899091929394959697989956 行未改动g[a].emplace_back(b, c, p);g[b].emplace_back(a, c, p);s[a][c] += p, s[b][c] += p;}cnt = n;for (int y = 1; y <= n; ++ y )for (auto e : g[y]) {int x = get<0>(e), c = get<1>(e), w = get<2>(e);int id = get(y, c);add(x, id, 0);add(id, x, s[y][c] - w);add(y, x, w);add(y, x, s[y][c] - w);}memset(dis, 0x3f, sizeof dis);dis[1] = 0;q.emplace(0, 1);while (q.size()) {int u = q.top().second;q.pop();if (st[u]) continue;st[u] = true;for (auto e : h[u]) {int v = e.first, w = e.second;if (dis[v] > dis[u] + w) {dis[v] = dis[u] + w;q.emplace(dis[v], v);}}}cout << (dis[n] < 1e18 ? dis[n] : -1);return 0;}```