自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 Gap HDU - 1067 BFS

暴力bfs + map判重#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <cstring> #include <queue> #include <cmath> #include <map>using namespace std;struct node { char a

2017-09-07 21:18:49 247

原创 Magic Cube ZOJ - 2477 IDA*模拟

棘手的模拟, 要算出移动后的位置, 注意顺逆针方向, wa了几次, 用IDA*搜索 因为中心颜色确定,找出每个面与中心颜色不同的数量, 每次旋转最多改变12个, 当不同数量/12>深度时剪枝。#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <cstring> #include

2017-09-07 18:22:45 434 1

原创 DNA sequence HDU - 1560 IDA*

迭代加深搜索,每次限制一个深度,搜不到就+1. 剪枝: 当剩余的深度不够最小匹配次数时直接退出。#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <cstring> #include <queue> #include <cmath>using namespace std;int

2017-09-07 15:28:45 266

原创 HDU - 3567 Eight II IDA*

典型的IDA*题目 估值函数:从当前状态移动到目标状态所需的最小步数(我们可以通过曼哈顿距离进行估值),用于剪枝 迭代:此处我们不再使深度每次加1,而是在搜索过程当中,记录大于len(len表示此次搜索的限制深度)的所有值中的最小值,作为下次迭代的限制深度#include <iostream> #include <cstdio> #include <algorithm> #include <cs

2017-09-06 16:31:57 356

原创 Eight HDU - 1043 八数码 A*算法

康托展开判重。也可以用打表和双向bfs做。 第一个A*搜索,A*是一种启发式搜索,g为已花代价,h为估计的剩余代价,而A*是根据f=g+h作为估价函数进行排列,也就是优先选择可能最优的节点进行扩展。可以对f进行关键字耗时600ms, 如果对h作为第一关键字, g作为第二关键字耗时170ms。#include <iostream> #include <cstdio> #include <algori

2017-09-06 11:02:55 382

原创 A - Network of Schools POJ - 1236 强连通分量缩点

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <cmath> #include <vector> #include <stack>using namespace std;int n, m; vector<int> g[101]; bool

2017-09-01 10:54:32 348

原创 Network UVA - 315 求割点数量

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <cmath> #include <vector>using namespace std;const int MaxM = 1e5;int n, cnt; bool f[101][101], m

2017-09-01 10:53:09 208

原创 Find The Determinant III SPOJ - DETER3

计算n阶矩阵行列式的值#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <cmath> #include <vector>using namespace std;long long a[201][201];long long det(long

2017-08-30 18:45:43 329

原创 Organising the Organisation UVA - 10766

生成树计数, matrix-tree定理#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <cmath> #include <vector>using namespace std;int f[51][51]; long double c[51]

2017-08-30 16:40:19 328

原创 不定根最小树形图 Ice_cream’s world II HDU - 2121

不定根就是加一个虚根(原本不存在的点) , 可以让这个虚根到每个点的距离大于原本所有点连接的道路花费之和sum , 然后计算出的结果减去sum,如果比sum还大就可以认为通过这个虚拟节点我们连过原图中两个点,即原图是不连通的,我们就可以认为不存在最小树形图。那么真正的根呢 , 在找最小入弧时,如果这条弧的起点是虚拟根,那么这条弧的终点就是要求的根,因为如果有多解的话,必然存在一个环,环上的顶点都可以

2017-08-28 19:45:25 487

原创 最小树形图 Command Network POJ - 3164

朱刘算法模版#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <cmath> #include <vector>using namespace std;struct node { int u, v, next; double w

2017-08-28 14:49:41 240

原创 ACM Contest and Blackout UVA - 10600

In order to prepare the “The First National ACM School Contest” (in 20??) the major of the city decided to provide all the schools with a reliable source of power. (The major is really afraid of blacko

2017-08-24 09:59:24 224

原创 hdu-6166 Senior Pan

Problem Description Senior Pan fails in his discrete math exam again. So he asks Master ZKC to give him graph theory problems everyday. The task is simple : ZKC will give Pan a directed graph every t

2017-08-23 16:01:56 384

原创 POJ - 1679 The Unique MST. 求次小生成树

判断最小生成树是否唯一, 即求次小生成树, O(nm + mlogm) 还要判断一下图是否联通。#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue>using namespace std;struct node { int u, v, w; }e[1000

2017-08-23 14:15:03 206

原创 HDU - 3416 Marriage Match IV 求最短路条数

题意:n个点m条边, 求a到b最短路条数。题解:求出a点到所有点的距离, b点到所有点距离, a到b最短路。建一个图, 枚举所有的边,如果此条边在最短路上(dist[a] + dist[b] + wab == mindistab)则加入图中, 容量为1, 超级汇点s连a ,t连b,用dinic 跑一边最大流即可。#include <iostream> #include <cstdio> #inclu

2017-08-21 08:34:32 252

原创 POJ - 2763. Housewife Wind LCA+单点更新

After their royal wedding, Jiajia and Wind hid away in XX Village, to enjoy their ordinary happy life. People in XX Village lived in beautiful huts. There are some pairs of huts connected by bidirectio

2017-08-17 10:09:29 260

原创 POJ - 3728 The merchant

若买卖不在相邻城市,朴素的想法是遍历找出路径,然后找出路径上的最高最低价格得到价格差。然而每次光找路径就要耗费O(n)的时间,而题目中肯定有多个Query。用动态规划的思路解决问题,对指定两点uv,假设v往上走2^k步的父节点为t,走2^(k+1)步的父节点为u,如下图所示边上的数字表示深度之差。定义四个dp数组:int dp_max[MAX_LOG_V][MAX_V], dp_min[MAX_LO

2017-08-16 17:28:43 326

原创 HDU - 3830 Checkers

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm>using namespace std;struct node { int x, y, z, d; }s, e;void run(node &u) { int num[3] = {u.x, u.y, u.z}; sort(n

2017-08-14 21:13:52 333

原创 HDU - 2874 Connections between cities (LCA Tarjan)

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <map> #include <vector>using namespace std;const int MaxN = 10000;struct node { int v, w, next; }e[MaxN * 2 +

2017-08-04 16:50:29 363

原创 Codeforces Round #425 (Div. 2) D. Misha, Grisha and Underground

#include  #include  #include  #include  #include  #include  using namespace std; const int MaxN = 1e5; int n, m; int depth[MaxN + 1]; int f[MaxN + 1][20

2017-08-02 20:21:55 321

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除