跳到正文

个人记录

快乐寒假(?题目总结)

Bb1t约 8 分钟
原文
文章信息与版本

文章信息

发布
2022年1月17日
收录
2026年3月3日
更新
2026年11月11日
篇幅
约 8 分钟

版本

  1. v1当前

Day 1

DS_problem 1{\color{green}\sqrt{}}

DS_problem 2{\color{green}\sqrt{}}

DS_problem 3

DS_problem 4{\color{green}\sqrt{}}

DS_problem 5(数据有问题不然直接 print(input()))

DS_problem 6{\color{green}\sqrt{}}

DS_problem 7{\color{green}\sqrt{}}

DS_problem 8{\color{green}\sqrt{}}

DS_problem 1

单调栈模板题。

DS_problem 2

找性质。

像 DS_problem 1 处理找出第一个比他大的数,之后处理递推后缀和。

先用 ST\text{ST} 表 O(nlog⁡n)O(n\log n) 预处理区间最小数的位置,询问时 O(1)O(1) 查出,之后 O(1)O(1) 回答。

DS_problem 4

原题

思考以每一个点为最小值时,取得最大和为多少。

DS_problem 6

滑动窗口模板题。

DS_problem 7

二维滑,为此我还特意写了一个封装。

Day 2

巩固。

都是水题。by cy

发射站{\color{green}\sqrt{}}

长方形{\color{green}\sqrt{}}

[HNOI2008]水平可见直线{\color{green}\sqrt{}}

宝物筛选{\color{green}\sqrt{}}

[NOI2005] 瑰丽华尔兹{\color{green}\sqrt{}}

【模板】单源最短路径(标准版){\color{green}\sqrt{}}

种树{\color{green}\sqrt{}}

[SCOI2010]股票交易

发射站

几乎是单调栈模板题。

长方形

听懂了,好像又没懂。

以每个点为中心,设左边能拓展到的为 ll,右边同理设为 rr,上面同理设为 hh。则它的贡献为 lrhlrh。

此过程用单调栈维护。

[HNOI2008]水平可见直线

神奇的题目。

现以 kk 和 bb 作为关键字排序,之后用二直线交点关系判断是否会被覆盖和后续的栈操作。

宝物筛选

多重背包。

[NOI2005] 瑰丽华尔兹

暴力 DP 能 A,并且理论上来讲稍微卡常应该能 A。所以我没写单调队列

【模板】单源最短路径(标准版)

堆优化 Dij。

种树

神奇的反悔贪心。

Day 3 union find set

【模板】并查集{\color{green}\sqrt{}}

[CEOI1999]Parity Game{\color{green}\sqrt{}}

Almost Union-Find{\color{green}\sqrt{}}

[NOI2001] 食物链{\color{green}\sqrt{}}

[POI2005]SKA-Piggy Banks{\color{green}\sqrt{}}

[POI2008]CLO-Toll{\color{green}\sqrt{}}

[APIO2011]方格染色40{\color{orange}40}

[AHOI2013]连通图{\color{green}\sqrt{}}

【模板】并查集

模板。

[CEOI1999]Parity Game

种类并查集可过,稍稍讨论奇偶关系即可。

Almost Union-Find

1,31,3 操作模板,22 操作需要一个虚点。

[NOI2001] 食物链

大力种类并查集,最后又用权值并查集写了一遍。

[POI2005]SKA-Piggy Banks

最水的一道,并查集找环。

[POI2008]CLO-Toll

先找一棵树,最后找一条边构成基环树,之后再把剩下的点连起来。

[APIO2011]方格染色

骗了 4040 分。

[AHOI2013]连通图

整活的提交答案。

Day 4 segment tree

【模板】线段树 1{\color{green}\sqrt{}}

【模板】线段树 2{\color{green}\sqrt{}}

楼房{\color{green}\sqrt{}}

[TJOI2011]书架{\color{green}\sqrt{}}

[BJOI2016]回转寿司{\color{green}\sqrt{}}

【模板】线段树 1&【模板】线段树 2

好久之前做的模板了。

楼房

区间 max⁡\max 和最后的遍历。

[TJOI2011]书架

暴力 O(n2)O(n^2) DP+O2。

[BJOI2016]回转寿司

最水省选题。

首先题目让你求满足

L≤∑i=lrai≤RL\le\sum_{i=l}^r a_i\le R

的 (l,r)(l,r) 个数。

将柿子变形

L≤∑i=lrai≤RL\le\sum_{i=l}^r a_i\le R L≤∑i=1rai−∑i=1l−1ai≤RL\le\sum_{i=1}^r a_i-\sum_{i=1}^{l-1} a_i\le R ∑i=1rai−R≤∑i=1l−1ai≤∑i=1rai−L\sum_{i=1}^r a_i-R\le\sum_{i=1}^{l-1} a_i\le\sum_{i=1}^r a_i-L

然后可以先枚举 rr,这样未知数只有中间的一个数,相当于是区间查询(区间内满足的个数),单点修改(将 sum⁡\operatorname{sum} 扔进来),可以用 BIT 维护。(要离散化)

Day 5

[Round 2] DS_problem 16 奇怪的计算器{\color{green}\sqrt{}}

[Round2] DS_problem 17

[Round 2] DS_problem 18{\color{green}\sqrt{}}

[Round 2] DS_problem 19{\color{green}\sqrt{}}

算术天才⑨与等差数列

[Round 2] DS_problem 16 奇怪的计算器

神奇标记下传,码量大,难调。

[Round 2] DS_problem 18

ODT 乱搞 A 了。

[Round 2] DS_problem 19

维护 2×22\times2 的矩阵中 44 个点的距离,合并时稍微讨论,查询注意细节即可。

Day 6 树状数组

BIT 好简单啊。

前面几道模板不写了,都 A 了。

[Round 2] DS_problem 13 Nested Segment(CodeForces 652D){\color{green}\sqrt{}}

[Round 2] DS_problem 14 D-Query{\color{green}\sqrt{}}

1h AK,多罚我 2h

[Round 2] DS_problem 13 Nested Segment(CodeForces 652D)

先按套路右端点排序,再离散化就没了。

[Round 2] DS_problem 14 D-Query

有人用莫队水过去了,我让他们去 A P1972 机房有人用的在线算法,%%%

先离线,按右端点排序。 指针从 11 开始指,每次扫到 rr,不重复在 BIT 上的标记位置,重复把之前的删掉,每次查询 [l,r][l,r] 的和。

Day 7

数据结构 test。PDF

开始因为 C++98 的原因,我全 CE 保灵,换成 C++14 就好了,还拿了 rk 1

开题顺序:54312。

得分:30+98+100+100+80=40830+98+100+100+80=408

std:100+100+100+0+90=390

A(P1950)

没错,做过的题不会做,写了前缀和 O(n4)O(n^4) 的 3030 分滚了。

B(U199603 or U199604)

一眼双指针,正解 O(n)O(n) 单调队列。我没看出来

考试最后 1h1h 写了 小常数的 zkw 线段树 O(nlog⁡n)O(n\log n)。就卡掉我 22 分。

C(类似 P3144)

离线,删点就相当于加点,这样就是并查集裸题。带权并查集

D(U199616)

BIT,就是出题人说的只能用 BIT 不能用 segment tree

E(P2061)

卡常题,正解并查集维护,接近 O(n)O(n)。

由于排序后只有区间推平,所以 ODT 复杂度有保证,为 O(nlog⁡n)O(n\log n)。

但由于只有 0.1s0.1s,set 常数大被卡常了。

原文
存档评论1 条抓取于