摘要: Problem link->https://www.luogu.com.cn/problem/P7990 Solution 很明显,这是一道贪心,那么该怎么贪呢?仔细琢磨样例之后发现一种方法: 首先,求出对每块草地与其最近的 FN 的距离,装入 $dis[]$ 数组,那么则对于草地 $i$ 而言,只 阅读全文
posted @ 2022-08-02 08:44 lsj2009 阅读(51) 评论(0) 推荐(0)
摘要: Problem 给定 $n$ 个点,问用至多 $2$ 条路径连接点 $1$ 和 $N$ 最小代价。 link->https://www.luogu.com.cn/problem/P7991 Solution 看见这题第一反应:并查集! 题中,提到 “他愿意建造至多两条新道路来实现这一目标”,那么,也 阅读全文
posted @ 2022-08-02 08:42 lsj2009 阅读(73) 评论(0) 推荐(0)
摘要: Problem link->https://www.luogu.com.cn/problem/P8143。 Solution 很明显,排列 $p$ 的生产图要么为偶环图,要么为奇环图。 引理:如果 $p$ 的生产图为偶环数,那么交换其中任意两项 $a_i$ 和 $a_j$,新的排列 $p_1$ 的生 阅读全文
posted @ 2022-08-02 08:39 lsj2009 阅读(34) 评论(0) 推荐(0)
摘要: Problem link->https://www.luogu.com.cn/problem/P8177 Solution 引理:$a_i$ 与 $a_i+d$ 之间可以添加 $2^{\max{k|d\mod{2^k}=0}}-1$ 个数。 证明: 数学归纳法。 当 $d$ 为奇数时,$a_i+a_ 阅读全文
posted @ 2022-08-02 08:35 lsj2009 阅读(39) 评论(0) 推荐(0)
摘要: Problem 给定起点 $(1,1)$ 和终点 $(n,n)$ 和三元组 $(a,b,c)$。可以且仅可以在第一象限活动。对于点 $(x,y)$,如果 $a\le x\le b$ 且 $y\le c$,则经过该点需要单位时间 $2$,反之需要单位时间 $1$。求从起点到终点的最短路程。 link- 阅读全文
posted @ 2022-08-01 14:26 lsj2009 阅读(23) 评论(0) 推荐(0)
摘要: Problem 函数 $f(x)$ 代表 $x$ 的第二大约数。求 $\max\limits_{L\le x\le R}{f(x)}$。 link->https://www.luogu.com.cn/problem/P8219 Solution 如果 $x$ 是偶数的话,那么 $f(x)$ 无疑是 阅读全文
posted @ 2022-08-01 14:24 lsj2009 阅读(22) 评论(0) 推荐(0)
摘要: Problem link->https://www.luogu.com.cn/problem/P8247。 Solution 我们不妨先来考虑,如果神箭游侠处于 $(1,1)$ 点,那么怎样的点 $(a_1,b_1)$ 与 $(a_2,b_2)$ 才能满足他们处于以 $(1,1)$ 为端点的同一条射 阅读全文
posted @ 2022-08-01 14:22 lsj2009 阅读(21) 评论(0) 推荐(0)
摘要: Problem link->https://www.luogu.com.cn/problem/P8248。 Solution 按题意直接构造即可:每次扩展时循环 $1,2,3,4$,判断是否可以添加(循环 $len$ 从 $1$ 到 $\lfloor\frac{i}{2}\rfloor$,判断每个 阅读全文
posted @ 2022-08-01 14:20 lsj2009 阅读(40) 评论(0) 推荐(0)
摘要: Problem 给定字符串 $s$,每次删除最大前缀 $a$ 满足删除后的 $s$ 不包含 $a$,问最终的 $|s|$。 link->https://codeforces.com/contest/1654/problem/B Solution 其实只需要每次删除 $s$ 的首字符即可直至不满足条件 阅读全文
posted @ 2022-08-01 14:18 lsj2009 阅读(26) 评论(0) 推荐(0)
摘要: Problem link->https://www.luogu.com.cn/problem/P8235。 Solution 容易发现,长度为 $n$ 的括号序列使得包含合法括号序列做多的最佳情况是: $$\begin{matrix}\underbrace{\texttt{()()()()..... 阅读全文
posted @ 2022-08-01 14:15 lsj2009 阅读(41) 评论(0) 推荐(0)