bzoj2125 3047】的更多相关文章

仙人掌上的最短路,这里有详细的题解http://pan.baidu.com/s/1wzCpC我觉得讲的很清楚,不懂的见代码注释吧 type node=record po,next,num:longint; end; ..] of node; dfn,low,p,q,mark,s,d,dis,dep,fa:..] of longint; anc:..,..] of longint; v:..] of boolean; st:..] of longint; t,h,i,len,x,y,z,n,m,t…
http://www.lydsy.com/JudgeOnline/problem.php?id=3242 http://uoj.ac/problem/126 http://codevs.cn/problem/3047/ 因为存在一条边,答案所在的点走向左右的城的最短路都不会经过这条边. 所以枚举这条边,剩下的用线段树维护. 线段树初始化搞了好久,忘了在外向树上做dp,树形dp时记录也错了,总之调了一天,吃枣药丸啊QwQ 时间复杂度$O(nlogn)$,听说有$O(n)$的单调队列做法,留一个坑以…
http://acm.hdu.edu.cn/showproblem.php?pid=3047 和hdu 3038以及poj那个食物链一样,都是带权并查集,此题做法和hdu 3038完全相同,具体操作看上篇博客 这题原来写过,但是没过,直接改的原来代码 #include <iostream> #include <cstdio> #include <cstring> #include <set> #include <cmath> using name…
带权并查集. /* 3047 */ #include <iostream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include <algorithm> #include <cstdio> #…
http://acm.hdu.edu.cn/showproblem.php?pid=3047 带权并差集 #include <cstdio> #include <cstring> #include <algorithm> #define maxn 60000 using namespace std; int f[maxn],d[maxn]; ; int n,m; int find1(int x) { if(x==f[x]) return x; int f1=f[x];…
Sublime Text 3 Build 3047 32bit/64bit 简体中文安装破解版 Sublime Text 3 Build 3047 32bit 简体中文安装破解版下载:http://yunpan.cn/QbQzvt4ymqPw5(访问密码:7113) Sublime Text 3 Build 3047 64bit 简体中文安装破解版下载:http://yunpan.cn/QbQzWKchvRBms(访问密码:23b2) 两个压缩包里面皆包含ST3安装包.keygen以及中文包.…
标题来源:POJ 3047 Bovine Birthday 意甲冠军:.. . 思考:式 适合于1582年(中国明朝万历十年)10月15日之后的情形 公式 w = y + y/4 + c/4 - 2*c + 26 * (m+1)/10 + d - 1; m假设是1 2 月份 y要倒退1年 m += 12 y是年份的后两位 y = year%100 c是世纪 c = year/100   #include <cstdio> #include <cstring> using names…
[BZOJ2125]最短路(仙人掌,圆方树) 题面 BZOJ 求仙人掌上两点间的最短路 题解 终于要构建圆方树啦 首先构建出圆方树,因为是仙人掌,和一般图可以稍微的不一样 直接\(tarjan\)缩点,对于每一个强连通分量构建方点(只有一个点的就不要建了) 圆方边的权值定义为到\(dfs\)(\(Tarjan\)不就是搞了一棵\(dfs\)树出来吗?)树上深度最小的点的最短距离. 为什么会有最短距离?因为它是一个环啊,走两侧的距离是不同的. 将圆方树树链剖分,和普通的求距离一样,先求解\(LCA…
http://acm.hdu.edu.cn/showproblem.php?pid=3047 题意: 给出n个座位,有m次询问,每次a,b,d表示b要在a右边d个位置处,问有几个询问是错误的. 思路: 基础带权并查集. #include<iostream> #include<cstdio> using namespace std; +; int n,m; int p[maxn],r[maxn]; int finds(int x) { if(p[x]==x) return x; in…
题意:仙人掌图最短路. 算法:圆方树DP,$O(n\log n+Q\log n)$ 首先建出仙人掌圆方树(与点双圆方树的区别在于直接连割边,也就是存在圆圆边),然后考虑点u-v的最短路径,显然就是:在圆方树上u-v的路径上的所有边权之和,加上每个环(方点)中连出去的两个点的最短距离. 现在问题就是:如何求出环上两个点的最短路径.考虑这样设定边权,首先显然圆圆边的边权就是原图的边权,然后设一个环在搜索树中深度最小的点为这个环的根,则方圆边的边权是环的根到这个点的最短距离,这个可以在Tarjan的时…