题解atcoder agc 004

AGC002E Candy Piles

> 桌上有 $n$ 堆糖果,第 $i$ 堆糖果有 $a_i$ 个糖。两人在玩游戏,轮流进行,每次进行下列两个操作中的一个: > > 1. 将当前最大的那堆糖果全部吃完 > 2. 将每堆糖果吃掉一个 > > 吃完的人输,假设两人足够聪明,问谁有必胜策略? 把序列从大到小排序,观察到 $2$ 操作后最大 ......
Candy Piles 002E AGC 002

「杂题乱写」AGC 002

# 「杂题乱写」AGC 002 点击查看目录 > [TOC] ## [A | Range Product](https://www.luogu.com.cn/problem/AT_agc002_a) 分讨不解释。 ## [B | Box and Ball](https://www.luogu.com ......
AGC 002

AtCoder Beginner Contest 149 F Surrounded Nodes

[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc149_f "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc149/tasks/abc149_f "AtCoder 传送门") 不错的题。 考虑题 ......
Surrounded Beginner AtCoder Contest Nodes

AT_abc304_f 题解

一、题目描述: 给你一个长度为 $n$ 的字符串 $s$ ,$s_i$ 要么是 $\#$ ,要么是 $.$ 。 求有多少种长度为 $n$ 的字符串 $t$ ,恰好由一个长度为 $\frac{n}{x}$ 的字符串循环 $x$ 次得来, 且对于每一个 $i$ 使得 $s_i$ 为 $.$,$t_i$ ......
题解 AT_abc 304 abc AT

「杂题乱写」AGC 001

# 「杂题乱写」AGC 001 点击查看目录 > [TOC] ## [A | BBQ Easy](https://www.luogu.com.cn/problem/AT_agc001_a) 排序奇数项求和,贪心正确性显然。 ## [B | Mysterious Light](https://www. ......
AGC 001

AtCoder Beginner Contest 225 F String Cards

[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc225_f "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc225/tasks/abc225_f "AtCoder 传送门") 这题是真的强。。 ......
Beginner AtCoder Contest String Cards

AtCoder Beginner Contest 225 G X

[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc225_g "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc225/tasks/abc225_g "AtCoder 传送门") 感觉是一种很新的建 ......
Beginner AtCoder Contest 225

AtCoder Beginner Contest 281 Ex Alchemy

[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc281_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc281/tasks/abc281_h "AtCoder 传送门") 考虑设 $f_i$ ......
Beginner AtCoder Alchemy Contest 281

[AGC050F] NAND Tree

求一个计数方案奇偶性的题考虑套路的交换两个元素。考虑最开始选的两条边,如果它们没有交,那么互换顺序之后结果不变。我们只需要统计相交的情况即可。 再考虑边相邻的情况。对于`y x z`,按两种顺序缩边的结果分别为 $\operatorname{NAND}(\operatorname{NAND}(y,x ......
050F NAND Tree AGC 050

DRTREE - Dynamically-Rooted Tree 题解

[DRTREE - Dynamically-Rooted Tree](https://www.luogu.com.cn/problem/SP14943) 本题建议评蓝。 ### 思路: 题目就是要对一颗不定根树求子树权值和。 这题不带修,如果带修难度会增加一点,就跟 [遥远的国度](https:// ......

Meteors 题解

[Meteors](https://www.luogu.com.cn/problem/SP10264) 蒟蒻初学整体二分,写一篇题解记录一下思考与看法。 ### 题目大意 在一个环形的轨道上分别着若干国家的空间站,在接下来的一段时间内会出现若干次陨石,每次出现在环形的某一段轨道,每个国家都想收集一定 ......
题解 Meteors

Full Tank 题解

[Full Tank](https://www.luogu.com.cn/problem/UVA11367) ### 题目大意 给定一张 $n$ 个点,$m$ 条边的连通无向图,在每个点有一个加油站,油价为该点的点权,每条边的油耗为该边的边权。现给出若干询问,问一辆油箱容量为 $c$ 的车子是否能从 ......
题解 Full Tank

Visible Lattice Points 题解

[Visible Lattice Points](https://www.luogu.com.cn/problem/SP7001) ### 题目大意 给定一个 $N×N×N$ 的由若干点组成的立方体,点的坐标从 $(0,0,0)$ 到 $(N,N,N)$,求从点 $(0,0,0)$ 处可以看见多少个 ......
题解 Visible Lattice Points

We Need More Bosses 题解

[We Need More Bosses](https://www.luogu.com.cn/problem/CF1000E) ### 题目大意 给定一张图,找到两个点,使得这两个点之间的所有路径必须经过的边最多。 ### 思路分析 我们先来思考一下如果已知两个点,怎么求两个点之间必须经过的边的数量 ......
题解 Bosses Need More We

Substring of Sorted String 题解

[Substring of Sorted String](https://www.luogu.com.cn/problem/AT_abc285_f) 写篇题解纪念一下蒟蒻第一次赛时切出的 F 题。 ### 题目简述 对一个字符串进行单点修改,区间判断操作。 修改操作为将一个字符修改为另一个,判断操作 ......
题解 Substring Sorted String of

镜面通道 题解

[镜面通道](https://www.luogu.com.cn/problem/P3260) ### 题目大意 在一个二维平面内,给出一个镜面通道和若干个镜面元件,每个元件可能是圆形或矩形。求出为了能够使光从通道左边通过通道到达右边,至少需要拿走的元件个数。 ![](https://i.imgloc ......
题解 镜面 通道

逛森林 题解

[P5344 逛森林](https://www.luogu.com.cn/problem/P5344) ### 题目大意 ~~原题的题目大意已经很明确了要这个干嘛~~ 给定一些孤立点,将要进行两种操作: - 若两点之间不可以通过 $1$ 类边连通,则在两点之间连双向 $1$ 类边 - 若 $u_1, ......
题解 森林

OTOCI 题解

[OTOCI](https://www.luogu.com.cn/problem/SP4155) ### 题目大意 给定 $n$ 个带权的点,需要进行四种操作:查询两点连通性;加边;修改点权;查询两点路径的权值和。 ### 思路分析 首先观察题目,我们会发现,在所有的操作结束后,所有的点构成一个森林 ......
题解 OTOCI

旅游 题解

[旅游](https://www.luogu.com.cn/problem/P3976) ### 题目大意 对一颗树进行两种操作:将一条从 $u$ 到 $v$ 的链上的点的权值增加 $x$;查询从 $u$ 到 $v$ 的链上最大的 $p_i-p_j(dis_{ui} using namespace ......
题解

Sell Pigs 题解

[Sell Pigs](https://www.luogu.com.cn/problem/SP4063) [双倍经验](https://www.luogu.com.cn/problem/P4638) ### 题目大意 有 $n$ 个顾客前来买猪,共有 $m$ 个猪圈,每个顾客携带着某一些猪圈的钥匙, ......
题解 Sell Pigs

Interesting Array 题解

[Interesting Array](https://www.luogu.com.cn/problem/CF482B) ### 题目大意 构造一个序列 $a$,使其满足若干限制条件,每个限制条件是形如 `l r q` 的式子,其意义是:$\&_{i=l}^ra_i=q$。 ### 题意分析 看上去 ......
题解 Interesting Array

Sum of MSLCM 题解

[Sum of MSLCM](https://www.luogu.com.cn/problem/UVA1730) ### 题目大意 定义 $\text{MSLCM}(n)$ 为所有满足该数集的 $\text{lcm}$ 为 $n$ 的数集中元素个数最多的数集的所有数字的和,现有多次询问,求 $$\s ......
题解 MSLCM Sum of

CF338D GCD Table 题解

# CF338D GCD Table 题解 ## 题目描述 你有一个长度为 $k$ 的数列 $a$ , 询问是否存在 $x\in[1,n]~~~y\in[1,m]$ 使得 $\forall i~~~ \gcd(x,y+i-1)=a_i$。 ## 解析 我们转换一下可以得到: $$ \forall i ......
题解 Table 338D 338 GCD

P5445 路灯 题解

[路灯](https://www.luogu.com.cn/problem/P5445) ### 题目大意 在 $n+1$ 个站点之间有 $n$ 盏路灯,给定 $0$ 时刻所有路灯的亮灭情况,在接下来的 $q$ 个时刻,每时刻会发生以下两种事件之一: - 切换某一盏路灯的亮灭。 - 询问两点之间存在 ......
题解 路灯 P5445 5445

P2487 拦截导弹 题解

[拦截导弹](https://www.luogu.com.cn/problem/P2487) ### 题目大意 给定若干元素,每个元素有 $3$ 个属性 $t_i,h_i,v_i$,求出一个使得对于 $\forall i,j,i>j$,$t_i>t_j,h_i\le h_j,v_i\le v_j$ ......
题解 导弹 P2487 2487

P2048 超级钢琴 题解

[超级钢琴](https://www.luogu.com.cn/problem/P2048) ### 题目大意 求出序列中长度在 $[L,R]$ 中的所有区间的区间和前 $k$ 大的区间的区间和。 ### 思路分析 暴力做法是把所有符合条件的区间扔进堆里,再弹出 $k$ 个,时间复杂度 $O((n^ ......
题解 钢琴 P2048 2048

P5012 水の数列 题解

[水の数列](https://www.luogu.com.cn/problem/P5012) ### 题目大意 对于给定的数列 $a$,选择一个数 $x$,定义其得分为数列中所有小于等于 $x$ 的数形成的若干个连续区间的平方和除以 $x$ 所得到的数。 现进行多次询问,每次询问给定两个数 $l,r ......
数列 题解 P5012 5012

[ABC208E] Digit Products 题解

[Digit Products](https://www.luogu.com.cn/problem/AT_abc208_e) ### 题目大意 求有多少个不大于 $n$ 的正整数,使得该正整数各位乘积不大于 $k$。 ### 思路分析 观察数据范围,首先考虑数位 DP。 考虑设计记忆化搜索函数 `d ......
题解 Products Digit 208E ABC

[ABC207E] Mod i 题解

[Mod i](https://www.luogu.com.cn/problem/AT_abc207_e) ### 题目大意 给定一个序列 $a$,问将其划分成若干段,满足第 $i$ 段的和是 $i$ 的倍数的划分方案的个数。 ### 思路分析 考虑 DP,设 $f_{i,j}$ 表示将序列中前 $ ......
题解 207E ABC 207 Mod

[ABC202E] Count Descendants 题解

[Count Descendants](https://www.luogu.com.cn/problem/AT_abc202_e) ### 题目大意 给定一颗以 $1$ 为根的树,多次询问求某点的子树中深度为给定值的点的个数。 ### 思路分析 对于每个深度开一个 `vector`,从大到小存下这个 ......
题解 Descendants Count 202E ABC