树链
ChengYuQi621
北京邮电大学人工智能学院
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
P2590 [ZJOI2008]树的统计
#include<bits/stdc++.h> #define N 100005 #define inf 1000000000 using namespace std; int n,q,a[4*N]; struct Edge{ int u,v,next; }G[N]; int tot=0,head[N]; int size[100005],wson[100005],fa[100...原创 2019-07-23 14:21:20 · 130 阅读 · 0 评论 -
P1005 矩阵取数游戏
题目大意 有一个n \times mn×m的矩阵,对于第ii行,每次取走边缘的值A_{i,j}A i,j ,增加这一行的得分xx(自行看题目规则),求nn行的最大得分总和。 分析一下 求nn行最大得分和,每一行取数又不会影响到其他行,那么只要确保每一行得分最大,管好自家孩子就行了。(这个在动规中叫最优子结构) 每次取数是在边缘取,那么每次取数完剩下来的元素一定是在一个完整的一个区间中,又是求...原创 2019-07-23 14:22:25 · 135 阅读 · 0 评论 -
P3384 【模板】树链剖分
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN=2*1e6+10; #define ls k<<1 #define rs k<<1|1 inline char nc() { static char b...原创 2019-07-23 14:24:06 · 155 阅读 · 0 评论 -
P3884 [JLOI2009]二叉树问题
#include<bits/stdc++.h> #define For(i,j,k) for(int i=j;i<=k;i++) #define maxn 202 using namespace std; int now,head[maxn],n,m,s,d[maxn],deep[maxn],p[maxn][11],maxx; struct node{ int a,b,n...原创 2019-07-23 14:25:04 · 180 阅读 · 0 评论
分享