自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 hdu 6068 Classic Quotation

这个博客讲的非常好  点击打开链接Description 给出一个长度为n的字符串S和一个长度为m的字符串T,有q次查询,每次查询给出一个区间[L,R],求对所有1Input 第一行一整数T表示用例组数,每组用例首先输入三个整数n,m,q分别表示S串串长和T串串长以及查询次数,之后输入串S和串T,两个串均由小写字母构成,最后q行每行输入两个整数L,R表示一次查询 (1O

2017-08-30 15:38:47 344

原创 hdu 6178 dfs+超神读入挂

Problem DescriptionThere is a tree having N vertices. In the tree there are K monkeys (K <= N). A vertex can be occupied by at most one monkey. They want to remove some edges and leave minimum edg

2017-08-29 21:23:10 353

原创 hdu 6044 dfs+组合数

Problem DescriptionAs to a permutation p1,p2,⋯,pn from 1 to n, it is uncomplicated for each 1≤i≤n to calculate (li,ri) meeting the condition that min(pL,pL+1,⋯,pR)=pi if and only if li≤L≤i

2017-08-29 20:41:28 315

原创 hdu 6161

Problem DescriptionYou are given a complete binary tree with n nodes. The root node is numbered 1, and node x's father node is ⌊x/2⌋. At the beginning, node x has a value of exactly x. We de

2017-08-28 14:52:34 215

原创 hdu 6162 树链剖分

Problem DescriptionMr. Cui is working off-campus and he misses his girl friend very much. After a whole night tossing and turning, he decides to get to his girl friend's city and of course, with w

2017-08-28 12:42:07 252

转载 树链剖分详解

树链剖分用一句话概括就是:把一棵树剖分为若干条链,然后利用数据结构(树状数组,SBT,Splay,线段树等等)去维护每一条链,复杂度为O(logn)  那么,树链剖分的第一步当然是对树进行轻重边的划分。定义size(x)为以x为根的子树节点个数,令v为u的儿子中size值最大的节点,那么(u,v)就是重边,其余边为轻边。 当然,关于这个它有两

2017-08-28 11:58:46 230

原创 hdu 6039 线段树+dfs序

constroy has some gears, each with a radius. Two gears are considered adjacent if they meet one of the following conditions: 1. They share a common edge (i.e. they have equal linear velocity). 

2017-08-27 21:35:46 296

原创 hdu6171 双向搜索+hash

Suppose that you are an admiral of a famous naval troop. Our naval forces have got 21 battleships. There are 6 types of battleships.First, we have got one flagship in which the admiral must be and i

2017-08-26 22:02:02 580

原创 hdu 6180 贪心+multiset

Problem DescriptionThere are N schedules, the i-th schedule has start time si and end time ei (1 timeend and timestart , where time_{end} is time to turn off the machine and timestart is t

2017-08-25 10:26:23 263

原创 hdu 6170 模拟

Problem DescriptionGiving two strings and you should judge if they are matched.The first string contains lowercase letters and uppercase letters.The second string contains lowercase letters, u

2017-08-23 10:49:43 294 1

原创 hdu 6168 模拟+优先队列

zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i(ai+aj). These new numbers could make up a new sequence b1,b2,...,bn(n−1)/2.LsF wants to make some trouble. While zk is sleeping, Lsf

2017-08-23 10:46:39 217

原创 优先队列详解

首先队列的特征大家都知道,就是先进先出,但是在有些时候我们需要队列所存的数据按照一定的优先级输出,这个时候我们就可以用优先队列解决了1.头文件2.变量声明priority_queue 变量名3.优先级priority_queue, less > 大的优先级大priority_queue<int, vector, greater > 小的优先级大当

2017-08-23 09:49:16 346

原创 hdu 3065 ac自动机

小t非常感谢大家帮忙解决了他的上一个问题。然而病毒侵袭持续中。在小t的不懈努力下,他发现了网路中的“万恶之源”。这是一个庞大的病毒网站,他有着好多好多的病毒,但是这个网站包含的病毒很奇怪,这些病毒的特征码很短,而且只包含“英文大写字符”。当然小t好想好想为民除害,但是小t从来不打没有准备的战争。知己知彼,百战不殆,小t首先要做的是知道这个病毒网站特征:包含多少不同的病毒,每种病毒出现了多少次。大家

2017-08-22 21:17:29 162

原创 hdu 2896 ac自动机

当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻。。。。在这样的时刻,人们却异常兴奋——我们能在有生之年看到500年一遇的世界奇观,那是多么幸福的事儿啊~~ 但网路上总有那么些网站,开始借着民众的好奇心,打着介绍日食的旗号,大肆传播病毒。小t不幸成为受害者之一。小t如此生气,他决定要把世界上所有带病毒的网站都找出来。当然,谁都知道这是不可能的。小t却执意要完成这不能的任务,他说

2017-08-22 21:15:53 155

原创 hdu 6136 模拟+优先队列

Problem Description> During the Trade Federation invasion of Naboo, Anakin Skywalker won the Boonta Eve Classic on Tatooine, securing his freedom from a life of slavery. Betting on the races was a

2017-08-22 21:06:40 306

原创 hdu 6138 ac自动机

Problem Description> The Eternal Fleet was built many centuries ago before the time of Valkorion by an unknown race on the planet of Iokath. The fate of the Fleet's builders is unknown but their l

2017-08-22 10:14:12 368

原创 无向图的最大独立集和最大团

首先说说最大独立集和最大团的意义:最大独立集:从无向图中的顶点中选出k个并且k个顶点之间互不相邻,最大的k就是最大独立集最大团:从无向图的顶点集中选出k个并且k个顶点之间任意两点之间都相邻(完全图),最大的k就是最大团性质:无向图的最大团==该无向图补图的最大独立集最大团模板:#include#include#define N 1010/*最大团 = 补

2017-08-21 19:17:33 10372 1

原创 zoj 3416 Balanced Number 数位dp

A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. When a pivot is

2017-08-21 18:09:05 181

原创 hdu 4389 X mod f(x) 数位dp

Here is a function f(x):   int f ( int x ) {    if ( x == 0 ) return 0;    return f ( x / 10 ) + x % 10;   }   Now, you want to know, in a given interval [A, B] (1 9), how many integer

2017-08-21 17:58:35 316

原创 HDU - 4734 F(x) 数位dp

For a decimal number x with n digits (A nA n-1A n-2 ... A 2A 1), we define its weight as F(x) = A n * 2 n-1 + A n-1 * 2 n-2 + ... + A 2 * 2 + A 1 * 1. Now you are given two numbers A and B, please c

2017-08-21 17:48:04 190

原创 hdu 3555 Bomb 数位dp

The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the current number sequence inc

2017-08-21 16:59:10 212

原创 hdu 2089 不要62

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

2017-08-21 16:21:13 177

原创 FZU - 2109 Mountain Number

题 目 传 送 门: x=a[0]a[1]...a[len-2]a[len-1],所有下标为奇数的数都>=他左右的数的称为Mountain Number ,找L~R中Mountain Number的个数思路:数位dp,dp[i][j][k],i表示第i位,j表示奇数位还是偶数位,k表示前一位的数ac代码:#include #include #include u

2017-08-21 16:17:35 237

原创 fzu 2113 Jason的特殊爱好

题 目 传 送 门:数位dp水题,dp[i][j]表示到第i位,1的个数为j的数的个数ac代码:#include #include #include using namespace std;int num[20];long long dp[20][20];long long dfs(int len,int n,int limit){ if(len<0) r

2017-08-21 16:08:33 229

原创 hdu 6140 阅读理解

题解:一开始只有a1能构成[-1,1]区间,L为左区间,R为右区间,因为如果加入一个值小于区间的话最终只会扩大变成一个更大范围的连续区间 a[i]如果只能负的话如果a[i]a[i]如果只能正的话如果a[i]a[i]如果可正可负的话如果a[i]最终判断k=L是不是即可#include#include#include#includeusing namespace std;

2017-08-18 12:50:16 300

原创 hdu 6143 Killer Names dp

题 目 传 送 门:题意:给出一个m个字母的字母表,问我们能生成多少对字符串,该对字符串长度为n。并且字符串之间不能存在相同的字母思路1:dp[i][j]表示用j中颜色去涂i个格子(j中颜色全用上),然后直接dp。状态转移方程为:dp[i][j]=dp[i-1][j]*j+dp[i-1][j-1]*(m-(j-1));ac代码:#include using names

2017-08-18 12:10:35 200

转载 RMQ算法详解

1. 概述RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j算法。当然,该问题也可以用线段树(也叫区间树)解决,算法复杂度为:O(N)~O(logN),这里我们暂不介绍。2.RMQ算法对于该问题,最容易想到的解决方案是遍历,复杂度是O(n)。但当数据量

2017-08-16 18:56:28 326

原创 poj 3071 概率dp

FootballTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 4344 Accepted: 2220DescriptionConsider a single-elimination football tournament involving

2017-08-14 16:49:20 181

原创 hdu6119 小小粉丝度度熊

题目传送门:思路:首先题目中说区间可能有交叉,所以第一步我们先处理一下区间重叠的情况把重叠的区间合并一下第二步我们只需要尺取一下找最大区间就可以了#include #include #include #include using namespace std;const int maxn=1e9+7;struct node{ int x; int y;}d

2017-08-14 13:23:15 294

原创 hdu 6114

题目传送门:假设矩阵的长边为n,短边为m,那么按题意摆放最多能放m个車,题目就转化为我们从1~n里边随意选择m个数,然后把它们按前后顺序挨个放在1~m即可ac代码:#include #include #include using namespace std;const int maxn=1e9+7;long long c[1005][1005];void init(

2017-08-14 09:54:55 393

原创 hdu 6112

题目传送门:思路:三种情况2月29之前2月292月29之后ac代码:#include#includeusing namespace std;int ph(int x){ if(x%400==0||(x%4==0&&x%100!=0)) return 1; return 0;}int main(){ int n;

2017-08-14 09:47:56 250

原创 hdu6108 思维

题 目 传 送 门(1),(2)两个条件同时满足的话  就必须要满足p%B==1,即(p-1)%B==0,即求出p-1因子的个数即可ac代码:#include#includeusing namespace std;const int N = 5000 + 5;const double EPS = 1e-7;int slove(int n

2017-08-13 10:35:06 458

转载 hdu 6096

因为要求前缀后缀都包含的个数,所以可以把字符串a转换成a#a这样一个字符串,比如abca就转换成abca#abca然后对于一组前缀a后缀b转换成b#a,比如ab ca,就是ca#ab,然后对前缀后缀的串建立AC自动机,让主串去匹配,如上述例子,ca#ab满足为abca#abca的一个子串,也就是abca满足这个前缀后缀,所以问题,就转换成了典型的ac自动机匹配问题。加个#的

2017-08-13 09:06:23 255

原创 hdu 6105 Gameia 思维+策略

题 目 传 送 门题意:给出一棵树,Alice 和 Bob 轮流操作, Alice先手, Alice的操作是选一个未染色的点将其染成白色,Bob的操作是选一个未染色的点将其染成黑色,并且和这个点有直连边的点也被强制染成黑色(无论这些直连点之前是否有颜色),Bob还有一个小技能是去掉一条边,最后当所有点都有颜色的时候,如果有白色点则Alice赢,否则Bob赢。思路:官方题解:

2017-08-11 19:24:00 290

原创 hdu 6103 Kirinriki 枚举+尺取

题 目 传 送 门题意:首先定义了两个串之间的距离          然后给我们一个串让我们找到这个串中两个不重叠的最长子串(两子个串长度相同),满足两个子串的距离思路:由于两个串是不重叠的,所以我们首先可以枚举两个串的对称轴,但这时候我们又需要分为两种情况讨论1.2.枚举完对称轴然后尺取法找最大长度就可以了ac代码:#include

2017-08-11 10:19:43 239

原创 hdu6090 Rikka with Graph

题 目 传 送 门题意:给定n个点,m条边,让你安排点和边构成一个无向图。dis(i,j),表示i到j最小的边数,如果无法到达,dis(i,j)为n,问每个点到其他所有的点的dis之和。思路:简单的贪心策略问题,有两种情况1.当m>n-1(连通)的时候2*m个dis(i,j)为1,其余为22.当m(1)m+1个点是联通的和1一样(2)n-(m

2017-08-09 13:39:03 244

原创 hdu 6092 Rikka with Subset 逆向背包

题 目 传 送 门题意:题中给出一个序列的两个性质1.序列中数的个数为n2.序列中所有数之和为m然后给出和为0~m的子序列的个数,最后让我们确定这个序列思路:比赛的时候写的是正向背包,一直re,后来发现从前往后加的话就有好多就覆盖了但是如果写反向背包的话就不会出现这种情况ac代码:#includeusing namespace std;const

2017-08-09 13:02:31 358

原创 单调栈

单调栈与单调队列很相似。首先栈是后进先出的,单调性指的是严格的递增或者递减。单调栈有以下两个性质:1、若是单调递增栈,则从栈顶到栈底的元素是严格递增的。若是单调递减栈,则从栈顶到栈底的元素是严格递减的。2、越靠近栈顶的元素越后进栈。单调栈与单调队列不同的地方在于栈只能在栈顶操作,因此一般在应用单调栈的地方不限定它的大小,否则会造成元素无法进栈。元素进栈过程:

2017-08-07 15:26:43 158

原创 poj 3494 单调栈

Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements.InputThe input contains multiple test cases.

2017-08-07 15:23:53 352

原创 poj 2796 单调栈

Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent people's memories about some period of life. A ne

2017-08-07 14:50:04 173

空空如也

空空如也

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

TA关注的人

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