传送门 题意:给一棵树,每条边有权.求一条路径,权值和等于K,且边的数量最小. 思路: 考虑点分治如何合并. 我们利用树形dpdpdp求树的直径的方法,边dfsdfsdfs子树边统计答案即可. 代码: #include<bits/stdc++.h> #define ri register int #define fi first #define se second using namespace std; typedef pair<int,int> pii; inline int…
[IOI2011]Race LG传送门 点分治板子题. 直接点分治统计,统计的时候开个桶维护下就好了. 注(tiao)意(le)细(hen)节(jiu). #include<cstdio> #include<cctype> #include<cstring> #define R register #define I inline using namespace std; const int S=200003,N=400003,K=1000003,inf=0x3f3f3f…
题目 bzoj权限题... Luogu Sol 点分治辣,边权非负,k>=1,开个\(1e6\)的桶就好辣 # include <bits/stdc++.h> # define RG register # define IL inline # define Fill(a, b) memset(a, b, sizeof(a)) using namespace std; typedef long long ll; const int _(2e5 + 5); IL int Input(){ R…
对于这道题,明显是点分治,权值等于k,可以用桶统计树上路径(但注意要清空); 对于每颗子树,先与之前的子树拼k,再更新桶,维护t["len"]最小边数; #include <bits/stdc++.h> using namespace std; #define up(i,l,r) for(register int i = (l); i <= (r); ++i) #define dn(i,l,r) for(register int i = (l); i >= (r…