跳到正文

个人记录

【模板】图

yzc2005约 1 分钟
原文
文章信息与版本

文章信息

发布
2020年3月3日
收录
2026年4月25日
更新
2026年11月15日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#define go(G, u) for(int i = G.head[u], v = G.to[i]; i; i = G.nxt[i], v = G.to[i])
struct Graph {
    int to[M], nxt[M], head[N], cnt;
    inline void add(int u, int v) {
        to[++cnt] = v;
        nxt[cnt] = head[u];
        head[u] = cnt;
    }
    inline void init() {
    	  fu(i, 1, n) head[i] = 0;
          cnt = 0;
    }
} G;
原文