Graph
klchen0112
这个作者很懒,什么都没留下…
展开
-
棋盘游戏 HDU - 1281
中文题面注意建图方式:将行与列看作顶点 棋子所在的位置的行与列所对应的顶点建边#include <iostream>#include <cstring>#include <cstdio>using namespace std;int N,M,K;bool G[105][105];int V;int match[205];bool used[205...原创 2018-02-23 15:05:20 · 185 阅读 · 0 评论 -
codeforces 1113B
智障了,居然贪心做了暴力枚举记录[1,100]每对的减少最大值,记录每个数字个数枚举最小值 #include<bits/stdc++.h> using namespace std; #define fst first #define sec second #define sci(num) scanf("%d",&num) #def...原创 2019-02-17 19:31:48 · 183 阅读 · 0 评论 -
k短路 k shortest path 入门
K短路求解算法常用的有djstra + A* 和 Yen算法。本文主要讲解djstra + A* 先了解下A*中的估值函数f(n)=g(n)+h(n)f(n)=g(n)+h(n)f(n)=g(n)+h(n),显然我们可以通过记录到达某一点的花费。即如下节点struct node { int h,g,v;}不断更新从某一点更新,将其压入优先队列之中。每取出一个点时需保证其...原创 2018-09-11 21:23:10 · 2155 阅读 · 0 评论 -
Redundant Paths POJ - 3177 kuangbin带你飞 专题九 连通图
题意询问任意两点相互到达,要添加几条边思路:tarjan缩点注意tarjan缩点后形成的树属于同一个强连通分量的low相同竟需将树中所有入度为1的强连通分量连接即可注意应为upper_bound(deg[1] / 2) 及 (ans + 1 ) >> 1 #include <cstdio>#include <cstring&g...原创 2018-06-16 23:14:56 · 150 阅读 · 0 评论 -
Critical Links UVA - 796 kuangbin带你飞 专题九 连通图 tarjan
题意求割边tarjan 模板题#include <map>#include <set>#include <queue>#include <stack>#include <vector>#include <cmath>#include <cstdio>#include <c原创 2018-06-16 23:01:14 · 127 阅读 · 0 评论 -
Network UVA - 315 kuangbin带你飞 专题九 连通图 图论 tarjan
题意求割点tarjan 模板题#include &lt;map&gt;#include &lt;set&gt;#include &lt;queue&gt;#include &lt;stack&gt;#include &lt;vector&gt;#include &lt;cmath&gt;#i原创 2018-06-16 22:57:48 · 131 阅读 · 0 评论 -
Network of Schools POJ - 1236 kuangbin带你飞 图论 tarjan 联通
题意:taskA: 询问有从给几个学校发送任务可以使全部学校的到软件taskB: 询问要加入几条边可以使所有强连通分量成为一个强联通分量思路tarjan 求强联通分量对于taskA 显然只需记录有几个强联通分量的入度为零对于taskB 应为入度为零 出度为零的强联通分量的个数较小值 注意题目保证不存在入度,出度均为0的强联通分量#include <...原创 2018-06-14 19:21:53 · 129 阅读 · 0 评论 -
Candies POJ - 3159
第一道差分约束题意:熊孩纸系列………… A认为B不会比他多c颗糖及candies[B] <= candies[A] + C与d[v] <= d[u] + e.cost 类似#include <iostream>#include <vector>#include <stack>#include <cstring>#includ...原创 2018-03-05 18:50:15 · 162 阅读 · 0 评论 -
Cow Contest POJ - 3660
题意: 给定牛a能打败牛b 求能确定几只牛的排名思路:floyd 传递闭包当一只牛能被打败与能打败牛的总数和为牛的总数减一或没有与其他牛未确定关系时牛的排名可确定#include <iostream>#include <cstdio>#include <cstring>using namespace std;bool martix[101][101];...原创 2018-03-05 18:35:07 · 163 阅读 · 0 评论 -
Currency Exchange POJ - 1860
题意:币种兑换寻找是否有正环计算公式 (money - Cost) * Rate思路:spfa_dfs 判正环#include<stdio.h>#include<string.h>#include <vector>using namespace std;const int MAX_V = 200;struct edge {int to; ...原创 2018-03-05 18:09:27 · 193 阅读 · 0 评论 -
Heavy Transportation POJ - 1797
题意:题意: 求的路径中边权最大值与poj2253l类似注意重边#include <iostream>#include <cstdio>#include <queue>#include <vector>#include <algorithm>#include <cstring>using namespace std...原创 2018-03-05 17:35:33 · 104 阅读 · 0 评论 -
Team Them Up! POJ - 1112
若两个人两两不认识这两两两一条边,判断是否能够染色。会将其分为多个可以染色的子图,再dp背包使人数尽可能少#include&lt;iostream&gt;#include &lt;cstdio&gt;#include &lt;cstring&gt;#include &lt;algorithm&gt;#include &lt;vector&g原创 2019-03-11 17:33:10 · 222 阅读 · 0 评论