随笔分类 - ACM算法--树
摘要:#include<stdio.h> #include<algorithm> #include<iostream> using namespace std; const int maxn=1e4+5; const int inf=0x3f3f3f3f; struct edge{ int v, next
阅读全文
摘要:已知完全二叉树和每条边的权值,q次询问,每次给出sta起点和H。 w=(H-点到sta的权值),求w>0的所有w的加和。 这题用树上前缀和来写,e[i]记录子树上的点到点i的距离,sum[i][j]为e[i]的前缀和 这样每次找到满足大于h-len[i]的长度就行(二分查找) void init()
阅读全文

浙公网安备 33010602011771号