文章列表

# 补题 # 题目链接:左右脑互博 HDU1004 # 题目大意 核心玩法: 给定一个包含 n 个正整数的集合,两人轮流从集合中取走一个数 aia_iai​,满足: aia_iai​&gt;(剩余元素的异或和) 若集合只剩 1 个数,可直接取走。 无法操作者输。 # 核心思路 关键性质:n 很小,考虑状态压缩,再结合只要对于当前状态,可以转移到至少一个必败态,则当前状态为必胜态,否则为必败态,可解 算法选择:状态压缩 + 记忆化搜索 # 易错点 / 坑点 状压后扫描每个位置是否取过的时候,i 应该从 0 开始 点击查看代码 for (int i = 0; i <...

# 曼哈顿距离: d(A,B)=∣x1−x2∣+∣y1−y2∣d(A, B) = |x_1 - x_2| + |y_1 - y_2|d(A,B)=∣x1​−x2​∣+∣y1​−y2​∣ # 切比雪夫距离(棋盘距离): d(A,B)=max⁡(∣x1−x2∣,∣y1−y2∣)d(A, B) = \max(|x_1 - x_2|, |y_1 - y_2|)d(A,B)=max(∣x1​−x2​∣,∣y1​−y2​∣) 常用坐标系转换 # 曼哈顿距离转切比雪夫距离 $ (x, y) \rightarrow (x + y, x - y) $ 原点 A(x1,y1)A(x_1,...

# 图论 # 1. 拓扑排序( Kahn 算法) const int N = 1505; vector&lt;int&gt; e[N], tp; int d[N]; // 存每个点的入度 bool topo(int n) { queue&lt;int&gt; q; for (int i = 1; i &lt;= n; i++) { if (!d[i]) q.push(i); } while (!q.empty()) { int u = q.front(); tp.push_back(u); q.pop(); for (auto i :...

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub. # Quick Start # Create a new post h$ hexo new "My New Post"More info: Writing # Run server h$...