链式前向星+Poj3321
参考博客:https://blog.csdn.net/acdreamers/article/details/16902023
/*
其中edge[i].to表示第i条边的终点,edge[i].next表示与第i条边同起点的下一条边的存储位置,edge[i].w为边权值.
另外还有一个数组head[],它是用来表示以i为起点的第一条边存储的位置,实际上你会发现这里的第一条边存储的位置其实
在以i为起点的所有边的最后输入的那个编号.
head[]数组一般初始化为-1,对于加边的add函数是这样的:
*/
void add(int u,int v,int w)
{
edge[cnt].w = w;
edge[cnt].to = v;
edge[cnt].next = head[u];
head[u] = cnt++;
}
poj3321
题目是简单题,就是我本人和poj不是很合得来。
1.用到的知识点是dfs序+树状数组
2.开vector会tle,改链式前向星,忘了怎么写,见上面。
3.我的O(n)建BIT数组被卡了,tle
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include