摘要: 差分约束系统: 正向建 $B A\ge C$ 为 $A\rightarrow B$ 权 $C$,求最长路。 或反向建 $B A\ge C$ 为 $B\rightarrow B$ 权 $ C$,求最短路。 均只能用 SPFA 做。注意判环! cpp include include include in 阅读全文
posted @ 2019-11-15 09:56 greyqz 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Casper is designing an electronic circuit on a $N \times M$ rectangular grid plate. There are $N \times M$ square tiles that are aligned to the grid o 阅读全文
posted @ 2019-11-14 22:11 greyqz 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 一种具有 $f(n)=g(n)+h(n)$ 策略的启发式算法能成为 A 算法的充分条件是: 搜索树上存在着从起始点到终了点的最优路径。 问题域是有限的。 所有结点的子结点的搜索代价值 $ 0$。 $h(n) \le h^\ast (n)$ ($h^\ast (n)$ 为实际问题的代价值)。 "Rem 阅读全文
posted @ 2019-11-14 12:17 greyqz 阅读(210) 评论(0) 推荐(0) 编辑
摘要: Luogu 1087 FBI tree Bzoj 1635 [Usaco2007 JAN] Tallest Cow Bzoj 1088 [SCOI2005] Mine cpp include include int n, d[10005], p[10005], ans; inline bool ch 阅读全文
posted @ 2019-11-13 22:26 greyqz 阅读(149) 评论(0) 推荐(0) 编辑
摘要: [HEOI2015] 定价 "BZOJ 4027" : 在市场上有很多商品的定价类似于 999 元、4999 元、8999 元这样。它们和 1000 元、5000 元和 9000 元并没有什么本质区别,但是在心理学上会让人感觉便宜很多,因此也是商家常用的价格策略。不过在你看来,这种价格十分荒谬。于是 阅读全文
posted @ 2019-11-13 10:44 greyqz 阅读(108) 评论(0) 推荐(0) 编辑
摘要: [SCOI2005] Mine "BZOJ 1088" : 相信大家都玩过扫雷的游戏。那是在一个 n×m的矩阵里面有一些雷,要你根据一些信息找出雷来。万圣节到了 ,“余”人国流行起了一种简单的扫雷游戏,这个游戏规则和扫雷一样,如果某个格子没有雷,那么它里面的数字 表示和它连通的格子里面雷的数目。现在 阅读全文
posted @ 2019-11-12 11:27 greyqz 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Weakness 求数列区间 $\{a_n\}$ 中满足 $i a_j a_k$ 的 $(i, j, k)$ 对的数目。 设对 $a_i$,左侧大于 $a_i$ 的数的数目为 $L_i$,右侧小于 $a_i$ 的数的数目为 $R_i$,易知答案为 $\sum_i L_i R_i$。 构建数值大小线段 阅读全文
posted @ 2019-11-11 20:57 greyqz 阅读(112) 评论(0) 推荐(0) 编辑
摘要: cout 和 printf 在 C++ 中的实现: 四舍六入五随缘 。比如 = 1。 标准做法: 。 矩阵乘法 由 $a_n=2a_{n 3}+a_{n 1}$ 得矩阵转移方程: $$ \begin{bmatrix} a_n & a_{n 1} & a_{n 2} \end{bmatrix} = \ 阅读全文
posted @ 2019-11-09 18:17 greyqz 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 拓扑排序 cpp for (int i=1; i int n, m, w[1003], f[1003][10003], g[1003][10003], ans; int main() { scanf("%d%d", &n, &m); for (int i=1; i=w[i]; j) f[i][j]= 阅读全文
posted @ 2019-11-06 19:05 greyqz 阅读(90) 评论(0) 推荐(0) 编辑
摘要: https://www.cnblogs.com/RabbitHu/p/51nod1353.html 树形 DP 求所有联通块 $\ge K$ 的方案数. 切断:$\forall i\in\left[1, s_u\right]$, $\displaystyle f(u, i) =\sum_{j=1}^ 阅读全文
posted @ 2019-10-31 09:58 greyqz 阅读(112) 评论(0) 推荐(0) 编辑