随笔分类 - DP,动态规划
摘要:题目链接 题目 给定一棵 个点的带权树,结点下标从 开始到 。寻找树中找两个结点,求最长的异或路径。 异或路径指的是指两个结点之间唯一路径上的所有边权的异或 思路 预处理每个点到根节点路劲的异或和,建一棵01trie树。 对于每个节点,在trie树上找离它最远的节点
阅读全文
摘要:题目链接 题目 This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constra
阅读全文
摘要:题目链接 题目 一年一度的展会要来临了,Farmer John 想要把 ()只奶牛和公牛安排在单独的一行中。 John 发现最近公牛们非常好斗;假如两只公牛在这一行中靠的太近,他们就会吵架,以至于斗殴,破坏这和谐的环境。 John 非常的足
阅读全文
摘要:题目链接 题目 Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make
阅读全文
摘要:题目链接 题目 There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that starts in the upper left cel
阅读全文
摘要:题目 Bessie the cow is trying to walk from her favorite pasture back to her barn. The pasture and farm are on an N×N grid (2≤N≤50 ), with her pasture in
阅读全文
摘要:题目链接 题目 Snuke is having another barbeque party. This time, he will make one serving of Skewer Meal. He has a stock of N Skewer Meal Packs. The i-th Sk
阅读全文
摘要:题目链接 由于BZOJ已挂,这里是黑暗爆炸和hydro的备份 黑暗爆炸: 国王奇遇记 国王奇遇记加强版 hydro: 国王奇遇记 国王奇遇记加强版 题目 Katharon 国有着悠久的历史,每个慕名而来的游客都渴望能在 Katharon 国发现一些奇怪的宝藏。而作为国王的 Kanari 君也梦想着有
阅读全文
摘要:完成情况:(7/9) cf1110e 题目链接 我要是在noip前做这道题就好了。 这道题的本质就是noip2021方差中的一个性质,对于每个数进行修改,就是把它左右的差进行交换。 注意的是首项一定要一样。 Code // Problem: CF1110E Magic Stones // Conte
阅读全文
摘要:题目链接 题目 You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such that t
阅读全文
摘要:题目链接 题目 Define the distance between two strings of the same length as the numbers of the positions where the characters differ in these two strings. I
阅读全文
摘要:题目链接 题目 Your company has just constructed a new skyscraper, but you just noticed a terrible problem: there is only space to put one game room on each
阅读全文
摘要:题目链接 题目 There is a n×m board, a chess want to go to the position (n,m) from the position (1,1). The chess is able to go to position (x2,y2) from the p
阅读全文
摘要:题目链接 题目 Bubu’s bookshelf is in a mess! Help him! There are nbooks on his bookshelf. We define the mess value to be the number of segments of consecuti
阅读全文
摘要:题目链接 题目 将一个8*8的棋盘进行如下分割:将原棋盘割下一块矩形棋盘并使剩下部分也是矩形,再将剩下的部分继续如此分割,这样割了(n-1)次后,连同最后剩下的矩形棋盘共有n块矩形棋盘。(每次切割都只能沿着棋盘格子的边进行) 原棋盘上每一格有一个分值,一块矩形棋盘的总分为其所含各格分值之和。现在需要
阅读全文
摘要:题目链接 题目 折叠的定义如下: 一个字符串可以看成它自身的折叠。记作S = S X(S)是X(X>1)个S连接在一起的串的折叠。记作X(S) = SSSS…S(X个S)。 如果A = A’, B = B’,则AB = A’B’ 例如,因为3(A) = AAA, 2(B) = BB,所以3(A)C2
阅读全文
摘要:cf1110e 给定一个序列 A{},每次可以选择 1 < i < N 的一个元素,更新 。 问是否可以是序列 A{} 变化得到序列 B{}。 判断差分、首项是否相等即可。 poj1191 题面 对于式子中一些没影响的东西去掉,原式就
阅读全文