【注意】邻接表
(1)图论题双向边一般开两倍(有关边的数组);
(2)以图论为例的写法:
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。void add(int x,int y,int len)
{
nxt[++tot]=fst[x];
fst[x]=tot;//tot是指针,不能写成nxt[tot]
w[tot]=len;
to[tot]=y;
//双向边要多写这一行以下的
nxt[++tot]=fst[y];
fst[y]=tot;
w[tot]=len;
to[tot]=x;
}

更多精彩