-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
173 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[{ | ||
"avartar": "https://www.slongod.top/images/toux.jpg", | ||
"name": "龙龙的 blog", | ||
"url": "https://www.slongod.top", | ||
"title": "前去观赏" | ||
}, | ||
{ | ||
"avartar": "https://www.llingy.top/img/416928.webp", | ||
"name": "long long 的 blog", | ||
"url": "https://www.llingy.top", | ||
"title": "前去观赏" | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: CF1662C | ||
categories: | ||
- 题目 | ||
date: 2023-11-07 21:20:44 | ||
tags: | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: "[Ynoi2019 模拟赛] Yuno loves sqrt technology I" | ||
categories: | ||
- 题目 | ||
date: 2023-11-02 21:33:09 | ||
tags: | ||
- 分块 | ||
--- | ||
区间在线逆序对板子。 | ||
|
||
块内分别记录下排序后的结果,并对每个块分别预处理,块内所有前缀和后缀内逆序对个数,以及对于每个 $k\in[1,n]$,块中有多少大于等于 $k$ 的数。 | ||
|
||
这样就可以很方便求出 $f_{i,j}$ 表示有多少这样的逆序对,使得第一个数在前缀 $[1,j)$ 中,第二个数在块 $i$ 中;$g_{i,j}$ 表示有多少这样的逆序对,使得第一个数在块 $i$ 中,第二个数在后缀 $[j,n)$ 中。对于每个块我们只需要考虑与其不交的前/后缀即可。 | ||
|
||
然后我们将所有逆序对分为四种: | ||
|
||
- 两个数在同一块内,$O(\frac nB)$ 对所有整块,以及两个散块的前后缀和求和得到; | ||
- 第二个数在整块内,讨论第二个数在哪个整块,那么第一个数就被限制在一个区间内,将区间表示为两个前缀相减,通过 $f$ 求出; | ||
- 第二个数在右端散块内,第一个数在整块内,讨论第一个数在哪个整块,第二个数就被限制在右端散块这个区间内,表示为两个后缀相减,通过 $g$ 求出; | ||
- 第二个数在右端散块内,第一个数在左端散块内,对两端块排序过后的数组双指针统计。 | ||
|
||
如果询问的区间完全被包含在一个块内,考虑容斥,设块左端点为 $t$,用 $[t,r)$ 内的逆序对数减去 $[t,l)$ 内的逆序对数和左端点在 $[t,l)$ 且右端点在 $[l,r)$ 内的逆序对数集合即可,其中前两部分已经预处理过,第三部分可以对该块排序后的数组进行简单的统计。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: "[CSP-S2019] 树的重心" | ||
categories: | ||
- 题目 | ||
date: 2023-11-07 16:21:46 | ||
tags: | ||
- 树 | ||
--- | ||
我们令任一重心作为根,分类统计。 | ||
|
||
一棵树的重心要么是根,要么在重儿子内,换言之,在重链上。 | ||
|
||
那么每个子树的重心可以均摊 $O(1)$ 地从其重儿子子树重心开始向上寻找。 | ||
|
||
对于一整棵树去掉一个子树后剩余的连通块,分类讨论: | ||
|
||
如果删掉的部分不在重儿子内,此时删掉的部分大小相同,剩下部分重心一定相同。所以我们只需要从小到大枚举删掉部分的大小,同时向上移动整棵树的重心,时间复杂度 $O(n)$。另统计出轻儿子子树内,某个大小的子树各有多少棵。 | ||
|
||
如果删掉部分在重儿子内,而删掉后重儿子仍然是重儿子,剩余部分的重心仍然在重链上,并且一定不比原重心低,只能是根。 | ||
|
||
否则次重儿子会成为重儿子。此时类似地统计出删除重儿子内某个大小的子树后重心是谁,以及重儿子内某个大小的子树各有多少颗。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: 震波 | ||
categories: | ||
- 题目 | ||
date: 2023-11-01 08:48:42 | ||
tags: | ||
--- | ||
|
||
单点修改,树上查询邻域点权和。 | ||
|
||
如果不带修的话是经典题目[树上邻域数点](https://www.luogu.com.cn/problem/P8498)的弱化版,因为查询时合并簇的次数限制从一次放宽到了 $O(\log n)$ 次。 | ||
|
||
具体做法是建出全局平衡二叉树,对于每个簇的某个界点 $u$,设 $d$ 为簇内到 $u$ 距离最远的点的距离,对于每个 $k\in[1,d]$ 维护簇内于 $u$ 相距为 $k$ 的点的点权和。全局平衡二叉树处理簇内点相关信息时一般不包含界点,否则不方便统计答案,这里同理。 | ||
|
||
于是树上单点修改 $u$ 的点权时,从包含 $u$ 的最小簇($u$ 不能是该簇界点)开始向父亲跳。对途径的每个簇维护的距离两个界点相应距离的点的权值和进行单点修改。 | ||
|
||
查询以 $u$ 为中心的邻域时,将邻域分解为几个整簇和几个簇内邻域进行合并。具体做法是从以 $u$ 为界点的任一簇开始往父亲跳,对途径的每个点,考察邻域是否覆盖到了它的兄弟,它兄弟的界点是否在父亲的簇内。一通合并后记得考察根簇的界点是否在邻域内。 | ||
|
||
簇内查询邻域需要对所维护的到两个节点距离为定值的点的权值和求前缀和,还需要单点修改,所以使用树状数组查询。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: "[省选联考 2022] 卡牌" | ||
categories: | ||
- 题目 | ||
date: 2023-11-07 17:06:08 | ||
tags: | ||
- 容斥 | ||
- 根号分治 | ||
--- | ||
询问有多少种选取的方案,使得取出的集合的并包含给定集合。 | ||
|
||
一眼 NP,于是考虑暴力容斥。 | ||
|
||
将选出集合的并包含给定集合 $\{a_1,a_2,\cdots,a_n\}$ 看作选出的集合并包含 $a_1$ 且包含 $a_2$ 且包含 $a_3$……。经过一步容斥后转化为选出的集合并不包含 $b_1$ 且不包含 $b_2$ 且不包含 $b_3$……(其中 $\{b_1,b_2,\cdots,b_n\}\subseteq\{a_1,a_2,\cdots,a_n\}$),也就是对于询问集合的每个子集,求可选集合中与它不交的有多少个。 | ||
|
||
暴力显然不可取,考虑到质因数分解带自然根号:每个质因数至多有一个不小于 $\sqrt n$ 的质因子。所以我们只用状压前 13 个质数,单独讨论最大的质数即可。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: "[CSP-S 2023] 消消乐" | ||
categories: | ||
- 题目 | ||
date: 2023-11-07 11:16:31 | ||
tags: | ||
- 哈希 | ||
--- | ||
给定一个串,它是可消除的,当且仅当存在两个相邻的位置字符相等,并且删去它们后剩下的字符串是可消除的。 | ||
|
||
如果这个串中出现了多个相邻的位置字符相等呢?我们如何找到删哪个字符能够构成一个可消除字符串呢? | ||
|
||
经过简单考虑后不难发现,一个串如果是可消除的,那么第一步删除任意一组相邻相等字符都可以得到一个可消除串。 | ||
|
||
如果一个串可消除,找出它的任意一组消除方案,其中记与位置 $x$ 一同被删除的是位置 $\hat x$。对于任意一组相邻相等字符 $u,v$($u<v$),如果 $u=\hat v$,那么在原方案中将“删除 $u,v$”这一步放到最开始做,其余步骤不变,仍然合法;否则不难发现原方案中 $\hat u,\hat v$ 之间(不含端点)的子串一定是内部相互配对,那么我们先消除 $u,v$,在删除 $\hat u,\hat v$ 之间的子串后删除 $\hat u,\hat v$,仍然合法。 | ||
|
||
所以我们从前往后考察每个位置,并维护一个栈表示已经做完的前缀中未被匹配的字符。如果当前位置和栈顶相等,立即匹配,弹出栈顶;否则压入栈。显然该串可消除当且仅当结束时栈为空。 | ||
|
||
--- | ||
|
||
原问题是询问这样的可消除子串有多少个。 | ||
|
||
可以把每个点都作为起点扫一遍,每当栈为空就统计一次,时间复杂度 $O(n^2)$。 | ||
|
||
显然我们只能对整个序列扫一次。考虑到一个子串可被消除当且仅当,加入它的第一个位置前,和加入它的最后一个位置后,两个时刻栈相等。对栈进行哈希,每个位置结束后进行统计即可。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: "[CSP-S 2023] 种树" | ||
categories: | ||
- 题目 | ||
date: 2023-11-07 15:47:27 | ||
tags: | ||
- 二分 | ||
--- | ||
对于方案难以通过贪心或 DP 直接构造的题目,可以尝试二分答案后贪心或 DP。 | ||
|
||
以及这道题要求所有树长成时间的**最大值最小**,提示我们二分答案。 | ||
|
||
对于每个节点,给定它长成的最后期限后,可以计算出种下它的最后期限。 | ||
|
||
至于父亲种下时间 $t_u$ 必须早于儿子种下时间 $t_v$ 的限制,我们令 | ||
|
||
$$t'_u=\min\{t_u,\min_v t_v-1\}$$ | ||
|
||
以 $t'_u$ 为修正后的种植最后期限,忽略祖先关系之间的限制,如果能够构造出任意一组合法方案,那么不断交换所有不满足限制的父亲和儿子,一定在有限步内结束,构造出一组满足限制的方案。 | ||
|
||
判断是否存在一组忽略祖先关系限制后的方案,只需按照 $t_u'$ 从小到大排序,贪心选取即可。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: 关于 nalemy.top | ||
layout: "about" | ||
--- | ||
nalemy 是一个热爱算法、热爱编程、热爱竞赛的同学!!1 | ||
|
||
nalemy 想尽可能把自己所学记录下来,方便自己和他人查看!!1 | ||
|
||
于是就有了这个博客!!1 | ||
|
||
--- | ||
|
||
建站记: | ||
|
||
(不知道多久多久以前)建好了以 mkdocs 为框架的站,那时候还不能称之为博客,而是 wiki。 | ||
|
||
2023.10.22 迁移到了 hexo 框架 | ||
|
||
2023.11.8 更新了 about 页面,以及优化了一些配置 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: 友链专版 | ||
layout: "friends" | ||
--- |