09 2020 档案
摘要:DAG(有向无环图)才有拓扑序列(有向无环图中的所有的路线必须都是单向的) 拓扑序列指,若一个由图中所有点构成的序列A满足:对于图中的每条边(x, y),x在A中都出现在y之前,则称A是该图的一个拓扑序列。 acwing—奖金(拓扑排序) #include<iostream> #include<cs
        阅读全文
                
摘要:###stringstream的头文件是《sstream》,stringstream可以作为中间介质,实现字符串和数字之间的转换。 数字转string double a=213; string s; stringstream ss; //注意stringstream ss(a)是错误的,因为a是数字
        阅读全文
                
摘要:AcWing 852. spfa判断负环 #include <cstring> #include <iostream> #include <algorithm> #include <queue> using namespace std; const int N = 2010, M = 10010; 
        阅读全文
                
摘要:acwing851—spfa求最短路 #include<iostream> #include<cstring> #include<algorithm> #include<queue> using namespace std; const int N=1e5+10; int n,m; int idx,
        阅读全文
                
摘要:int pre[N];//pre[x]=y表示节点x的前驱节点时y void print_path(int a,int b)//打印从节点a到节点b的路径 { if(a==b){printf("%d",s),return ;} printf_path(a,pre[b]) printf("%d",b)
        阅读全文
                
摘要:#include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N=510,M=1e4+10; int n,m,k,dis[N],backup[N]; //dis数组表示dis[i]到起点
        阅读全文
                
摘要:###1.dijkstra 时间复杂度:O(n^2) n次迭代,每次找到距离集合S最短的点 每次迭代要用找到的点t来更新其他点到S的最短距离。 #include<iostream> #include<algorithm> #include<cstring> using namespace std; 
        阅读全文
                
摘要:###1.y氏写法 链式前向星注意事项,如果a->b,b->c在前向星中a的临点只有b,所以在求连通块的数量的时候不能一次dfs,要多次dfs! const int N=?,M=??;//N是点数,M是边数 int h[N],e[M],ne[M],idx; void add(int a,int b,
        阅读全文
                
摘要:acwing836—合并集合 #include<iostream> #include<cstdio> using namespace std; const int N=1e5+10; int n,m; int p[N]; int find(int x)//返回x的祖宗节点 { if(x!=p[x])
        阅读全文
                
摘要:ll f(ll q,ll n)//递归求快速幂 { if(n==1)return q; if(n&1) return q*f(q,n-1); else return f(q,n/2)*f(q,n/2); } #include<bits/stdc++.h> using namespace std; t
        阅读全文
                
摘要:###Dilworth定理 导弹拦截系统](https://www.acwing.com/problem/content/1012/) 这个定理和一个对偶定理,讲的意思大概就是,给一个偏序关系,比如说是一个数它出现的位置i在另一个数出现的位置j之前,而且满足ai>aj.那么满足这个偏序关系的链就叫做
        阅读全文
                
摘要:###1. #ifdef 标识符 代码段1 #else 代码段2(可以为空) #endif (条件编译结束语句,和#ifdef配套使用) 如果标识符被#define过,则编译代码段1,否则编译代码段2 ###2. #ifndef 标识符 代码段1 #else 代码段2(可以为空) #endif (条
        阅读全文
                

 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号