邻接表模板
// 邻接表模板
// 头节点,next指针,节点值,结点总数
int h[N], nxt[N],to[N], tot;
void add(int a, int b){
to[++tot]=b, nxt[tot]=h[a], h[a]=tot; // 先保存节点值 => 头插法 插入链表
}
// 邻接表模板
// 头节点,next指针,节点值,结点总数
int h[N], nxt[N],to[N], tot;
void add(int a, int b){
to[++tot]=b, nxt[tot]=h[a], h[a]=tot; // 先保存节点值 => 头插法 插入链表
}