随笔分类 - 图论
摘要:我发现了两种边双的写法 1.先求桥,标记桥再dfs求连通块,< 似乎有点麻烦 2.直接上有向图的写法,把回头的情况标记一下 其1 int tarjan(int x, int fa) { low[x] = dfn[x] = ++df; for (int i = head[x]; i; i = G[i]
阅读全文
摘要:传送门:https://ac.nowcoder.com/acm/problem/52805 我佛了,还能跑边图啊!!! 跑边图不能用vector啦啦啦啦啦 具体也不难,就直接上代码了 #include<cstdio> #include<queue> #include<iostream> #inclu
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/964/B 整了个例题 一、欧拉路(能把边只走一次全走完,图还得连通) 1.无向图 (1)度数全是偶数 (2)有两个奇数度数节点(图都有偶数个奇度数节点,或者没有奇数度数节点)。 2.有向图 (1)每个点出度和入度一样 (2)出
阅读全文
摘要:传送门: https://ac.nowcoder.com/acm/contest/3274/B 牛客练习赛题,真就特判猜结论呗 // 他没说有好几个连通块啊 1 有环(所有点度数为2),极限就是n(连通块的定点数) 2 有链子,或者单点(度数不可能大于2,) 3 特判四个顶点的菊花图。。。。输出3
阅读全文
摘要:https://www.luogu.com.cn/problemnew/solution/P4208 看这里的题解就够了其实 #include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<algorit
阅读全文
摘要:数据范围,n <= 50 具体看代码吧,倍增其实就是动态规划(目前我见过的来说) #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<vector> using namespace st
阅读全文
摘要:这题有毒,不取模还会溢出,我哭了 《进阶指南》p337动态规划 公式就是个这了,代码就不贴了,反正是错的,用java算了
阅读全文
摘要:这题哪里和最小生成树有关系??? 不明白呀! 问有几条路径的题,一般都是乘法原理 #include<iostream> #include<cstring> #include<queue> #include<vector> #include<algorithm> #define maxn 1010 u
阅读全文
摘要:这是一个树上差分的问题; 题目大意 给定一个不包含自环的连通图,从中选出一些边使得特定的点满足入度的奇偶性。 想一个问题,在图上,选择ab两个顶点,记录下他们的路径,经过的顶点度数+=2,对奇偶没有影响。 二两端的顶点度数++;所以问题关键,每个标记1 的点,找两个让他们添加一条边, 那么要如何操作
阅读全文
摘要:#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<vector> #define maxn 300030 using namespace std; struct Node { int
阅读全文
摘要:#include<iostream> #include<vector> #include<cstring> #include<cstdio> #include<queue> #include<algorithm> #include<stack> #include<map> #define maxn
阅读全文
摘要:不能一个一个bfs,要一起bfs #include<iostream> #include<vector> #include<cstdio> #include<queue> #include<cstring> #define maxn 300100 using namespace std; vecto
阅读全文
摘要:https://www.luogu.org/problemnew/solution/P4782 这里的大佬已经说的够好了 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<vector
阅读全文
摘要:#include<cstring> #include<iostream> #include<cstdio> #include<queue> #include<algorithm> #define maxn 200200 using namespace std; typedef long long ll; int par[maxn]; ll num[maxn]; int find(int x) {
阅读全文
摘要:刚开始想了两个小时,打算把区间分块然后计算,但是这就很灵性了看了一个大佬的博客,侵删
阅读全文
摘要:按照《算法竞赛进阶指南》写的 哦对了,注意下最后判断,因为开始拓扑的时候,s可能不在里边,所以不一定等于INF,而是应该大于等于INF
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/959/H来源:牛客网 C国有n个大城市和m条道路,每条道路连接这n个城市中的某两个城市。任意两个城市之间最多只有一条道路直接相连。这m条道路中有一部分为单向通行的道路,一部分为双向通行的道路,双向通行的道路在统计条数时也
阅读全文
摘要:二分+最短路算法
阅读全文

浙公网安备 33010602011771号