2022.10.26 闲话
下面是几个 SoyTony 的初等研究
工业制橘子
工业制算法导论
高等研究可以详细问一下 SoyTony .
SoyTony 歌
We are the world
There comes a time when we heed a certain call
When the world must come together as one
There are people dying
And it's time to lend a hand to life
The greatest gift of all
We can't go on pretending day by day
That someone, somewhere will soon make a change
We are all a part of God's great big family
And the truth, you know
Love is all we need
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
Send them your heart so they'll know that someone cares
And their lives will be stronger and free
As God has shown us by turning stone to bread
And so we all must lend a helping hand
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
When you're down and out, there seems no hope at all
But if you just believe there's no way we can fall
Well well well
Let's realize that a change can only come
When we stand together as one
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
We are the world, we are the world
We are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
It's true we'll make a better day
Just you and me
We are the world, we are the children
We are the ones who make a brighter day
So let's start giving
There's a choice we're making
We're saving our own lives
Daleks' Invasion
给一张 \(n\) 个点,\(m\) 条边的无向带权图,对于集合 \(S\) 内的每条边,问它的边权最大改成多少可以使它在原图中的一个 MST 上 .
特殊性质 A. \(|S| = 1\) .
特殊性质 B. 存在一个 MST 使得 \(|S|\) 中不存在树边(可以看成 MST 给定).\(1\le |S|\le n\),令值域为 \(V\) .
Basic
基本思路:
- 非树边:这是一个经典问题,答案即为 MST 上边两端点路径间的权值 min .
- 树边:对于每条非树边考虑计算贡献,则答案为对于所有非树边,覆盖当前边的 MST 上边两端点路径的权值 min(也就是对于每个非树边,对应到 MST 上一条路径 checkmin).
Algorithm 1 - A. \(\Theta(m\log m\log V)\)
因为特殊性质 A 只用查一条边,所以可以考虑二分答案 .
选的时候边权重复优先选 1,Kruskal 跑一遍看 MST 是否包含那个边即可 check .
时间复杂度 \(\Theta(m\log m\log V)\) .
Algorithm 2 - A. \(\Theta(m\log m)\)
令 \(S\) 中唯一元素为边 \((u,v)\),注意到如果去掉边 \((u,v)\) 则 Kruskal 的过程中第一次 \(u,v\) 连通时,答案即为使它们连通的那条边的边权,这可以模拟通过 Kruskal 的过程求解,时间复杂度 \(\Theta(m\log m)\) .
关于证明:注意到 \((u,v)\) 必然是 MST 的非树边,对应边权即为 MST 上 \(u,v\) 路径的权值 min .
Algorithm 3 - B. \(\Theta(n+m\log n)\)
使用基本思路,答案为 MST 上边两端点路径间的权值 min .
然后简单维护一下,可以做到的是:
- 树剖:线段树 \(\Theta(n\log n+m\log^2 n)\) ST 表 \(\Theta(n+m\log n)\) .
- 倍增预处理 \(\Theta((n+m)\log n)\) .
Algorithm 4 - B. \(\Theta(m\log m)\)
考虑沿用 Algorithm 2 做法,去掉 MST 上所有边然后 Kruskal 一下 .
每次暴力更新会对每条树边更新一次,也就是更新 \(n-1\) 次,算上 Kruskal 的复杂度就是 \(\Theta(m\log m)\) .
Algorithm 5 - General. \(\Theta(m\log^2n)\)
树剖一下,就变成区间 checkmin 了 .
大力出奇迹,直接树剖 + Segment Tree Beats!,于是就是 \(\Theta(m\log^2n)\) 的了 .
注意到可以离线,于是 SoyTony 指出可以直接把询问排序然后就变成区间赋值了,线段树平凡维护,然而还是 \(\Theta(m\log^2n)\) 的 .
Algorithm 6 - General. \(\Theta(m\log m)\)
注意到可以离线,显然可以更给力一点啊!
树剖一下,还是变成区间 checkmin .
把所有询问挂点上,具体就类似扫描线,对于每个点开两个 vector 维护以这个点开始的操作和结束的操作,然后扫一遍算答案 .
vector 的总大小是 \(\Theta(m\log m)\),也就是询问次数级别的 . 现在就需要维护一个数据结构支持插入一个数,删除一个数和询问最小值 .
发现 Fibonacci Heap 可以在 \(\Theta(1)\) 时间完成 insert, decrease-key 和 find-min 操作,于是问题就被 \(\Theta(m\log m)\) 解决了 .
被卡空间了 /kk
Algorithm 7 - General. \(\Theta(m\log n)\)
lyin 锐评做法,知识落差限制想象力 .
沿用 Algorithm 5,使用 Global Biased Tree 或者叫全局平衡二叉树维护,即可 \(\Theta(m\log n)\) .
结束 .
题目链接:
- 特殊性质 A:CF1184E1 Daleks' Invasion (easy) .
- 特殊性质 B:CF1184E2 Daleks' Invasion (medium) .
- General:CF1184E3 Daleks' Invasion (hard) .
以下是博客签名,正文无关
本文来自博客园,作者:Jijidawang,转载请注明原文链接:https://www.cnblogs.com/CDOI-24374/p/16829998.html
版权声明:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议(CC BY-NC-SA 4.0)进行许可。看完如果觉得有用请点个赞吧 QwQ