lca模板 1.树上倍增 #include <queue> #include <cstdio> using namespace std; const int MAXN = 1e5 + 5; const int MAXTEP = 45; int n, m; int depth[MAXN], f[MAXN][MAXTEP]; int len, head[MAXN]; struct edge { int to, next; }e[MAXN * 2]; void add (int, int); void...
接下来M行每行包含两个正整数a、b,表示询问a结点和b结点的最近公共祖先。 输出格式: 输出包含M行,每行包含一个正整数,依次为每一个询问的结果。 输入样例#1: 5 5 4 3 1 2 4 5 1 1 4 2 4 3 2 3 5 1 2 4 5 输出样例#1: 4 4 1 4 4 模板:时间复杂度nlogn #include<iostream>#include<cs...
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn=500007,ln=20; struct E { int to,next; }e[maxn*2]; int p[maxn][ln+1],d[maxn],list[maxn],cnt=1,n,q,u; void add(int u,int v) { e[++cnt].to=v; e[cnt].next=list[u]; list[...
1#include <cstring>2#include <cstdio>3#include <cstdlib>4#include <algorithm>5#include <cmath>6#include <vector>7usingnamespacestd;8constintN=10000+5;9vector <int>son[N];10intT,n,depth[N],fa[N][20],in[N],a,b;11voiddfs(intprev,intrt){12depth[rt]=depth[prev]+1;13fa[rt][...
[idx]=c,h[a]=idx++;}voiddfs(introot){memset(depth,0x3f,sizeofdepth);depth[root]=1;depth[0]=0;queue<int>q;q.push(root);while(q.size()){autot=q.front();q.pop();for(inti=h[t];i!=-1;i=ne[i]){intj=e[i];if(depth[j]>depth[t]+1){depth[j]=depth[t]+1;fa[j][...
模板:时间复杂度nlogn 代码语言:javascript 代码运行次数:0 运行 AI代码解释 #include<iostream>#include<cstdio>using namespace std;struct yyy{int t,nex;}e[2*500001];int deepth[500001],fa[500001][22],lg[500001],head[500001];int tot;voidadd(int x,int y)//邻接表存树{e[++tot].t=y;e[...
60 } 61 void read(int & x) 62 { 63 char c=getchar();x=0; 64 while(c<'0'||c>'9')c=getchar(); 65 while(c>='0'&&c<='9')x=x*10+c-48,c=getchar();// 读入优化,必须要有! 66 } 67 int main() 68 { 69 //scanf("%d%d%d",&n,&m,&root); 70 read(n);read(...
铅酸电池全生命周期评价报告模板(LCA报告)绿色设计产品 生命周期评价报告(报告编号:XXXXXXXX)产品名称:铅酸电池 软件工具:eFootprint软件系统编制:XXX 审核:XXX 批准:XXX XXX有限公司 XXXX年X月X日
一种面向中小企业的LCA软件开发思想及开发实践
lca 倍增模板 1#include<cstdio>2#include<iostream>3usingnamespacestd;4constintmaxn=1e5+10;5intn,m,s,num=0,head[maxn],dep[maxn],f[maxn][23];6inta1,a2;7structedg{8intnext,to;9}G[maxn];10voidedge_add(intu,intv)//链式前向星存图11{12num++;13G[num].next=head[u];G[num]....