版本比较
[JOISC 2018] 做题记录
正文
增加 12 行删除 12 行
11234556 行未改动62636465666667686970707172737461 行未改动13613713813914014014114214314477 行未改动22222322422522622622722822923023023123223323432 行未改动26726826927027127127227327427527527627727827955 行未改动335336337338339339340341342343175 行未改动全部展开51952052152252352352452552652725 行未改动55355455555655755755855956056145 行未改动607608609610611611612613#### [P14365 [JOISC 2018] 高速公路建设 / Construction of Highway - 洛谷](https://www.luogu.com.cn/problem/P14365)### [P14365 [JOISC 2018] 高速公路建设 / Construction of Highway - 洛谷](https://www.luogu.com.cn/problem/P14365)
查询相当于查根到 $A$ 路径上的顺序对。
最终树的形态是固定的。考虑离线操作,得到整棵树后树剖。56 行未改动 return 0; }```
#### [P14366 [JOISC 2018] 栅栏 / Fences - 洛谷](https://www.luogu.com.cn/problem/P14366)### [P14366 [JOISC 2018] 栅栏 / Fences - 洛谷](https://www.luogu.com.cn/problem/P14366)
计算几何。咕咕咕~
#### [P14367 [JOISC 2018] 帐篷 / Tents - 洛谷](https://www.luogu.com.cn/problem/P14367)### [P14367 [JOISC 2018] 帐篷 / Tents - 洛谷](https://www.luogu.com.cn/problem/P14367)
显然一行如果放了两个那么会导致有两列不能放,列相同。
考虑枚举有 $x$ 个行上的对,有 $y$ 个列上的对,有 $z$ 个单点,那么此时对答案的贡献为:61 行未改动 return 0; }```
#### [P14368 [JOISC 2018] 修行 / Asceticism - 洛谷](https://www.luogu.com.cn/problem/P14368)### [P14368 [JOISC 2018] 修行 / Asceticism - 洛谷](https://www.luogu.com.cn/problem/P14368)
观察到如果 $p_i>p_{i+1}$ 就必定需要分开读;否则直接把 $p_{i+1}$ 跟在 $p_i$ 后面读一定不劣。
设 $f(k)$ 为钦定 $k$ 个 $>$ 的方案数,$g(k)$ 为恰好 $k$ 个 $>$ 的方案数,则:77 行未改动 return 0; }```
#### [P14369 [JOISC 2018] 路网服务 / Road Service - 洛谷](https://www.luogu.com.cn/problem/P14369)### [P14369 [JOISC 2018] 路网服务 / Road Service - 洛谷](https://www.luogu.com.cn/problem/P14369)
提交答案。咕咕咕~
#### [P14370 [JOISC 2018] 最差的记者 3 / Worst Reporter 3 - 洛谷](https://www.luogu.com.cn/problem/P14370)### [P14370 [JOISC 2018] 最差的记者 3 / Worst Reporter 3 - 洛谷](https://www.luogu.com.cn/problem/P14370)
对于第 $0$ 个人,每 $1$ 单位时间会前进 $1$ 单位距离。
对于第 $1$ 个人,当第 $0$ 个人与其距离到达 $D_1+1$ 时,该距离缩减为 $1$,即向前 $D_1$ 单位距离。每 $D_1$ 的时间会触发一次。 32 行未改动 return 0; }```
#### [P14371 [JOISC 2018] 航空路线图 / Airline Route Map - 洛谷](https://www.luogu.com.cn/problem/P14371)### [P14371 [JOISC 2018] 航空路线图 / Airline Route Map - 洛谷](https://www.luogu.com.cn/problem/P14371)
通信题。咕咕咕~
#### [P14372 [JOISC 2018] 比太郎的聚会 / Bitaro's Party - 洛谷](https://www.luogu.com.cn/problem/P14372)### [P14372 [JOISC 2018] 比太郎的聚会 / Bitaro's Party - 洛谷](https://www.luogu.com.cn/problem/P14372)
单次询问 $O(n)$ 求是容易的。
考虑 $\sum Y_i\le n$,因此 $Y_i>\sqrt n$ 的询问不会超过 $O(\sqrt n)$ 个,可以直接暴力 $O(n)$ 求;因为 $Y_i<\sqrt n$ 的询问最多不考虑 $\sqrt n - 1$ 个点,因此答案一定前 $\sqrt n$ 大中取。可以归并预处理每个点的对应的前 $\sqrt n$ 大点即答案。55 行未改动 return 0; }```
#### [P14373 [JOISC 2018] 安全门 / Security Gate - 洛谷](https://www.luogu.com.cn/problem/P14373)### [P14373 [JOISC 2018] 安全门 / Security Gate - 洛谷](https://www.luogu.com.cn/problem/P14373)
思路有点长,感觉以本人的语文水平写出来会是一坨。直接去看 **[官方题解](https://www2.ioi-jp.org/camp/2018/2018-sp-tasks/day3/security_gate-review.pdf)** 吧,写的很清晰了。
大概就是对每个有贡献的 $S'$ 串按照前后缀分类计入贡献。175 行未改动全部展开 return 0; }```
#### [P14374 [JOISC 2018] 糖果 / Candies - 洛谷](https://www.luogu.com.cn/problem/P14374)### [P14374 [JOISC 2018] 糖果 / Candies - 洛谷](https://www.luogu.com.cn/problem/P14374)
(反悔贪心裸题?)
直接链表+堆维护,每次取最大的,取 $i$ 后 $a_i\leftarrow a_{\text{pre}}+a_{\text{nxt}}-a_i$ 并删去 $\text{pre}$ 和 $\text{nxt}$。25 行未改动 return 0; }```
#### [P14375 [JOISC 2018] 图书馆 / Library - 洛谷](https://www.luogu.com.cn/problem/P14375)### [P14375 [JOISC 2018] 图书馆 / Library - 洛谷](https://www.luogu.com.cn/problem/P14375)
$n\le 1000,q\le 2\times 10^4$,因而猜测大概是 $O(n\log n)$ 的算法。
发现对一个集合 $S$ 进行询问返回的是 $|S|-w(S)$,其中 $w(S)$ 表示 $S$ 中在图书馆里相邻的图书对数。45 行未改动 Answer(ans);}```
#### [P14376 [JOISC 2018] 野猪 / Wild Boar - 洛谷](https://www.luogu.com.cn/problem/P14376)### [P14376 [JOISC 2018] 野猪 / Wild Boar - 洛谷](https://www.luogu.com.cn/problem/P14376)
咕咕咕~