Codeforces Round #121 (Div. 1) C. Fools and Roads time limit per test :2 seconds memory limit per test : 256 megabytes They say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, populated by the fools and connecte…
They say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, between each pair of cities th…
题目链接:Codeforces 191C Fools and Roads 题目大意:给定一个N节点的数.然后有M次操作,每次从u移动到v.问说每条边被移动过的次数. 解题思路:树链剖分维护边,用一个数组标记就可以,不须要用线段树. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 1e5 + 5; int N, Q, ne, fi…
裸的树上差分+倍增lca 每次从起点到终点左闭右开,这就有一个小技巧,要找到右端点向左端点走的第一步,然后差分就好了 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #define N 300005 using namespace std; int fa[N][20],dep[N],f[N],g[N],n,l[N];…