/* 链式前向星简单易懂,比vector快 */ int head[maxn];//初始化为-1 struct Edge{ int v,w,next; }edge[maxn<<2]; void addEdge(int u,int v,int w){ edge[cnt].v=v; edge[cnt].w=w; edge[cnt].next=head[u]; head[u]=cnt++; }