摘要:
题目链接:P1600 天天爱跑步 暴力程序(25pts) 复杂度$O(n^2)$ #include<bits/stdc++.h> using namespace std; const int maxn=3e5+10; int n,m,ans[maxn]; inline int read(){ int 阅读全文
摘要:
跟上一题几乎是一模一样的套路。 离线+倍增预处理+开以深度为权值的线段树。 代码如下: #include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; int n,m,f[maxn][20]; int root[maxn],to 阅读全文
摘要:
【问题描述】 小 Z 有一棵 n 个节点的树,以 1 号节点为根,每条边有对应的权值,小 Z 经过时会收到对应权值的保护费。 现在有 q 个询问,每次询问如下: 若小 z 站在 x 号节点上,他需要凑齐至少 k 的路费才能回家,但小 z 每 次只能往下走 (也就是只能往子树方向走),小 z 想知道凑 阅读全文
摘要:
线段树合并,手打一遍过。 非常嗨皮,记录一下。 使用并查集,合并+查询。 代码如下: #include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; int n,m,q,a[maxn],rev[maxn],f[maxn]; in 阅读全文
摘要:
莫队+套路值域分块。 #include<bits/stdc++.h> using namespace std; const int maxn=1e6+10; const int len=305; int n,m,a[maxn],cnt[maxn],sum[maxn],ans[maxn]; int l 阅读全文