![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论模板
文章平均质量分 69
_Ark
这个作者很懒,什么都没留下…
展开
-
堆优化/zkw线段树优化 dijkstra
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int MAXM = 200005; inline void read(int &num) { char ch; int flag=1; while(!isdigit(ch=getchar()))if(ch=...原创 2018-10-29 22:36:56 · 633 阅读 · 0 评论 -
A* 第k短路
#include <cstdio> #include <algorithm> #include <queue> #include <cstring> #include <cctype> using namespace std; void read(int &num) { char ch; while(!isdig...原创 2018-11-05 19:37:55 · 134 阅读 · 0 评论 -
无向图边双联通分量 tarjan 模板
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int MAXM = 500005; int n, m; int fir[MAXN], nxt[MAXM<<1], to[MAXM<<1], cnt = 1; int low[MAXN], dfn[MAX...原创 2018-11-04 20:36:38 · 230 阅读 · 0 评论 -
匈牙利算法 最大匹配 模板
#include <bits/stdc++.h> using namespace std; const int MAXN = 1005; int n, m, e; int match[MAXN]; bool g[MAXN][MAXN], vis[MAXN]; bool dfs(int u) { for(int v = 1; v <= m; v++) ...原创 2018-11-02 21:58:57 · 267 阅读 · 0 评论 -
KM模板 最大权匹配(广搜版) Luogu P1559 运动员最佳匹配问题
KM板题: #include <bits/stdc++.h> using namespace std; inline void read(int &num) { char ch; num = 0; int flag = 1; while((ch=getchar()) < '0' || ch > '9')if(ch == '-') flag = -flag;...原创 2018-11-09 21:58:58 · 225 阅读 · 0 评论 -
树的点分治 板题 Luogu P3806
给定一棵有n个点的树 询问树上距离为k的点对是否存在。 AC code: #include<bits/stdc++.h> using namespace std; const int MAXN = 10005; const int MAXM = 105; const int MAXK = 10000005; int n, m, q[MAXM]; int fir[MAXN], t...原创 2018-11-06 18:50:51 · 189 阅读 · 0 评论 -
无向图的割点和桥 tarjan 模板
#include <bits/stdc++.h> using namespace std; const int MAXN = 20005; const int MAXM = 100005; int n, m, fir[MAXN], nxt[MAXM<<1], to[MAXM<<1], cnt=1; int dfn[MAXN], low[MAXN], tot;...原创 2018-10-30 22:16:35 · 245 阅读 · 0 评论 -
二叉树遍历 递归/非递归 模板(??)
递归版 void First_order_traversal(int i) //先序 { printf("%d\n", key[i]); First_order_traversal(lc[i]); First_order_traversal(rc[i]); } void Sequential_traversal(int i) //中序 { Sequential_traversal(lc[i...原创 2018-10-30 21:37:36 · 415 阅读 · 0 评论 -
堆优化Prim 最小生成树 模板
#include <bits/stdc++.h> using namespace std; const int MAXN = 5005; const int MAXM = 200005; int n, m, fir[MAXN], to[MAXM*2], nxt[MAXM*2], w[MAXM*2], cnt, dis[MAXN]; bool vis[MAXN]; #define pii...原创 2018-10-30 20:55:26 · 430 阅读 · 0 评论 -
Codeforces Round #554 (Div. 2) E Neko and Flashback (欧拉路径 邻接表实现(当前弧优化..))
就是一欧拉路径 贴出邻接表欧拉路径 CODE #include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, b[MAXN], c[MAXN], bin[MAXN<<1], tot; int val[MAXN], deg[MAXN], stk[MAXN<<1], top;...原创 2019-04-29 16:44:14 · 188 阅读 · 0 评论