Description 公元 2044 年,人类进入了宇宙纪元. L 国有 n 个星球,还有 n−1 条双向航道,每条航道建立在两个星球之间,这 n−1 条航道连通了 L 国的所有星球. 小 P 掌管一家物流公司, 该公司有很多个运输计划,每个运输计划形如:有一艘物流飞船需要从 ui 号星球沿最快的宇航路径飞行到 vi 号星球去.显然,飞船驶过一条航道是需要时间的,对于航道 j,任意飞船驶过它所花费的时间为 tj,并且任意两艘飞船之间不会产生任何干扰. 为了鼓励科技创新, L 国国王同意小 P…
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 1000005; vector <int> g[N]; int f[N],dis[N],fa[N][20],vis[N],n,m,t1,t2,t3,t4,ps[N],pt[N],lc[N],ans; int a[N],d[N]; void dfs1(int p) { vis[p] = 1; for (int i = 0;…
题目描述 Farmer John has installed a new system of pipes to transport milk between the stalls in his barn (), conveniently numbered . Each pipe connects a pair of stalls, and all stalls are connected to each-other via paths of pipes. FJ is pumping milk…
这居然是我第一次写线段树合并--所以我居然在合并的时候加点结果WAWAWAMLEMLEMLE--!ro的时候居然直接指到la就行-- 树上差分,每个点建一棵动态开点线段树,然后统计答案的时候合并即可 #include<iostream> #include<cstdio> #include<queue> using namespace std; const int N=100005; int n,m,h[N],cnt,de[N],fa[N],si[N],hs[N],fr[…
P3128 [USACO15DEC]最大流Max Flow 题目描述 Farmer John has installed a new system of pipes to transport milk between the stalls in his barn (), conveniently numbered . Each pipe connects a pair of stalls, and all stalls are connected to each-other via path…