随笔分类 - 题解
摘要:#include<cstdio> #include<algorithm> const int N = 1e6 + 1; int n, t[N]; namespace lsh{ int lsh[N], tmp[N]; void init() { for (int i = 1; i <= n; ++i)
阅读全文
摘要:**link:**http://poj.org/problem?id=2976 description: There are n courses, $a_i$is your grade, while the full marks is \(b_i\). The GPA calculate metho
阅读全文
摘要:description: Color some of the cells of the \(n*n\) square's edge black, check if there exists an solution of given black cells of each edge. solution
阅读全文
摘要:description: There are \(3\) buckets, whose volume are \(a,b,c\) respectly. How can you get \(k\) \(L\) oil by the three buckets? (Initially, the firs
阅读全文
摘要:description: 9宫格, 其中有一个空位(0), 每次操作可以将一个与空位临接的数与空位交换, 问最少需要多少次达到目标123804765(实际上是12345678顺序围了一圈中间放0~)(像不像21世纪10年代手机里的拼图小游戏?) solution: 先手打一个临接表存储可能的状态转移
阅读全文
摘要:description: There are two strings \(a\), \(b\) with the length \(n\), and \(m\). Find the Array <\(p_1, p_2, ..., p_m>\), such that \(a_{p_i}= b_i\),
阅读全文
摘要:Link:https://codeforces.com/problemset/problem/1492/B description: You are given a deck of cards, numbered from \(1\) to \(n\). For each time you can
阅读全文
摘要:description: Two strings \(a,b\) are nonempty strings.We can replace a char, delete a char or add a char, so how many edition are needed to make the t
阅读全文
摘要:Link:https://codeforces.com/problemset/problem/1487/E description: \(4\) kinds of dishes, each has \(n_i\) courses for \(i\in \{1,2,3,4\}\), we have t
阅读全文
摘要:description: How many pairs \(<a,b>\), s.t. \(a\mod b=\lfloor\frac{a}{b}\rfloor\), for \(1\leqslant a\leqslant x\), $1\leqslant b\leqslant y $ ? solut
阅读全文
摘要:Link:https://codeforces.com/problemset/problem/1490/E description: There are \(n\) players, every player has a power value. Every round, two players a
阅读全文
摘要:Link:https://www.luogu.com.cn/problem/P3368 description: 实现一个支持动态区间修改(区间内的每个数增加常量), 和单点查询的数据结构. solution: Consider the difference, let \(a[0] = 0\), \
阅读全文
摘要:Link:https://codeforces.com/problemset/problem/1487/D description: Find the numbers of triples$(a,b,c)$s.t.$a2+b2=c^2$and \(a^2=b+c\), where 1≤a≤b≤c≤n
阅读全文
摘要:Link: https://codeforces.com/problemset/problem/1487/B description: Cat A sleep from \(n\) downto 1 per hour, while cat B sleep from 1 to n per hour i
阅读全文
摘要:description: 长$L$米,宽$W$米的草坪里装有$n$个浇灌喷头。每个喷头都装在草坪中心线上(离两边各$\frac{2}$米)。我们知道每个喷头的位置(离草坪中心线左端的距离),以及它能覆盖到的浇灌范围。 请问:如果要同时浇灌整块草坪,最少需要打开多少个喷头? solution: 先预处
阅读全文
摘要:description: 某条街被划为$n$条路段,这$n$条路段依次编号为$1$~\(n\) 。每个路段最多可以种一棵树。现在居民们给出了$h$组建议,每组建议包含三个整数$b,e,t$ ,表示居民希望在路段$b到e$之间至少要种t棵树。这些建议所给路段的区间可以交叉。请问:如果要满足所有居民的建
阅读全文
摘要:discription: 给定$n$项工作的起止时间, 每个工人同一时间最多干一件工作. 问做完这些工作最少要雇佣多少工人?(万恶的资本家) \(第一行一个整数 n,(1≤n≤100000),表示工作的数目.\) \(接下来 n 行, 第 i+1 行有俩整数 S_i, E_i, (0≤Si<Ei≤1
阅读全文
摘要:链接:https://leetcode-cn.com/problems/minimum-number-of-arrows-to-burst-balloons discription: 在二维空间中有许多球形的气球。对于每个气球,提供的输入是水平方向上,气球直径的开始和结束坐标。由于它是水平的,所以纵
阅读全文
摘要:链接:https://leetcode-cn.com/problems/kth-largest-element-in-an-array/ discription: 在未排序的数组中找到第 k 个最大的元素。 solution: 用随机化快排partition, 由于每次查询区间减半, 等比递缩和是2
阅读全文
摘要:discription: 判断一个图是否为欧拉图(图本身是欧拉闭迹) 欧拉闭迹的定义:含有图中每一条边的闭合迹(trail). 迹(trail)的定义:一条没有重复边的途径(walk) 途径(walk)的定义:形如{\(x_0,x_1\)},{\(x_1,x_2\)},{\(x_2,x_3\)},.
阅读全文