自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

thunderMrbird的博客

宠辱不惊,静观堂前花开花落;去留无意,漫随天外云卷云舒。

  • 博客(37)
  • 收藏
  • 关注

原创 poj1987 Distance Statistics 树的分治

DescriptionFrustrated at the number of distance queries required to find a reasonable route for his cow marathon, FJ decides to ask queries from which he can learn more information. Specifically,

2016-08-24 10:54:05 700

原创 poj2594 经处理后的最小路径覆盖

题目描述:给你一个有向无环图,有n个点,m条有向边。一个机器人可以从任意点开始沿着边的方向走下去。对于每一个机器人:走过的点不能再走过。问你最少用几个机器人可以走完所有的n个点,不同的机器人可以走相同的点。可以看出这题类似于经典的最小路径覆盖。(注意最小路径覆盖和最小边覆盖的区别)只不过多了一个条件就是可以多个机器人访问同一个点。思路也和之前一样,建图找最大匹配数,这时问题来了

2016-08-23 15:46:58 641

原创 算法讲解:二分图匹配

二分图匹配,自然要先从定义入手,那么二分图是什么呢?二分图:二分图又称作二部图,是图论中的一种特殊模型。 设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同的顶点集(i in A,j in B),则称图G为一个二分图。简单的说,一个图被分成了两部分,相同的部分没有边,那这个图就是二分图,二

2016-08-23 10:17:36 56371 21

原创 hdu1281 棋盘游戏 二分图匹配

Description小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击。 所以现在Gardon想让小希来解决一个更难的问题,在保证尽量多的“车”的前提下,棋盘里有些格子是可以避开的

2016-08-20 17:05:27 626

原创 hdu2255 奔小康赚大钱,二分图最优匹配km模板

Description传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子。 这可是一件大事,关系到人民的住房问题啊。村里共有n间房间,刚好有n家老百姓,考虑到每家都要有房住(如果有老百姓没房子住的话,容易引起不安定因素),每家必须分配到一间房子且只能得到一间房子。 另一方面,村长和另外的村领导希望得到最大的效益,这样村里的机构才会有钱.由于老百姓都比较

2016-08-20 16:05:32 1028

原创 hdu2444 二分图匹配(判断二分图)

DescriptionThere are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply that A and C k

2016-08-20 11:13:08 1003

原创 UVA 10163 Storage Keepers 两次dp

Randy Company has N (1 ≤ N ≤ 100) storages. Company wants some men to keep them safe. Nowthere are M (1 ≤ M ≤ 30) men asking for the job. Company will choose several from them. RandyCompany employ

2016-08-18 11:28:33 442

原创 hdu3549 网络流ek模板

DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph.InputThe first line of

2016-08-17 15:37:30 490

原创 hdu5093 Battle ships 二分图匹配

DescriptionDear contestant, now you are an excellent navy commander, who is responsible of a tough mission currently. Your fleet unfortunately encountered an enemy fleet near the South Pole wh

2016-08-17 13:49:28 564

原创 算法讲解:ac自动机及简单衍生

AC自动机简介: 首先简要介绍一下AC自动机:Aho-Corasick automation,该算法在1975年产生于贝尔实验室,是著名的多模匹配算法之一。一个常见的例子就是给出n个单词,再给出一段包含m个字符的文章,让你找出有多少个单词在文章里出现过。嗯没错,比如word文档等一系列带有查找功能的东西一般用的都是这种东西啦。要搞懂AC自动机,先得有字典树Trie和KMP模式匹配算法的

2016-08-08 13:36:10 2362

原创 hdu1247 Hat's words trie树

DescriptionA hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary. You are to find all the hat’s words in a dictionary.  In

2016-07-29 15:23:08 458

原创 hdu3592 差分约束问题

DescriptionNowadays, many people want to go to Shanghai to visit the World Exhibition. So there are always a lot of people who are standing along a straight line waiting for entering. Assume that

2016-07-29 14:35:48 386

原创 hdu1811 并查集+拓扑排序

Description自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。 为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新,名堂要比福布斯富豪榜还响。关于如何排名,这个不用说都知道是根据Rating从高到低来排,如果两个人具有相同的Rating,那就按这几个人的RP从高到低来

2016-07-29 11:02:35 1202

原创 hdu2222 ac自动机模版

DescriptionIn the modern time, Search engine came into the life of everybody like Google, Baidu, etc. Wiskey also wants to bring this feature to his image retrieval system. Every image have a

2016-07-27 20:35:39 503

原创 poj3461Oulipo kmp

DescriptionThe French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:Tout avait Pair n

2016-07-27 19:25:32 367

原创 poj1094 拓扑排序(屎)

An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence A, B, C, D

2016-07-27 11:10:50 507

原创 uva10305 拓扑排序

John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task isonly possible if other tasks have already been executed.题干很短,意思很简单,拓扑排序。我的方法是用队列做,将入度为零的点进队,每次出

2016-07-26 16:56:04 554

原创 hdu3062 2-sat

