版本比较
【CF1486F】Pairs of Paths
正文
增加 6 行删除 6 行
34 行未改动35363738394041424344454647484916 行未改动666768697071727374757615 行未改动929394959697989910031 行未改动34 行未改动int sz;int c[_];void init (int tot) { memset(c, 0, sizeof(c)); sz = tot; }void add (int x, int k) { while (x <= sz) c[x] += k, x += lowbit(x); }ll query (int x) {ll res = 0;while (x) res += c[x], x -= lowbit(x);return res;}ll querysum (int l, int r) {return query(r) - query(l - 1);}} using namespace FenwickIndex;int n, m, dfc;16 行未改动if (x == y) return x;per(i, 19, 0) if (anc[x][i] != anc[y][i]) x = anc[x][i], y = anc[y][i];return anc[x][0];}int kthanc (int x, int k) {if (k == -1) return x;rep(i, 0, 19) if (k & (1 << i)) x = anc[x][i]; return x;}int tmp[_];map <pair<int, int>, int> mp;15 行未改动if (u != x) nd -= querysum(dfn[u], ed[u]);if (v != x) nd -= querysum(dfn[v], ed[v]);ret += nd;}for (auto & [p, k] : ad[x]) add(dfn[p], k);for (int y : e[x]) if (y ^ fa) dfs2(y, x);}int main() {/*31 行未改动34 行未改动35363738394041424344454647484916 行未改动666768697071727374757615 行未改动929394959697989910031 行未改动34 行未改动int sz;int c[_];void init (int tot) { memset(c, 0, sizeof(c)); sz = tot; }void add (int x, int k) { while (x <= sz) c[x] += k, x += lowbit(x); }ll query (int x) {ll res = 0;while (x) res += c[x], x -= lowbit(x);return res;}ll querysum (int l, int r) {return query(r) - query(l - 1);}} using namespace FenwickIndex;int n, m, dfc;16 行未改动if (x == y) return x;per(i, 19, 0) if (anc[x][i] != anc[y][i]) x = anc[x][i], y = anc[y][i];return anc[x][0];}int kthanc (int x, int k) {if (k == -1) return x;rep(i, 0, 19) if (k & (1 << i)) x = anc[x][i]; return x;}int tmp[_];map <pair<int, int>, int> mp;15 行未改动if (u != x) nd -= querysum(dfn[u], ed[u]);if (v != x) nd -= querysum(dfn[v], ed[v]);ret += nd;}for (auto & [p, k] : ad[x]) add(dfn[p], k);for (int y : e[x]) if (y ^ fa) dfs2(y, x);}int main() {/*31 行未改动