摘要:
主定理 主定理适用于求解如下递归式算法的时间复杂度: \[T(n)=aT({n\over b}) + f(n) \]其中: \(n\) 是问题规模大小; \(a\) 是原问题的子问题个数; \({n\over b}\) 是每个子问题的大小,这里假设每个子问题有相同的规模大小; \(f(n)\) 是将 阅读全文
posted @ 2024-04-13 14:37
飞花阁
阅读(38)
评论(0)
推荐(0)
摘要:
点分治 模板题引入:点分治1 题目描述 给定一棵有 \(n\) 个点的树,询问树上距离为 \(k\) 的点对是否存在。 输入格式 第一行两个数 \(n,m\)。 第 \(2\) 到第 \(n\) 行,每行三个整数 \(u, v, w\),代表树上存在一条连接 \(u\) 和 \(v\) 边权为 \( 阅读全文
posted @ 2024-04-13 14:34
飞花阁
阅读(22)
评论(0)
推荐(0)
摘要:
区间最大和 描述 给你一个长度为 \(n\) 的数列,请求出其中一段连续的数之和,最大是多少? 样例输入 8 7 -4 2 5 -20 3 -9 2 样例输出 10 区间问题,通常涉及到区间的左右端点,我们只需枚举右端点即可。 思路1 利用前缀和的原理,\(s[i]\) 表示以 \(i\) 作为右端 阅读全文
posted @ 2024-04-13 14:31
飞花阁
阅读(43)
评论(0)
推荐(0)
摘要:
sort C++ 中,我们可以使用头文件 <algorithm> 中的 sort 函数对数组进行排序。 #include <cstdio> #include <algorithm> const int N = 1007; int a[N]; int main() { int n; scanf("%d 阅读全文
posted @ 2024-04-13 14:21
飞花阁
阅读(328)
评论(0)
推荐(0)
摘要:
扫描线 #include <iostream> #include <algorithm> using namespace std; const int N = 2e5 + 7; struct Line { int x, yl, yr, state; bool operator<(Line &B) { 阅读全文
posted @ 2024-04-13 14:20
飞花阁
阅读(14)
评论(0)
推荐(0)

浙公网安备 33010602011771号