建边

· · 个人记录

变量

函数

代码

int head[N],ver[N<<1],edge[N<<1],nxt[N<<1],tot;
void add(int x,int y,int z){
    ver[++tot]=y,edge[tot]=z,nxt[tot]=head[x],head[x]=tot;
}

高级版本

template<const int N,const int M>
struct Graph{
    int head[N],ver[M],edge[M],nxt[M],tot;
    void add(int x,int y,int z){
        ver[++tot]=y,edge[tot]=z,nxt[tot]=head[x],head[x]=tot;
    }
};
Graph<N,N<<1> G;