随笔分类 - dfs
摘要:https://www.hackerrank.com/contests/hourrank-19/challenges 第一题略。 第二题是nim博弈,问删掉一个区间的石子,使得先手败的方案有几种,明显维护前缀异或,然后一直加方案数就好了 #include <cstdio> #include <cst
阅读全文
摘要:Bitwise And Queries Time limit: 1500 msMemory limit: 128 MB You are given QQ queries of the form a\ b\ xa b x. Count the number of values yy such that
阅读全文
摘要:题意:给你一棵树,让你求出每个点离树上最远的距离. ...不会做,想了半天查了题解。 对于每一个点最远距离,要么是往下走,要么是从父节点下来的。 dp[u][0]表示跑儿子路的最大值,dp[u][1]表示跑儿子路的次大值.为什么要记录次大值呢。 dp[u][2]表示往父亲那里跑的最大值. dp[v]
阅读全文
摘要:题意:给你一颗树,树上每个节点都有一个权值,父亲和儿子不能同时选,求最大权值 dp[u][0]表示不选u节点时的最大权值,dp[u][1]表示选u时的最大权值。 dp[u][1]+=dp[v][0],选父亲的时候,就加上不选儿子的 dp[u][0]=max(dp[v][0],dp[v][1]),不选
阅读全文
摘要:D. Choosing Capital for Treeland time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The cou
阅读全文

浙公网安备 33010602011771号