图的储存
const int maxn = 1e5+10;
struct edge {
int to;
int nxt;
};
edge e[maxn * 2];//无向图开双向边
int h[maxn],tot = 1;
void addeage(int x, int y) {
e[++tot].to = y;
e[tot].nxt = h[x];
h[x] = tot;
}
void solve(int i) {
//……
for (int x = h[i]; x; x= e[x].nxt) {
solve(e[x].to);
}
//……
}Last updated