题目链接:CF570D
Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n - 1 remaining vertices has a parent in the tree. Vertex is connected with its parent by an edge. The parent of vertex i is vertex pi, the parent index is always less than the index of the vertex (i.e., pi < i).
The depth of the vertex is the number of nodes on the path from the root to v along the edges. In particular, the depth of the root is equal to 1.
We say that vertex u is in the subtree of vertex v, if we can get from u to v, moving from the vertex to the parent. In particular, vertex v is in its subtree.
Roma gives you m queries, the i-th of which consists of two numbers vi, hi. Let’s consider the vertices in the subtree vi located at depth hi. Determine whether you can use the letters written at these vertices to ma

给定一棵以节点1为根的树,每个节点包含一个字母,求解能否从以节点x为根的子树中,深度为d的节点形成回文串。奇数长度回文串字符奇数个数不超过1。使用启发式合并算法,将所有查询存起来一次性计算,确保不修改节点值,不影响答案。
最低0.47元/天 解锁文章
1221

被折叠的 条评论
为什么被折叠?



