正向表用于优化vector的速度。
注意正向表是反序查询的
/*_________________________正向表_______________________________*/
// !!!!!!!!!M=2*M;
//NO.one
int tot,h[M];//标号
struct node{
int to;//val
int nx;//must have it pointed the next one
}G[M<<1];
void Add(int a,int b){
G[++tot].to=b;//val
G[tot].nx=h[a];//h[]初值为0
h[a]=tot;
}
for(register int i=h[x];i;i=G[i].nx) //如果为0终止
//NO.two
int A[M],B[M],C[M];//信息
int tot,h[M],nx[M];
void Add(int x,int a,int b,int c){
//信息
A[++tot]=a;
B[tot]=b;
C[tot]=c;
//连接
nx[tot]=h[x];
h[x]=tot;
}
for(register int i=h[x];i;i=nx[i])
a=A[i],b=B[i],c=C[i];
/*______________________________________________________________*/