Author: michaele

梅深不见冬 题解

题面 原题:P5521 [yLOI2019] 梅深不见冬 样例: 6 1 1 2 3 4 3 14 1 5 12 15 输出: 21 20 13 20 12 15 题解 这个题类似于国王游戏,要考虑每个节点的贡献。 对于一个节点 x,设ans_x表示要在x节点上放梅花至少需要准备ans_x朵梅花

michaele michaele Published on 2025-05-11

18 ABC405 A ~ E 题解

A、B 略 A code #include <iostream> #include <algorithm> #include <cstring> #include <cstdlib> #include <cstdio> using namespace std; const int N = 1e5

michaele michaele Published on 2025-05-11

高精度模板

这是我 因为一个小错调了一中午 苦苦钻研凝结出的精华,请放心食用 本博客涉及高精度加、减、乘、除、取余 定义&初始化 定义 struct bn { ll num[N] = {0}; int len = 1, fu = 0; void init_num (ll x); void init_s

michaele michaele Published on 2025-05-10

16 ABC404 A ~ E 题解

A 题面 给你一个长度介于 1\sim25 之间的字符串 S ,它由小写英文字母组成。 请输出一个没有出现在 S 中的小写英文字母。如果有多个,输出其中任意一个即可。 题解 直接用一个 vis[] 记录每个字母是否出现过即可 code #include <iostream> #include <al

michaele michaele Published on 2025-05-07

2025 04 30 模拟赛题解

T1 传送门 题面 有 n 个城市,编号为 0\sim n - 1 ,小乐要去旅行,从 0 城市出发,终点为 n-1 节点,编号越大的城市距离 n-1 城市越近,每个城市有 h 条到达其他城市的路 (i, j,k) ,表示有一条从 i\to j\,

michaele michaele Published on 2025-04-30

13 ABC252G Pre-Order 题解

题面 传送门 描述 有一棵n个节点的有根树,从根开始执行深度优先遍历,每次选择未遍历过的节点编号P_{i}最小的子节点继续向下遍历,给出先序遍历(DFS序),求共有多少不同的树满足这个先序遍历? 两棵有根树(根节点为1)被视为不同,当且仅当两棵树中存在编号相同但父节点不同的节点 约束 2 \leq

michaele michaele Published on 2025-04-29

模拟赛T4 题解

思路 这题赛时想到了用质因数来求每个子树的因数个数,但是没时间写了,而且也没有那么熟悉STL,所以最后只拿了a_{i}\leq 3的10pts 下面说下思路,题解写的太恶心,所以我结合自己的思路,再捋一遍 首先我们要预处理出每个数分解质因数以后的结果,也就是每个数分别有哪些质因数、以及每个质因数的指

michaele michaele Published on 2025-04-26

模拟赛T2 hack

hack1 3 0 -1 -1 hack2 2 0 -1 hack3 5 0 -1 -1 -6 7 hack4 5 0 1 1 -6 7 hack5 3 1 1 1 hack6 3 -1 -1 -1

michaele michaele Published on 2025-04-26

6 软件安装 题解

update\ on\ 2025.4.30 代码中有一处错误,修正一下,要将f数组的初值赋为极大值,否则可能会导致结果错误 软件安装 题解 题面 传送门 N个物品,背包体积为V,每个物品有价值v_{i}以及体积w_{i},每个物品至多有一个依赖物品(选每个物品前必须先选它的依赖物品)d_{i}

michaele michaele Published on 2025-04-25

5 Bone Collector II 题解

题面 传送门 N个物品,背包容量为V,每个物品有相应的体积w和价值v。求严格第k优解(背包容量为V的情况下,价值第k多的方案) N\leq 100 ,\,V\leq 1000,\,k\leq 30 题解

michaele michaele Published on 2025-04-25