MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / update_cost

Method update_cost

code/graph/hld.test.cpp:16–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 }
15
16 void update_cost(int u, int v, int c) {
17 if (parent[v].first == u)
18 swap(u, v);
19
20 assert(parent[u].first == v);
21 parent[u] = ii(v, c);
22
23 for (int i = 0; i < size(adj[u]); i++)
24 if (adj[u][i].first == v)
25 adj[u][i] = ii(v, c);
26
27 for (int i = 0; i < size(adj[v]); i++)
28 if (adj[v][i].first == u)
29 adj[v][i] = ii(u, c);
30 }
31
32 int lca(int u, int v) {
33 vi uat, vat; int res = -1;

Callers 1

testFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected