摘要: 题目链接 Alyona and a tree 比较考验我思维的一道好题。 首先,做一遍DFS预处理出$t[i][j]$和$d[i][j]$。$t[i][j]$表示从第$i$个节点到离他第$2^{j}$近的祖先,$d[i][j]$表示从$i$开始到$t[i][j]$的路径上的路径权值总和。 在第一次D 阅读全文
posted @ 2016-12-15 20:26 cxhscst2 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 枚举第一行第一个格子的状态(有雷或者无雷,0或1),然后根据第一个格子推出后面所有格子的状态。推出之后判断解是否可行即可。 #include using namespace std;#define REP(i,n) for(int i(0); i = (b); -... 阅读全文
posted @ 2016-12-15 20:18 cxhscst2 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 非常简单的DP题。类似背包的操作,按照音量改变值进行状态转移即可。 #include using namespace std;#define REP(i,n) for(int i(0); i = (b); --i)#define for_edge(i,x) ... 阅读全文
posted @ 2016-12-15 20:15 cxhscst2 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 差不多可以说是树链剖分的模板题了,直接维护即可。 #include using namespace std;#define REP(i,n) for(int i(0); i = (b); --i)#define for_edge(i,x) ... 阅读全文
posted @ 2016-12-15 20:11 cxhscst2 阅读(117) 评论(0) 推荐(0) 编辑