codlz
codlz
全部文章
不抄模板能解题?
后端开发实践(2)
未归档(21)
题解(1)
归档
标签
去牛客网
登录
/
注册
这都不会?
全部文章
/ 不抄模板能解题?
(共12篇)
tarjan 强连通分量 缩点 入度出度 模板
洛谷-校园网 #include <bits/stdc++.h> using namespace std; const int N = 105; const int M = 10000; struct { int to, next; } edges[M]; int n; i...
2021-05-20
0
450
区间dp模板 石子归并
设有N堆沙子排成一排,其编号为1,2,3,…,N(N<=100)。每堆沙子有一定的数量。现要将N堆沙子并成为一堆。归并的过程只能每次将相邻的两堆沙子堆成一堆,这样经过N-1次归并后成为一堆。找出一种合理的归并方法,使总的代价最小。归并的代价是归并后堆的数量。 #include <bit...
2021-05-10
0
530
树的重心 性质和模板
以树的重心为根时,所有子树的大小都不超过整棵树大小的一半。 树中所有点到某个点的距离和中,到重心的距离和是最小的;如果有两个重心,那么到它们的距离和一样。 把两棵树通过一条边相连得到一棵新的树,那么新的树的重心在连接原来两棵树的重心的路径上。 在一棵树上添加或删除一个叶子,那么它的重心最...
2021-05-09
0
390
一套常见的背包问题的应用
https://leetcode-cn.com/problems/target-sum/solution/yi-tao-kuang-jia-jie-jue-bei-bao-wen-ti-58wvk/ 一、目标和 0-1背包的一种变形,原来适用于求最大值,这道题用于求组合数 /* ...
2021-05-08
0
485
分组背包问题模板
https://blog.csdn.net/yu121380/article/details/81387879 for 所有的组k for v=V..0 for 所有的i属于组k f[v]=max{f[v],f[v-c[i]]+w[i]}
2021-05-07
0
422
欧拉筛 线性筛法 模板
int prime[maxn]; int visit[maxn]; void Prime(){ mem(visit,0); //若为1,则不是素数 mem(prime, 0); //将已经搜索到的素数保存下来 int cnt = 0; //当前有多少个素数 ...
2021-05-06
0
345
Dijkstra 链式前向星 堆优化 模板
#include <bits/stdc++.h> using namespace std; using ll = long long; using p = pair<ll, int>; const int maxn = 2e5 + 10; int cnt = -1; int...
2021-05-06
0
571
最朴素的线段树 模板
#include<cstring> #include<cstdio> #include<algorithm> #include<iostream> using namespace std; const int N = 2e5 + 10; using ...
2021-05-06
0
446
Tire 模板 高效存储和查找字符串
ACWING 835. Trie字符串统计 #include <bits/stdc++.h> using namespace std; const int N = 100005; int idx; //每个节点的唯一标识 int son[N][26], cnt[N]; ...
2021-05-06
0
510
Bellman-ford 有边数限制的最短路 模板
给定一个n个点m条边的有向图,图中可能存在重边和自环, 边权可能为负数。 请你求出从1号点到n号点的最多经过k条边的最短距离,如果无法从1号点走到n号点,输出impossible。 注意:图中可能 存在负权回路 。 #include <bits/stdc++.h> using ...
2021-05-06
0
485
首页
上一页
1
2
下一页
末页