随笔分类 - 数据结构与算法
摘要:1. DP问题 1.1 DP问题的时间复杂度计算的一般公式 \(时间复杂度=状态数量 * 状态转移需要的计算量\) 2.2 注意事项 状态表示一定能够让答案能够推出来,在此基础上,状态表示的维数要越小越好,状态表示每高一维,计算的时间复杂度就会高一维。因此,状态表示一般从一维开始考虑,如果一维不能表
阅读全文
摘要:卡码网_97.小明逛公园 对于floyd算法的写法有几个注意点: 对边松弛的中间点的循环要放在三个for循环的最外层 使用邻接矩阵存图时,每个点自己到自己的距离要初始化为0,即对角线的位置要初始化为0,其他点没有边直接相连时,要初始化为inf(inf依照题目定),如果初始化INT_MAX,在判断是否
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; const int N = 1000; struct { int to; int w; int next; }edge[N]; int head[N]; void add_edge(in
阅读全文
摘要:package lanqiao; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.
阅读全文
摘要:package daweiguo.other; import java.util.Arrays; /** * @Author DaWeiGuo * @Date 2022/3/21 16:16 * @Desc: 差分数组 */ public class DifferenceArray { public
阅读全文
摘要:package daweiguo.other; /** * @Author DaWeiGuo * @Date 2022/3/19 21:04 * @Desc: */ public class HeapSort { public static void main(String[] args) { He
阅读全文
摘要:void quickSort(int left,int right){ int mid = a[left]; int i = left; int j = right; // int t; while(i<j){ while(a[j]>mid && i<j) j--; if(i<j){ a[i] =
阅读全文
摘要:#include<iostream> #include<cstdio> using namespace std; void buildTree(int array[],int arrayTree[],int node,int start,int end){ if(start==end) arrayT
阅读全文
摘要:#include<iostream> using namespace std; void makePrefixTable(string pattern,int prefix[],int size){ //我们都是生活在阴沟里的人,但仍有人仰望星空。 //永远相信美好的事情明天即将发生。 prefix
阅读全文
摘要:typedef struct item{ int to; int next; int w; }Item; Item E[MAXN]; void addEdge(int u,int v,int w){ E[cnt].to = v; E[cnt].w = w; E[cnt].next = head[u]
阅读全文
摘要:落谷p1226 理论依据 #include<iostream> #include<cstdio> using namespace std; long long fun(long long a,long long b,long long c){ long long An = 1; long long
阅读全文
摘要:落谷题目p1993 #include<iostream> #include<cstdio> using namespace std; typedef struct item { /* data */ int u; int v; int w; }Item; Item a[5000+5]; int n,
阅读全文

浙公网安备 33010602011771号