版本比较
P14251 [集训队互测 2025] Everlasting Friends?
正文
增加 15 行删除 15 行
76 行未改动777879808181828384858686878889906 行未改动9798991001011011021031041051051061071081091091101111121135 行未改动11912012112212312312412512612792 行未改动2202212222232242242252262272282292302302312322332342352352362372382392402412422432432442452462472482492502512512522532542552562562572582592609 行未改动2702712722732742742752762772785 行未改动28428528628728828828929029129217 行未改动310311312313314314315316317318123 行未改动全部展开76 行未改动}
namespace Sub1 { ll ans;
struct node { ll x, y; node(ll _x = 0, ll _y = 0) : x(_x), y(_y) {} } f[maxn];
inline node operator + (const node &a, const node &b) { if (a.y < b.y) { return a; } else if (a.y > b.y) {6 行未改动 return node(x, a.y); } } }
inline node operator * (const node &a, const node &b) { return node(a.x * b.x % mod, a.y + b.y); }
inline node operator / (const node &a, const node &b) { return node(a.x * qpow(b.x, mod - 2) % mod, a.y - b.y); }
void dfs(int u) { f[u] = node(1, 0); for (int v : G1[u]) { dfs(v);5 行未改动 f[u] = f[u] * (f[v] + node(1, 0)); } ans = (ans + (f[u].y ? 0 : f[u].x)) % mod; }
void solve() { for (int i = 1; i <= n; ++i) { fa[i] = i; }92 行未改动
namespace SGT { int ls[maxm], rs[maxm], tag[maxm], nt, stk[maxm], top; pii a[maxm];
inline void init() { for (int i = 0; i < maxm; ++i) { a[i] = pii(inf, 0); } }
inline void pushup(int x) { a[x] = a[ls[x]] + a[rs[x]]; a[x].fst += tag[x]; }
inline void pushtag(int x, int y) { if (!x) { return; } a[x].fst += y; tag[x] += y; }
inline void delnode(int x) { a[x] = pii(inf, 0); ls[x] = rs[x] = tag[x] = 0; if (top + 1 < maxm) { stk[++top] = x; } }
inline int newnode() { assert(nt + 1 < maxm); return top ? stk[top--] : (++nt); }
void update(int &rt, int l, int r, int ql, int qr, int x) { if (!rt) { rt = newnode(); }9 行未改动 update(rs[rt], mid + 1, r, ql, qr, x); } pushup(rt); }
void modify(int &rt, int l, int r, int x) { if (!rt) { rt = newnode(); }5 行未改动 int mid = (l + r) >> 1; (x <= mid) ? modify(ls[rt], l, mid, x) : modify(rs[rt], mid + 1, r, x); pushup(rt); }
int merge(int u, int v, int l, int r) { if (!u || !v) { return u | v; }17 行未改动 pushup(u); delnode(v); return u; }
pii query(int rt, int l, int r, int ql, int qr) { if (!rt) { return pii(inf, 0); }123 行未改动全部展开