模板
BranZhai
这个作者很懒,什么都没留下…
展开
-
HDU 2586 LCA模板
好题题解题意倍增法题意这个是一个LCA裸题,题意不难理解倍增法下面来一个讲解LCA非常棒的博客:Author by Morslin然后根据我自己的风格,写出本题的代码#include <bits/stdc++.h>using namespace std;const int MAXV = 4e5 + 5;struct Edge { int to; int nxt;}g[MAXV << 1];int head[MAXV], tol;原创 2020-08-26 10:34:35 · 92 阅读 · 0 评论 -
POJ1330 dfs + ST模板 LCA
https://vjudge.net/problem/POJ-1330#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXV = 10005;int rmq[MAXV << 1];int n;struct ST { int lg[MAXV << 1]; int dp[MAXV原创 2020-08-30 12:19:55 · 98 阅读 · 0 评论 -
LCA Tarjan 模板 洛谷 P3379
https://www.luogu.com.cn/problem/P3379#include <bits/stdc++.h>using namespace std;const int MAXV = 5e5 + 5;int F[MAXV];bool vis[MAXV];int ans[MAXV];struct Edge { int to, nxt;}edge[MAXV << 1];int tol1;int he[MAXV];void ad原创 2020-08-28 23:07:31 · 106 阅读 · 0 评论 -
HDU 1711 KMP 模板题
https://vjudge.net/problem/HDU-1711#include <bits/stdc++.h>using namespace std;const int MAXN = 1e6 + 5, MAXM = 1e4 + 5;int n, m;int a[MAXN], b[MAXM];int nxt[MAXM];void preKMP() { int i, j; j = nxt[0] = -1; i = 0;原创 2020-08-28 18:52:19 · 106 阅读 · 0 评论 -
POJ 1330 LCA 倍增法 bfs模板
https://vjudge.net/problem/POJ-1330#include <cstdio>#include<cstring>#include <queue>using namespace std;const int MAXV = 10005;const int DEG = 20;struct Edge { int to, nxt;}edge[MAXV << 1];int head[MAXV], tol;int原创 2020-08-26 15:11:40 · 138 阅读 · 0 评论 -
P3379 【模板】最近公共祖先(LCA) 倍增法 dfs模板
https://www.luogu.com.cn/problem/P3379#include <bits/stdc++.h>using namespace std;const int MAXV = 5e5 + 5;struct Edge { int to; int nxt;}g[MAXV << 1];int head[MAXV], tol;int depth[MAXV], fa[MAXV][20], lg[MAXV];void adde原创 2020-08-26 11:50:27 · 137 阅读 · 0 评论