colorful 133f tree abc

CodeForces 825G Tree Queries

[洛谷传送门](https://www.luogu.com.cn/problem/CF825G "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/825/G "CF 传送门") 模拟赛赛时做法。 看到查询路径点权最小值,想到建重构 ......
CodeForces Queries 825G Tree 825

[CF1794E] Labeling the Tree with Distances 题解

# [CF1794E] Labeling the Tree with Distances 题解 ## 题目描述 给你一个树,边权为 $1$。给定 $n-1$ 个数,你需要将这些数分配到 $n-1$ 个节点上。 一个点 $x$ 是好的,当且仅当存在一种分配方案,所有被分配数的点到 $x$ 的最短路径长 ......
题解 Distances Labeling 1794E 1794

P3521 [POI2011] ROT-Tree Rotations

[P3521 [POI2011] ROT-Tree Rotations](https://www.luogu.com.cn/problem/P3521) 首先合并两棵子树的时候只关心子树内值的个数,并不关心子树内具体是什么顺序,引导从下向上线段树合并计算代价。 每一个值只会出现一次,首先每个叶子节点 ......
Rotations ROT-Tree P3521 3521 2011

1154 Vertex Coloring

题目 A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color. A c ......
Coloring Vertex 1154

ABC296D题解

简单题。 考虑 `-1` 的情况,即为 $n^2 #include #define ll unsigned long long ll n,m; ll ans=1llm) ans=min(ans,a*b); } printf("%llu",ans); } return 0; } ``` ......
题解 296D ABC 296

ABC020C题解

本题二分 + 搜索。 我们可以先二分出 $x$ 可能的值,再用搜索检验这个答案是否满足要求。若满足,左端点右移,否则右端点左移。 至于搜索可以用记搜加速。 注意输出要换行,否则会 WA。 ```cpp #include #include int n,m,t; char map[20][20]; in ......
题解 020C ABC 020

el-tree 折叠节点时去掉 defaultExpandedKeys 中已折叠的节点及其子节点

# 问题场景 树形节点默认是全部折叠的。展开节点A,再把它折叠。然后给节点B新增子节点,新增成功后刷新树,却发现节点A是展开的。 # 原因分析 **树刷新后全部节点都默认是折叠的,除非 `defaultExpandedKeys` 数组中有数据(这些节点数据是展开的)。** 因此,只需要在折叠节点A时 ......
节点 defaultExpandedKeys el-tree tree el

[ABC313F] Flip Machines

Problem StatementThere are $N$ cards numbered $1$ through $N$. Each face of a card has an integer written on it; card $i$ has $A_i$ on its front and $ ......
Machines 313F Flip ABC 313

遍历Tree控件中的节点

class SapGuiTree: class TreeType(enum.Enum): SIMPLE = 0 LIST = 1 COLUMN = 2 @classmethod def show(cls, tree, node, indention): print(indention, node, ......
节点 控件 Tree

题解 ABC309Ex【Simple Path Counting Problem】

好好玩的题。 设普通生成函数 $F_i$,其中 $[z^k]F_i$ 表示从所有起点走到 $(i,k)$ 的方案数。特别地,$[z^k]F_1=\sum\limits_{a\in A}[a=k]$。 注意到 $F_i=(z^{-1}+1+z)F_{i-1}$ **几乎**成立,但是在 $[z^1]F ......
题解 Counting Problem Simple Path

[LeetCode][124]binary-tree-maximum-path-sum

# Content A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can onl ......

Element tree树形控件,多选改为单选

参考:https://blog.csdn.net/yfq946910096/article/details/130145519 ......
树形 控件 Element tree

「题解」Codeforces 825G Tree Queries

点权转边权,把边权设为两个端点的 $\min$,然后发现询问 $x$ 的答案,就是询问 $x$ 与所有黑点的虚树,边权的 $\min$ 是多少。假设要判定答案是否 $\geq k$,那么就是询问 $x$ 只经过 $\geq k$ 是否能到达所有黑点,于是想到建立 Kruskal 重构树,那么 $x$ ......
题解 Codeforces Queries 825G Tree

[LeetCode][96]unique-binary-search-trees

# Content Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 t ......

[ABC305G]

# [[ABC305G] Banned Substrings](https://www.luogu.com.cn/problem/AT_abc305_g) 考虑到字母只有 `a,b`,且限制串的长度不超过 $6$,可以想到以当前处理到的位数、结尾的字符情况为状态动态规划。可以指记录 $5$ 位。 处 ......
305G ABC 305

PQ-Tree

为什么 NOIP 模拟会考到这种东西啊? PQ-Tree 能解决也恐怕仅能解决如下问题: 对于长度为 $n$ 的排列 $p$,在线地给出 $q$ 个限制,每次给定一个集合 $S$,要求在 $p$ 中,$S$ 中的所有数出现位置构成一个连续段,要求对排列计数。 朴素实现的 PQ-Tree 可以给出一个 ......
PQ-Tree Tree PQ

ABC314EX 题解

模拟退火的题解。 题目的难点在于如何计算点到所有线段的距离。 我们可以通过求线段的直线解析式,然后计算与其垂直的直线的斜率,将随机出来的点带入求得直线解析式,然后求两直线交点,判断是否在线段上进行分讨即可,但是我可能写挂了,所以改成用的向量。 ![](https://cdn.luogu.com.cn ......
题解 ABC 314 EX

P9572 Colorful Days♪

## 思路 ### Step0.骗分 显然,题目中的 $c_1,c_2$ 就是为了送分,如果比赛中没有思路,倒是可以直接输出两个 $0$ 先得到 $2$ 分,聊胜于无。 ### Step1.暴力不出奇迹 显然第一个想到的是暴力,枚举 $k$,容易观察得出,若一次增加 $k$ 而 LCS 不变,则再增 ......
Colorful P9572 9572 Days

[ABC238E]Rcange Sums

## 前言 一道水得不能再水的题,虽说在图论的题单里,但我真的没有用图,用了并查集就轻松$AC$。 ## 大意 输入$q$个$l,r$,表示知道$l$到$r$的区间,最后问能不能知道$0$到$n$,能就输出`Yes`,不能就输出`No`。 ## 思路 1. 图论做法:可以把知道$l$到$r$的区间抽 ......
Rcange 238E Sums ABC 238

ABC315G 解题报告

题意:给定 $n,a,b,c,x$,求满足 $1 \le i,j,k \le n$ 且 $ai+bj+ck=x$ 的三元组 $(i,j,k)$ 的个数。$1 \le n \le 10^6$,$1 \le a,b,c \le 10^9$,$1 \le x \le 3 \times 10^{15}$。 ......
报告 315G ABC 315

[ABC098D] Xor Sum 2 题解

### 题解 [传送门](https://luogu.com.cn/problem/at_abc176_d) #### 题目大意 给出一个序列 $A$ ,求 $A_l \oplus A_{l+1} \oplus \dots \oplus A_r = A_l + A_{l + 1} +\dots+ A ......
题解 098D ABC 098 Xor

[ABC254Ex] Multiply or Divide by 2 题解

### 前言 [传送门](https://www.luogu.com.cn/problem/AT_abc254_h) 仅次于文本编辑器的紫水题(草 ### 题意 给你两个集合 $A$ 和 $B$ ,你可以把集合 $A$ 的任意一项变为原来的 $\left \lfloor\frac{1}{2}\rig ......
题解 Multiply Divide ABC 254

[ABC314G]

# [[ABC314G] Amulets](https://www.luogu.com.cn/problem/AT_abc314_g) 考虑如果 $k$ 是固定的,可以二分答案,然后暴力 `check`。 而本题显然不行。 有一个简单的性质:如果我们知道了最多可以打几只怪兽,那么带某种护身符的贡献是 ......
314G ABC 314

【学习笔记】DSU on Tree

## 概述 DSU on Tree 即树上启发式合并,重点不在“合并”,而在利用树链剖分的性质对子树问题进行复杂度正确的分治。 ## 算法流程 1. 递归处理轻儿子的答案 1. 递归处理重儿子的答案 1. 重新遍历轻儿子子树,计算当前子树的答案 1. 如果当前节点是轻儿子,重新遍历整棵子树,清除答案 ......
笔记 Tree DSU on

abc232e Rook Path

开始看成走到相邻格子,后面发现是车的走法。。。 发现可以将整个图分成四个部分, (x1,y1) $(x,y1) (x \neq x1)$ $(x1,y) (y\neq y1)$ $(x,y) (x\neq x1 ,y\neq y1)$ 然后每一部分中的点的答案都是相同的,转移即可。 ```cpp # ......
232e Rook Path abc 232

[CF1790F] Timofey and Black-White Tree 题解

# [CF1790F] Timofey and Black-White Tree 题解 ## 题目描述 ZYH 有一棵 $n$ 个节点的树,最初 $c_0$ 号节点是黑色,其余均为白色。 给定操作序列 $c_1,c_2,\cdots,c_{n-1}$,第 $i$ 次操作表示将 $c_i$ 号节点染黑 ......
题解 Black-White Timofey 1790F Black

CF1762E Tree Sum 题解

## 题意 对于一棵 $n$ 个节点的树 $T$,定义 $\operatorname{good}(T)$ 为真当且仅当边权 $w \in \left\{-1,1\right\}$ 且对于任意节点 $u$,均有 $\displaystyle f(u) = \prod\limits_{\left(u, ......
题解 1762E 1762 Tree Sum

[ABC315G] Ai + Bj + Ck = X (1 <= i, j, k <= N) 题解

# [ABC315G] Ai + Bj + Ck = X (1 #include #include #include #include #define int __int128 using namespace std; typedef pair PII; typedef long long ll; ......
题解 315G lt ABC 315

[ABC314F]

# [A Certain Game](https://www.luogu.com.cn/problem/AT_abc314_f) 关于题目中的样例解释翻译如下: 将队伍中的球员编号表示为 $ x_1,\ x_2,\ \ldots,\ x_k $ 的队伍称为队伍 $ \lbrace\ x_1,\ x_ ......
314F ABC 314

[AGC005C] Tree Restoring 题解

比较简单的题。 ### 思路 我们可以把一棵树抽象成一条极长的链上挂了很多的点。 观察这样的树的性质。 除去中间的每一个 $dis$ 至少有两个点的 $a_i=dis$。 考虑这条链的长度为 $s$。 那么对于中间的点,我们可以分两种情况讨论。 1. $s$ 为偶数 那么我们必然要求在中间的权值只有 ......
题解 Restoring 005C Tree AGC