版本比较
题解 P9340 【[JOISC 2023 Day3] Tourism】
正文
增加 7 行删除 7 行
25 行未改动262728293030313233343435363738394041414243444520 行未改动6667686970707172727374757676777879804 行未改动85868788898990919293127 行未改动全部展开25 行未改动using namespace std;
namespace BIT { int tree[100007];
inline int lowbit(int x){ return x & (-x); }
inline void add(int n, int x, int k){ while (x <= n){ tree[x] += k; x += lowbit(x); } }
inline int get_sum(int x){ int ans = 0; while (x > 0){ ans += tree[x];20 行未改动 int l; int r; int lca; } Node;
Node tree[400007];
inline void update(int x){ tree[x].lca = lca(tree[x * 2].lca, tree[x * 2 + 1].lca); }
void build(int x, int l, int r){ tree[x].l = l; tree[x].r = r; if (l == r){4 行未改动 build(x * 2, l, mid); build(x * 2 + 1, mid + 1, r); update(x); }
int get_lca(int x, int l, int r){ if (l <= tree[x].l && tree[x].r <= r) return tree[x].lca; int mid = (tree[x].l + tree[x].r) >> 1, ans = 0; if (l <= mid) ans = get_lca(x * 2, l, r);127 行未改动全部展开