Chri_K

11 2020 档案

拓扑排序
摘要:#include <iostream> #include <vector> #include <cstring> using namespace std; const int N=1e5+5; int h[N], e[N], ne[N], indegree[N], idx; int head, ta 阅读全文

posted @ 2020-11-06 10:59 Chri_K 阅读(91) 评论(0) 推荐(0)

kruskal(最小生成树)
摘要:#include<iostream> #include<cstring> #include<algorithm> using namespace std; const int N = 100010, M = 200010, INF = 0x3f3f3f3f; int n, m; int p[N]; 阅读全文

posted @ 2020-11-06 10:55 Chri_K 阅读(84) 评论(0) 推荐(0)

进制转换
摘要:m进制转十进制 #include<cstdio> #include<iostream> #include<cstdlib> #include<cstring> char a[10000]; using namespace std; int main() { int n,m; int f=0; sca 阅读全文

posted @ 2020-11-05 16:33 Chri_K 阅读(89) 评论(0) 推荐(0)

dijkstra
摘要:#include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N=510; int g[N][N]; //为稠密阵所以用邻接矩阵存储 int dist[N]; //用于记录每一个点距离第 阅读全文

posted @ 2020-11-05 15:43 Chri_K 阅读(74) 评论(0) 推荐(0)

优先队列
摘要://对于基础类型 默认是大顶堆 (降序)priority_queue<int> a;//升序队列 priority_queue <int,vector<int>,greater<int> > q; //降序队列 priority_queue <int,vector<int>,less<int> >q 阅读全文

posted @ 2020-11-02 19:08 Chri_K 阅读(61) 评论(0) 推荐(0)

判断是否有环(有向图)
摘要:int dfs(int v){ vis[v] = -1; for(int i = 1; i <= n; i++) { if(a[v][i] != 0 && !vis[i]) { dfs(i); vis[i]=1; } if(a[v][i] != 0 && vis[i] == -1){ printf( 阅读全文

posted @ 2020-11-02 19:02 Chri_K 阅读(99) 评论(0) 推荐(0)

P2341 [USACO03FALL][HAOI2006]受欢迎的牛 (tarjan缩点,拓扑)
摘要:#include<iostream> #include<cstring> using namespace std; const int maxn=50010; int head[maxn],cnt; int dfn[maxn],low[maxn],tot,stack[maxn],idx,visit[ 阅读全文

posted @ 2020-11-02 18:57 Chri_K 阅读(69) 评论(0) 推荐(0)

链式前向星
摘要:#include<bits/stdc++.h> using namespace std; const int maxn = 1005;//点数最大值 int n, m, cnt;//n个点,m条边 struct Edge { int to, w, next;//终点,边权,同起点的上一条边的编号 } 阅读全文

posted @ 2020-11-02 08:49 Chri_K 阅读(72) 评论(0) 推荐(0)