Description有n对夫妻被邀请参加一个聚会,因为场地的问题,每对夫妻中只有1人可以列席。在2n 个人中,某些人之间有着很大的矛盾(当然夫妻之间是没有矛盾的),有矛盾的2个人是不会同时出现在聚会上的。有没有可能会有n 个人同时列席? Inputn: 表示有n对夫妻被邀请 (nm: 表示有m 对矛盾关系 ( m 在接下来的m行中,每行会有4个

2016-07-26 16:11:59 422

原创 hdu4405 概率dp

DescriptionHzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws a dice(a dice have six faces with equal probabil

2016-07-26 15:58:48 397

原创 hdu4422 The Little Girl who Picks Mushrooms 暴力

It's yet another festival season in Gensokyo. Little girl Alice planned to pick mushrooms in five mountains. She brought five bags with her and used different bags to collect mushrooms from different

2016-07-26 11:35:54 560

原创 hdu4430 Yukari's Birthday 枚举+二分

Today is Yukari's n-th birthday. Ran and Chen hold a celebration party for her. Now comes the most important part, birthday cake! But it's a big challenge for them to place n candles on the top of the

2016-07-26 10:36:38 623

原创 poj2001 Shortest Prefixes trie树

DescriptionA prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", "ca", "car", "carb", "carbo", and "carbon". Note that the empty str

2016-07-25 16:09:04 312

原创 hdu1269 强连通分量tarjan

Problem Description为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N Input输入包含多组数据,输入的第一行有两个数:N和M,接下来的M行每行有两个数a和b,表示了一条通道可以从A房间来到B房间。文件最后以两个0结束。 Output对于输入的每组数据,如果任意两个房间都是相互连接的,输

2016-07-25 16:05:43 474

原创 HDU1251统计难题 trie树

DescriptionIgnatius最近遇到一个难题, 老师交给他很多单词( 只有小写字母组成, 不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量( 单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表, 每行一个单词, 单词的长度不超过10, 它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是

2016-07-24 17:24:06 528

原创 poj1509 字符串最小表示法

题意就是给一个环形字符串,求在哪里断开可以得到字典序最小的字符串经典的字符串最小表示法#include#include#include#include#include#includeusing namespace std;typedef long long ll;#define N 505const int inf=0x3f3f3f3f;string str;int

2016-07-24 15:46:54 492

原创 UVA11374_Airport Express

In a small city called Iokh, a train service, Airport-Express,takes residents to the airport more quickly than other transports.There are two types of trains in Airport-Express,the Economy-Xpress and

2016-07-24 14:57:45 608

原创 UVA - 10537 The Toll! Revisited dijkstra反向

Sindbad the Sailor sold 66 silver spoons to the Sultan of Samarkand. The selling was quite easy; butdelivering was complicated. The items were transported over land, passing through several towns andv

2016-07-24 11:20:04 612

原创 hdu4126 prim+树形dp

Genghis Khan(成吉思汗)(1162-1227), also known by his birth name Temujin(铁木真) and temple name Taizu(元太祖), was the founder of the Mongol Empire and the greatest conqueror in Chinese history. After uniting

2016-07-23 16:43:36 368

原创 POJ2728 Desert King 最优比率生成树

David the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his country to bring water to every village. Villages which are co

2016-07-21 20:13:06 472

原创 HDU 3415-Max Sum of Max-K-sub-sequence 单调队列

Given a circle sequence A[1],A[2],A[3]......A[n]. Circle sequence means the left neighbour of A[1] is A[n] , and the right neighbour of A[n] is A[1]. Now your job is to calculate the max sum of a Ma

2016-07-21 18:32:47 308

原创 hdu5444 Elven Postman 二叉树遍历

Elves are very peculiar creatures. As we all know, they can live for a very long time and their magical prowess are not something to be taken lightly. Also, they live on trees. However, there is som

2016-07-19 16:48:55 730

原创 POJ-1182 食物链

Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个

2016-07-18 16:52:49 567

原创 BZOJ1026 [SCOI2009] windy数

Description  windy定义了一种windy数。不含前导零且相邻两个数字之差至少为2的正整数被称为windy数。 windy想知道,在A和B之间,包括A和B,总共有多少个windy数?Input  包含两个整数,A B。Output  一个整数还算是一道标准的数位dp,不过使

2016-07-12 10:39:56 594

原创 hdu2089 不要62

Description杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。 不吉利的数字为所有含有4或62的号码。例如: 62315 73418 88914 都属于不吉利号码。但是,61152虽然含有6和2,

2016-07-11 20:32:46 702

原创 poj1185 炮兵阵地 状压dp

司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围如图中黑色区域所示: 如果在地图中的灰色所标识的平原上部署一支炮兵部队,则图中的黑色的网格表示它能够攻击到的区域

2016-07-11 20:21:54 587

原创 八数码问题--A*算法

hdu1043:#include#include#include#include#includeusing namespace std;typedef long long ll;int a[10];int vis[400000];int way[4][2]={{0,1},{0,-1},{1,0},{-1,0}};int pre[400000];int Hash[10]={1,

2016-07-08 19:03:07 1755

原创 数据结构中哈夫曼树水题代码

描述:写一个哈夫曼码的编/译码系统,要求能对要传输的报文进行编码和解码。构造哈夫曼树时,权值小的放左子树,权值大的放右子树,编码时右子树编码为1,左子树编码为0. 输入:输入表示字符集大小为n(n 输入串长小于或等于100的目标报文。输出:经过编码后的二进制码,占一行;以及对应解码后的报文,占一行;最后输出一个回车符。输入样例:

2016-04-27 15:32:45 1883

空空如也

空空如也

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

TA关注的人

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