04 2020 档案
摘要:include include include include include using namespace std; const int N=560100; int ver[N],head[N],ed[N],net[N],tot; int n,m,p; int fa[N],d[N],v[N],l
阅读全文
摘要:一般ACM或者笔试题的时间限制是1秒或2秒。 在这种情况下,C++代码中的操作次数控制在 107107 为最佳。 下面给出在不同数据范围下,代码的时间复杂度和算法该如何选择: n≤30, 指数级别, dfs+剪枝,状态压缩dp n≤100 = O(n3),floyd,dp n≤1000 = O(n2
阅读全文
摘要:dp include include include include using namespace std; const int N=1000100; int head[N],net[N],ans,ed[N],ver[N],tot,d[N]; bool v[N]={false}; void add
阅读全文
摘要:void get_primes(int n) { for(int i=2;i1)//到最后的时候 再加进去一个 prime[m++]=n,c[m]=1; for(int i=1;i<=m;i++)//输出 printf("%d %d\n",prime[i],c[i]);
阅读全文
摘要:const int N=10010; int prime[N]; bool v[N]; void get_primes(int n) { memset(v,0,sizeof(v)); m=0; for(int i=2;i<n;i++)//循环遍历2~n的质数 { if(!v[i]){v[i]=i,p
阅读全文
摘要:#kruskal最小生成树算法0(mlogn) 适合边稀疏的图 #include #include #include<stdio.h> #include using namespace std; const int N=600000; int fa[N],n,m,ans; struct rec{ i
阅读全文
摘要:拓扑排序 https://www.acwing.com/problem/content/850/ include include include include include using namespace std; const int N=1e5+10; int ver[N],head[N],n
阅读全文
摘要:模板题 快速幂求矩阵的幂 https://www.luogu.com.cn/problem/P3390 include include include using namespace std; const int N = 110; long long n, k; const int mod = 10
阅读全文
摘要:记录简单路径 并且求出路径权值的积 "原题链接" 下面附上模板 include include include include using namespace std; const int M=100010,N=100100; int d[N],Next[N],edge[M],head[N],tot
阅读全文
摘要:spfa算法 o(nm) 适用的地方 权值可以为负的时候,也是单源最短路径的一个算法 include include include include include using namespace std; const int N=100100,M=1000010; queueq; int d[N]
阅读全文
摘要:求单源最短路径 迪杰斯特拉算法 O(n n) inlcude include Include include using namespace std; int a[1000][1000],d[1000],n,m; bool v[1000]; void dijkstra() { memset(d,0f
阅读全文
摘要:求有权无向图两点之间的最长距离 这是根据蓝桥杯大臣的旅费一题 看一位大佬写的 https://blog.dotcpp.com/a/7027 这个是链接 include include include include include using namespace std; int cnt,node,
阅读全文
浙公网安备 33010602011771号