随笔分类 - 贪心
摘要:洛谷传送门 AtCoder 传送门 赛时在想一些奇怪的东西,没想到建图。 考虑使用元素两两之间的相对顺序来描述序列。发现若 互质那么它们的相对顺序被确定了。 先把输入的序列从小到大排序。然后考虑互质的数之间先连一条无向边。那么先手要把无向边定向使得它是个 DAG,后手会求出这个 D
阅读全文
摘要:QOJ 传送门 好题。 首先可以视为每一列 的个数 ,超出的最后再无视即可。 首先先不考虑构造。考虑二分 ,考虑 Dilworth 定理,即询问是否有 条链覆盖所有的黑格。 可以调整使得第 条链的起点为 \((n - k + i,
阅读全文
摘要:洛谷传送门 CF 传送门 如果我们能把 路径上的所有点权插入到线性基,那么可以 查询。 但是因为线性基合并只能 (把一个线性基的所有元素插入到另一个),所以只能倍增做 \(O((n + q) \log n \log^2
阅读全文
摘要:洛谷传送门 CF 传送门 要求最大化收益加上支出,又因为每个字符有染红和染蓝两种选择,考虑最小割模型。可以看成是一开始先获得 的收益,然后对于每个 ,连边 ;对于每个 ,连边 \((S, i, r
阅读全文
摘要:洛谷传送门 AtCoder 传送门 非常好题目。 发现每个点颜色被反转的次数是固定的,为其深度(根结点深度为 )。于是可以看作是,一放棋子就得到分数。 那么先手取偶数层和后手取奇数层都会使先手得分,所以双方的目标都是尽可能多取偶数层的结点。 考虑若一开始有偶数层的叶子,那么当前的先手肯定会
阅读全文
摘要:洛谷传送门 AtCoder 传送门 考虑若 是奇数怎么做。枚举 Alice 第一次选的数 ,然后考虑把剩下的数两两结成一个匹配,若 Bob 选了其中一个,Alice 就选另一个。容易发现排序后奇数位和它右边的偶数位匹配最优。那么设奇数位的和为 ,偶数位的和为 \(
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1856E1 "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1856/E1 "CF 传送门") 考虑局部贪心,假设我们现在在 ,我们希
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF725F "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/725/F "CF 传送门") 不错的贪心题。 我们考虑一对照片只有一张的情况。那么
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1844C "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1844/C "CF 传送门") 原题是 [[ARC092E] Both Side
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc092_c "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc092/tasks/arc092_c "AtCoder 传送门") Key obser
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc164_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc164/tasks/arc164_e "AtCoder 传送门") 妙妙题。 我们考虑
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc153_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc153/tasks/arc153_e "AtCoder 传送门") 我们考虑给定 $X
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc308_g "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc308/tasks/abc308_g "AtCoder 传送门") 考虑没有删除操作怎
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc021_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc021/tasks/agc021_e "AtCoder 传送门") 容易发现一个变色龙
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1845C "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1845/C "CF 传送门") 我怎么这么多天没写题解了,快来水一篇。 考虑对
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1842F "洛谷传送门") [CF 传送门](https://codeforces.com/contest/1842/problem/F "CF 传送门") 事实上自己方向一直是错的…… 绝对值不好弄,我一开始的
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc275_g "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc275/tasks/abc275_g "AtCoder 传送门") 原问题等价于: >
阅读全文