diff options
Diffstat (limited to 'graph/connect.cpp')
| -rw-r--r-- | graph/connect.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/graph/connect.cpp b/graph/connect.cpp index a7b2811..98b5b25 100644 --- a/graph/connect.cpp +++ b/graph/connect.cpp @@ -5,20 +5,20 @@ struct connect { connect(int n, int m) : n(n), edges(m), lct(n+m) {} - bool connected(int a, int b) { - return lct.connected(&lct.nodes[a], &lct.nodes[b]); + bool connected(int u, int v) { + return lct.connected(&lct.nodes[u], &lct.nodes[v]); } - void addEdge(int a, int b, int id) { + void addEdge(int u, int v, int id) { lct.nodes[id + n] = LCT::Node(id + n, id + n); - edges[id] = {a, b}; - if (connected(a, b)) { - int old = lct.query(&lct.nodes[a], &lct.nodes[b]); + edges[id] = {u, v}; + if (connected(u, v)) { + int old = lct.query(&lct.nodes[u], &lct.nodes[v]); if (old < id) eraseEdge(old); } - if (!connected(a, b)) { - lct.link(&lct.nodes[a], &lct.nodes[id + n]); - lct.link(&lct.nodes[b], &lct.nodes[id + n]); + if (!connected(u, v)) { + lct.link(&lct.nodes[u], &lct.nodes[id + n]); + lct.link(&lct.nodes[v], &lct.nodes[id + n]); }} void eraseEdge(ll id) { |
