//图的存储
struct edge{
int from,to,w;
edge(int a,int b,int c){
from=a; to=b; w=c;
}
};
for(int i=1;i<=n;i++)
e[i].clear();
e[a].push_back(edge(a,b,c));
for(int i=0;i<e[u].size();i++){
...
}
//链式前向星
const NUM 1000005;
struct edge{
int to,next,w;
}egde[NUM];
int head[NUM];
int cnt;
void init(){
for(int i=0;i<NUM;i++){
edge[i].next =-1;
head[i]=-1;
}
cnt=0;
}
void addedge(int u,int x,int w){
edge[cnt].to =v;
edge[cnt].w =w;
edge[cnt].next =head[u];
head[u]=cnt++;
}