[POJ 3321]Apple Tree dfs序+树状数组
给定一棵树,树上权值初始时为1。
给出两种操作:
1.将单点权值取反。
2.查询子树的权值和。
我们可以通过dfs将其映射到一个树状数组里,记录子树的起始位置以及终止位置。直接暴力改logn查询即可。
#include
#include
using namespace std;
const int Maxn=2e5+5;
int n,m,Timer=0,tot=0;
int c[Maxn
原创
2017-10-12 20:36:42 ·
290 阅读 ·
0 评论