Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fractional_cascading.md): 增加分散层叠 #5589

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

fairytaleqwq
Copy link

  • 我已认真阅读贡献指南 (contributing guidelines) 和社区公约 (code of conduct),并遵循了如何参与页及格式手册页的相应规范。

Copy link

welcome bot commented May 9, 2024

感谢你对 OI Wiki 的关注!记得检查是否遵守了格式规范,听说和项目风格统一的 Pull Request 会更容易被 Merge~

24OI-bot
24OI-bot previously approved these changes May 9, 2024
Copy link
Collaborator

@24OI-bot 24OI-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint finished, ready for review :)

@Enter-tainer
Copy link
Member

请一并修改 mkdocs.yml,并把你的页面添加的合适的位置

Copy link
Member

@Enter-tainer Enter-tainer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前的感觉好像是,题解。

思考,感觉好像还是有点,不对劲

docs/misc/fractional_cascading.md Outdated Show resolved Hide resolved
@@ -0,0 +1,414 @@
# 引入

[P6466 分散层叠算法(Fractional Cascading)](https://www.luogu.com.cn/problem/P6466)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xx算法 好像和 xx算法模板题 是两个概念

docs/misc/fractional_cascading.md Outdated Show resolved Hide resolved
#include <bits/stdc++.h>
#define re register
#define il inline
#define rep(x, qwq, qaq) for (re int(x) = (qwq); (x) <= (qaq); ++(x))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

别整这些宏了 好好写代码

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的我现在改


绝大部分解法都是 $\mathcal O(n\sqrt n\log n)$ 或 $\mathcal O(n\sqrt{n\log n})$ 的,但是其实使用分散层叠能优化为 $\mathcal O(n\sqrt{n\log\log n})$ 甚至 $\mathcal O(n\sqrt n)$。

## 传统的 $\mathcal O(n\sqrt{n\log n})$ 做法
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是应该是三级标题

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以及标题里面不推荐用数学公式。因为显示效果不太好

@fairytaleqwq fairytaleqwq marked this pull request as draft May 9, 2024 12:26

推广(引自论文):

> “如果我们建立分散层叠时选取的比例为 $\frac{1}{r}$(本题 $r=2$),那么 $x$ 在 $M_i$ 中二分查找的结果(即 $y$)指向的 $M_{i+1}$ 的位置和 $x$ 在 $M_{i+1}$ 中二分查找的正确结果的距离不会超过 $r$。因为 $r$ 是一个常数,所以可以在 $\mathcal O(1)$ 的时间复杂度内求出 $x$ 在 $M_{i+1}$ 中二分查找的正确结果。”
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 可以放到折叠框
  2. 大段引原文,感觉不如直接给个原文链接并引用
  3. 哪篇论文

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦对,我加一下来源

给链接是不是要让读者跳转一下,感觉不如直接拉过来

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

都是可以的。建议可以都做。链接,和你的翻译都加上

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经用了 > 的话,是不是就不需要用 “” 了

@HeRaNO HeRaNO changed the title feat(fractional_cascading.md):增加了分散层叠相关 feat(fractional_cascading.md): 增加分散层叠 May 9, 2024
24OI-bot
24OI-bot previously approved these changes May 9, 2024
Copy link
Collaborator

@24OI-bot 24OI-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint finished, ready for review :)

24OI-bot
24OI-bot previously approved these changes May 9, 2024
Copy link
Collaborator

@24OI-bot 24OI-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint finished, ready for review :)


## 参考文献

[蒋明润《浅谈利用分散层叠算法对经典分块问题的优化》](https://rusunoi.github.io/books/National-Team-Thesis/2020.pdf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

综上,取块长为 $\sqrt n$ 时复杂度最优,为 $\mathcal O(n\sqrt n)$。

```cpp
#include <bits/stdc++.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码建议收纳到折叠框里面,可以参考一下其它页面的用法。搜索 ??? 可以搜到

注意折叠框里面的每一行(包括空行)都需要有4格的缩进

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 24 to 32
### 引理 1:$y$ 在 $l_1$ 中的后继一定是 $x$ 在 $l_1$ 中的后继。

> 证明:若 $y$ 在 $l_1$ 中出现过,$y$ 的后继就是 $y$,显然成立。若 $y$ 不在 $l_1$ 中,$y$ 在 $l_1$ 中的后继就是 $x$ 在 $l_1$ 中的后继。

不难发现本条对任意 $l_i(1\le i\le k)$ 均成立。

### 引理 2:$y$ 在 $M_2$ 中的后继与 $x$ 在 $M_2$ 的后继下标差不超过 $2$。

> 证明:因为我们从 $M_2$ 中每两个数就选取一个加入 $M_1$,所以 $x$ 在 $M_2$ 的后继 $p$ 和 $x$ 在 $M_2$ 的后继的后继 $q$ 必定有一个加入了 $M_1$。(在 $M_2$ 中 $\ge x$ 的数 $< 2$ 个的情况下显然成立)因此 $x\le y\le q$,最极端情况下 $y=q$,此时 $y$ 在 $M_2$ 中的后继就是 $q$ 的后继,与 $x$ 的后继下标差为 $2$。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不知道是不是我的问题。感觉这两条引理出现的有点莫名其妙,这里能想办法处理的更符合直觉一点吗

24OI-bot
24OI-bot previously approved these changes May 9, 2024
Copy link
Collaborator

@24OI-bot 24OI-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint finished, ready for review :)

24OI-bot
24OI-bot previously approved these changes May 9, 2024
Copy link
Collaborator

@24OI-bot 24OI-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint finished, ready for review :)

24OI-bot
24OI-bot previously approved these changes May 9, 2024
Copy link
Collaborator

@24OI-bot 24OI-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint finished, ready for review :)

@HeRaNO
Copy link
Collaborator

HeRaNO commented May 10, 2024

我感觉可以看看其他页面内容规划这页吧(包括格式和内容),把原理抽离出题目来讲,最后题目只当做一个例题应用。现在这个版本更像博客或者大号题解?

@fairytaleqwq
Copy link
Author

我感觉可以看看其他页面内容规划这页吧(包括格式和内容),把原理抽离出题目来讲,最后题目只当做一个例题应用。现在这个版本更像博客或者大号题解?

好,我尽量修改

@fairytaleqwq
Copy link
Author

最近学校要期中考试比较忙,不能及时修改,抱歉/ll

考完一定来修!

@HeRaNO HeRaNO added the Busy Author / 作者正忙 作者现在正忙,将于一段时间后继续完善该 PR label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Busy Author / 作者正忙 作者现在正忙,将于一段时间后继续完善该 PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants