摘要: 题目链接:https://www.acwing.com/problem/content/description/166/ 拓扑排序: 对于图中每条边$(x,y)$, 如果在序列$A$中,\(x\) 始终出现在 \(y\) 的前面,则称序列 \(A\) 为该图的拓扑序 用 \(bfs\) 求解拓扑序, 阅读全文
posted @ 2020-11-08 21:15 Tartarus_li 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/160/ 最小表示法模板题 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<cmath> #i 阅读全文
posted @ 2020-11-08 16:55 Tartarus_li 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/147/ 贪心策略: 将商品按时间排序,维护一个小根堆,如果当前商品过期天数等于堆中商品数量, 且当前商品价值大于堆顶商品,则将堆顶弹出,插入当前商品; 如果当前商品过期天数大于堆中商品数量,则之间将商品插入堆中 阅读全文
posted @ 2020-11-08 16:24 Tartarus_li 阅读(60) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/146/ 令 \(D[i]\) 表示 \(i\) 到根路径上的值的异或之和, 则根据异或的性质,\(u,v\) 间路径的异或和即为 \(D[u] ^ D[v]\) 所以问题就变成了在 \(D\) 中选出异或值最大 阅读全文
posted @ 2020-11-08 15:52 Tartarus_li 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/145/ 把每个整数看成长度为 $32$ 位的 $01$ 串,插入$trie$树, 根据异或运算的性质,要得到最大的异或值,那每次要尽量沿着与当前数字相反的方向走 #include<cstdio> #includ 阅读全文
posted @ 2020-11-08 15:34 Tartarus_li 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/144/ Trie板子题 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<cmath> #in 阅读全文
posted @ 2020-11-08 15:20 Tartarus_li 阅读(84) 评论(0) 推荐(0) 编辑