正文
增加 9 行删除 9 行
27 行未改动2829303132333435363738396 行未改动464748495051525354102 行未改动全部展开1571581591601611621631641653 行未改动16917017117217317417517617736 行未改动21421521621721821922022122222316 行未改动2402412422432442452462472489 行未改动2582592602612622632642652664 行未改动27 行未改动siz[x] += siz[to[i]];}}void dfs2(int x){stk[++ top] = x;for(int i = bg[x], fa; i; i = q[i].nxt){if(q[i].kf >= top) q[i].ans = 0;else fa = stk[top - q[i].kf], q[i].ans = upper_bound(p + cnt[dep[x] - 1] + 1, p + cnt[dep[x]] + 1, dfn[fa] + siz[fa] - 1)- lower_bound(p + cnt[dep[x] - 1] + 1, p + cnt[dep[x]] + 1, dfn[fa]) - 1;}for(int i = head[x]; i; i = nxt[i]) dfs2(to[i]); top --;}6 行未改动for(int i = 1; i <= n; i ++) p[++ cnt[dep[a[i]] - 1]] = i;for(int i = 1; i <= n; i ++) -- cnt[dep[i] - 1];for(int i = 1, u, k; i <= Q; i ++) cin >> u >> k, add2(u, k); dfs2(1);for(int i = 1; i <= Q; i ++) cout << q[i].ans << " ";}```## Cnoi 2019 青染之心102 行未改动全部展开for(int i = 1; i < n; i ++){for(int j = 1; j <= n; j ++) t[j] = 0; int res = 0;for(int j = 1; j <= n; j ++){tmp.clear(); for(auto k : v[i][a[i + 1][j]]) tmp.push_back({k, query(k - 1)});for(auto k : tmp) res = max(res, k.second + 1), add(k.first, k.second + 1);}ans = ans - res;}cout << ans;3 行未改动## Cnoi 2021 矩阵推推式子家人们!手玩一下规律真的很好找啊!因为每轮迭代的变化量是一样的,有答案为$$(\sum\limits_{i=1}^n a_i) \times (\sum\limits_{i=1}^n a_i) \times (\sum\limits_{i=1}^n a_ib_i)^{k-1}$$容易实现。```cpp36 行未改动} return {ansl, R};}std::pair<int,int> guess(int l, int r){if(l == r) return {l, r}; int x = r - l + 1;int pos = l + g[x];int res = Query(pos);if(res == -1) return guess(pos + 1, r);else if(res == 1) return guess(l, pos - 1);else return find(l, r, pos);}16 行未改动nxt[i] = (j += L[i] == L[j + 1]);} memset(f, 0x3f, sizeof f); f[0] = 0;for(int i = 1; i <= m; i ++) f[i] = f[i - nxt[i + n + 1]] + 1;if(f[m] > 1e9) cout << "Fake\n"; else cout << f[m];}```## Cnoi 2021 自我主义的平衡者9 行未改动} printf("%.2f ", 1.0 * sum / n);reverse(a + 1, a + n + 1); sum = 0;for(int i = 1; i <= n; i ++){if(sum <= 1ll * a[i] * (i - 1)) sum = sum + m;} printf("%.2f", 1.0 * sum / n);}```## Cnoi 2021 未来试题4 行未改动27 行未改动2829303132333435363738396 行未改动464748495051525354102 行未改动全部展开1571581591601611621631641653 行未改动16917017117217317417517617736 行未改动21421521621721821922022122222316 行未改动2402412422432442452462472489 行未改动2582592602612622632642652664 行未改动27 行未改动siz[x] += siz[to[i]];}}void dfs2(int x){stk[++ top] = x;for(int i = bg[x], fa; i; i = q[i].nxt){if(q[i].kf >= top) q[i].ans = 0;else fa = stk[top - q[i].kf], q[i].ans = upper_bound(p + cnt[dep[x] - 1] + 1, p + cnt[dep[x]] + 1, dfn[fa] + siz[fa] - 1)- lower_bound(p + cnt[dep[x] - 1] + 1, p + cnt[dep[x]] + 1, dfn[fa]) - 1;}for(int i = head[x]; i; i = nxt[i]) dfs2(to[i]); top --;}6 行未改动for(int i = 1; i <= n; i ++) p[++ cnt[dep[a[i]] - 1]] = i;for(int i = 1; i <= n; i ++) -- cnt[dep[i] - 1];for(int i = 1, u, k; i <= Q; i ++) cin >> u >> k, add2(u, k); dfs2(1);for(int i = 1; i <= Q; i ++) cout << q[i].ans << " ";}```## Cnoi 2019 青染之心102 行未改动全部展开for(int i = 1; i < n; i ++){for(int j = 1; j <= n; j ++) t[j] = 0; int res = 0;for(int j = 1; j <= n; j ++){tmp.clear(); for(auto k : v[i][a[i + 1][j]]) tmp.push_back({k, query(k - 1)});for(auto k : tmp) res = max(res, k.second + 1), add(k.first, k.second + 1);}ans = ans - res;}cout << ans;3 行未改动## Cnoi 2021 矩阵推推式子家人们!手玩一下规律真的很好找啊!因为每轮迭代的变化量是一样的,有答案为$$(\sum\limits_{i=1}^n a_i) \times (\sum\limits_{i=1}^n a_i) \times (\sum\limits_{i=1}^n a_ib_i)^{k-1}$$容易实现。```cpp36 行未改动} return {ansl, R};}std::pair<int,int> guess(int l, int r){if(l == r) return {l, r}; int x = r - l + 1;int pos = l + g[x];int res = Query(pos);if(res == -1) return guess(pos + 1, r);else if(res == 1) return guess(l, pos - 1);else return find(l, r, pos);}16 行未改动nxt[i] = (j += L[i] == L[j + 1]);} memset(f, 0x3f, sizeof f); f[0] = 0;for(int i = 1; i <= m; i ++) f[i] = f[i - nxt[i + n + 1]] + 1;if(f[m] > 1e9) cout << "Fake\n"; else cout << f[m];}```## Cnoi 2021 自我主义的平衡者9 行未改动} printf("%.2f ", 1.0 * sum / n);reverse(a + 1, a + n + 1); sum = 0;for(int i = 1; i <= n; i ++){if(sum <= 1ll * a[i] * (i - 1)) sum = sum + m;} printf("%.2f", 1.0 * sum / n);}```## Cnoi 2021 未来试题4 行未改动