自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Remilia's

此博客停更了,新博客地址www.zhuoyifan.net

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

原创 fzu 1963 交通建设(最小生成树)

题目链接:Problem 1963 交通建设思路:多建一个虚拟的点,如果有机场,就和这个点相连,然后就是最小生成树问题了,最后要注意如果一开始没有机场,并且最后只有一条边和虚拟点相连,是需要扣掉权值CA的。代码:#include #include #include using namespace std;const int N = 1005;const int

2014-03-29 20:51:39 1876

原创 11589 - Save the President(暴力+技巧枚举)

链接:11589 - Save the President题意:有n个爆炸区域,每个区域有一个爆炸时间,现在要保护总统,要保证总统的生存空间为x, y, z;并且不被炸到,问有多少个不同时间空间的位置。思路:算上时间,算是一个四维坐标系,问题转化为四维坐标系上有一些点,你要找出前三维大小为(x,y,z)的所有位置。且这个大小内没有点。这题我直接暴力就过了。。而且时间很快,8层for

2014-03-28 22:23:12 1449

原创 UVA 12121 - You are around me ...(贪心+几何)

链接:12121 - You are around me ...题意:给定n个人的坐标,椭圆的离心率e,椭圆的角度r。要求这n个人的椭圆面积相等,并且尽量大,但是不能有两两相交,问这个最大面积。思路:贪心,先按x坐标排序算一次,再按y坐标排序算一次,每次椭圆和最近的两个椭圆相比计算出最大合适面积,维护这个面积的最小值即可。代码:#include #include #includ

2014-03-27 22:52:12 1085

原创 UVA 12002 Happy Birthday(dp+LIS)

链接:12002 - Happy Birthday题意:一排的盘子,你一个个走过去,可以选择拿盘子,加在上面或下面,但是要保证上面的盘子一定小于等于下面的盘子,问最多拿几个。思路:LIS的变形,先找出每个位置的LIS和LDS(注意相等也可以),然后枚举每个位置的LIS(LDS),加上往后找一个比他小(大)作为LDS(LIS)的开头,然后相加就是答案,维护最小值。代码:#incl

2014-03-26 21:56:19 1428

原创 UVA 11766 - Racing Car Computer(DP)

题目链接:11766 - Racing Car Computer题意:n个人进行比赛,以下n行输入对于每个人而言,有a个人在他前面,b个人在他后面。可能并排,问根据所有人情况,找出矛盾最小的数目。思路:这题只要想通一点就很简单了。对于每个人而言,他的位置可能的区间为[a + 1, n - b]。那么对于两个人而言,如果他们可能区间不一样,那么肯定矛盾,反之则不矛盾。因为一个

2014-03-26 14:10:29 1301

原创 UVA 11307 - Alternative Arborescence(dp)

Problem AALTERNATIVE ARBORECSENCEGiven a graph, we define "proper coloring" as coloring of the graph nodes in such way that no two adjacent nodes have the same color. If we map each color to

2014-03-26 12:08:59 1839

原创 UVA 11400 Lighting System Design(贪心+DP)

Problem FLighting System DesignInput: Standard InputOutput: Standard Output You are given the task to design a lighting system for a huge conference hall. After doing a lot of calculation &

2014-03-24 22:44:32 1411 1

原创 HDU 4576 (2013杭州邀请赛J题-dp滚动数组优化)

http://acm.hdu.edu.cn/showproblem.php?pid=4576题意:1-n的环,现在m次操作,每次顺时针或逆时针走w步,顺逆概率相同,问最后走完落在[l,r]内的概率是多少。思路:dp,由于m很大,要滚动数组优化,dp[i][j]代表i步走到j这个位置的概率,那么只可能由i - 1步顺时针或逆时针到达,状态转移挺好想的。主要是,这题卡时间也是卡得厉害,

2014-03-23 22:09:03 1049

原创 HDU 4585 Shaolin(2013杭州邀请赛J题-二分)

http://acm.hdu.edu.cn/showproblem.php?pid=4585题意:少林一些和尚,每个和尚有一个id和一个分值,按输入顺序一个个和尚进来,一开始寺庙有一个住持,分数无限大,编号为1,然后每个和尚进来后会找寺庙已经有的和尚PK,尽量找分接近的,如果有两个接近的,就找分小的那个,注意和尚ID和分数都不会重复,求出这个PK顺序。思路:这题用set非常方便,和尚进

2014-03-23 21:44:23 1216

原创 HDU 4584(2013杭州邀请赛I题-水)

http://acm.hdu.edu.cn/showproblem.php?pid=4584题意:找出一条HC路线,要求HC的曼哈顿距离尽量小,H的x坐标尽量小,y坐标尽量小,C的x坐标尽量小,y坐标尽量小。思路:直接在每条边去找出答案即可,我是直接排个序就找出答案。代码:#include #include #include #include using namespace

2014-03-23 21:40:47 1294

原创 UVA 10934 Dropping water balloons(DP)

链接:10934 - Dropping water balloons题意:k个水球,现在在一个n层建筑物上,水球可能在某一层层以上扔下去会破掉,现在求一个最少的次数使得用这k个水球能确定出哪一层。这题想了好久,,终于想通了思路:dp,一共就3个数据,k个小球,n层,求次数,其中n是非常大的,那么肯定不会选择用n去做状态了,于是想到利用小球数和次数去做状态,dp[i][j]表示i个小

2014-03-23 21:32:36 2003 1

原创 1347 - Tour (双调欧几里得旅行商问题)

链接:1347 - Tour没想通,看了题解,学习了。。。思路【转】:  欧几里得旅行商问题是对平面上给定的n个点确定一条连接各点的最短闭合旅程的问题。如图(a)给出了一个7个点问题的解。这个问题的一般形式是NP完全的,故其解需要多于多项式的时间。J.L. Bentley 建议通过只考虑双调旅程(bitonic tour)来简化问题,这种旅程即为从最左点开始,严格地

2014-03-22 21:57:44 1396

原创 HDU 4763 Theme Section(KMP)

Theme SectionTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 944    Accepted Submission(s): 503Problem DescriptionIt's time for

2014-03-19 23:14:06 1771

原创 fzu 1901 Period II (KMP)

题目链接:http://acm.fzu.edu.cn/problem.php?pid=1901题目要求的找到所有满足S[i]=S[i+P] for i in [0..SIZE(S)-p-1]的前缀,并且长度为p。利用上面的式子可以等价的得到等式s[0,len-p-1] = s[p , len-1].思路:利用next数组的性质,从next[n]往前推即可。代码:#include

2014-03-19 23:00:54 847

原创 hdu 2609 How many(最小表示法)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=2609题目要求的是给定n个字符串,找出不同的字符串的个数。由于题目说了,字符串可以进行变换,也就是如果两个字符串相同那么它们的最小表示是相同的。思路:利用最小表示法求出每个串,然后利用set记录去重,最后输出个数即可代码:#include #include const int N

2014-03-19 22:59:53 989

原创 hdu 3374 String Problem (最小表示法+KMP)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=33741 题目要求给定一个字符串求出最小和最大表示的rank和出现的times。利用最小/大表示法求出位置,然后利用KMP,next求出循环节,就能计算次数。代码:#include #include const int N = 1000005;int n, next[N];c

2014-03-19 22:58:35 735

原创 hdu 2328 Corporate Identity (KMP)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=2328求公共字串,暴力+KMP代码:#include #include #define INF 0x3f3f3f3fconst int N = 205;char s[4005][N];int next[N], n, t;void get_next(char *seq, int

2014-03-19 22:56:57 670

原创 hdu 1238 Substrings(KMP)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1238求个公共字串,正逆序其中一个满足即可。KMP暴力即可。判断的时候正逆序都去判断即可代码:#include #include const int N = 105;#define max(a,b) ((a)>(b)?(a):(b))char s[N][N], rs[N][N];

2014-03-19 22:55:58 899

原创 hdu 4300 Clairewd’s message (KMP)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=4300第一个串给定密文的翻译方式,然后去求一个暗文+明文正确格式的串。思路:保存一个翻译好的明文串,然后和暗文去匹配,从暗文的一半开始匹配,匹配到末看匹配了几个,n - 个数就是暗文/明文的长度代码:#include #include const int N = 100005;ch

2014-03-19 22:54:41 825

原创 hdu 3336 Count the string(KMP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3336求每个前缀串的匹配次数,利用next数组的性质,对于每个位置往前一直推计算总和即可。代码:#include #include #define INF 0x3f3f3f3fconst int N = 200005;char s[N];int next[N], n, t, vi

2014-03-19 22:52:43 665

原创 poj 3080 Blue Jeans(KMP)

题目链接:http://poj.org/problem?id=3080思路:暴力+KMP,枚举第一个串每个位置作为开头,然后用KMP去求公共字串代码:#include #include #define INF 0x3f3f3f3fconst int N = 65;char s[15][N];int next[N], n, t;void get_next(char *s

2014-03-19 22:51:13 598

原创 POJ 2752 Seek the Name, Seek the Fame(KMP)

题目链接:http://poj.org/problem?id=2752求一个串的前缀后缀最长匹配串。利用next数组的性质从next[n]不断往前推即可代码:#include #include #define INF 0x3f3f3f3fconst int N = 400005;char s[N];int next[N], n, ans[N], ansn;void

2014-03-19 22:49:56 566

原创 POJ Power Strings(KMP)

题目链接:http://poj.org/problem?id=2406KMP求最小循环节个数。最小循环节= n - next[n];代码:#include #include #define INF 0x3f3f3f3fconst int N = 1000005;char s[N];int next[N], n;void get_next(char *seq, int

2014-03-19 22:48:23 597

原创 HDU 2594 Simpsons’ Hidden Talents(KMP)

Simpsons’ Hidden TalentsTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2417    Accepted Submission(s): 912Problem DescriptionHo

2014-03-18 21:50:06 546

原创 HDU 2023 亲和串(KMP)

亲和串Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6954    Accepted Submission(s): 3156Problem Description人随着岁数的增长是越大越聪明还是越大越笨,这

2014-03-18 17:14:36 612

原创 HDU 1358 Period(KMP)

PeriodTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2435    Accepted Submission(s): 1205Problem DescriptionFor each prefix of

2014-03-18 17:03:32 559

原创 HDU 3746 Cyclic Nacklace(KMP)

Cyclic NacklaceTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2213    Accepted Submission(s): 979Problem DescriptionCC always b

2014-03-18 13:19:25 623

原创 HDU 2087 剪花布条(KMP)

剪花布条Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7610    Accepted Submission(s): 4996Problem Description一块花布条,里面有些图案,另有一块直接可用

2014-03-18 12:49:53 627

原创 HDU 1681 Oulipo(KMP)

OulipoTime Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4023    Accepted Submission(s): 1591Problem DescriptionThe French author G

2014-03-18 12:44:28 714

原创 UVA 1414 - Hanoi Towers(dp)

The ``Hanoi Towers" puzzle consists of three pegs (that we will name A , B , and C ) with n disks of different diameters stacked onto the pegs. Initially all disks are stacked onto peg A with the sm

2014-03-17 18:59:07 1228

原创 HDU 4749 Parade Show(KMP)

Parade ShowTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 921    Accepted Submission(s): 386Problem Description  2013 is th

2014-03-17 18:09:42 1065

原创 HDU 1711 Number Sequence(KMP)

Number SequenceTime Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9548    Accepted Submission(s): 4370Problem DescriptionGiven two

2014-03-17 14:55:59 598

原创 UVA 12223 - Moving to Nuremberg(树形DP)

题目链接:12223 - Moving to Nuremberg题目大意:给定一颗无根树,有一些结点需要访问num次。然后你现在选择一个点作为起点,去访问每个点,访问完要回到原点,求一个起点,使得访问完所有点的路程最少,问这个路程,并求出这些点(如果有多个点一样小都要输出)。思路:这题是由父亲结点u的状态去推出子节点v状态。如图:dp[u]为结点u的最佳方案,num[v]为

2014-03-15 22:35:31 1604

原创 12222 - Mountain Road(dp+贪心)

Problem EMountain RoadIn the Franconian Switzerland, there is a narrow mountain road. With only a single lane, this is a bottleneck for two-way traffic. Your job is to schedule incoming cars

2014-03-15 00:04:10 1645

原创 609 - Metal Cutting(几何+暴力)

Metal Cutting In order to build a ship to travel to Eindhoven, The Netherlands, various sheet metal parts have to be cut from rectangular pieces of sheet metal. Each part is a convex pol

2014-03-13 01:15:10 1483

原创 Codeforces Round #235 (Div. 2)

Problems  #Name  AVanya and Cardsstandard input/output1 s, 256 MB  x2537BSereja and Contestsstandard input/outpu

2014-03-12 20:48:15 1130

原创 UVA 10239 - The Book-shelver's Problem(记忆化搜索)

Problem DThe Book-shelver’s ProblemInput: standard inputOutput: standard outputTime Limit: 5 secondsMemory Limit: 32 MB You are given a collection of books, which must be shelved i

2014-03-12 10:40:06 1044

原创 UVA 11456 - Trainsorting(DP + LIS)

Problem A: TrainsortingErin is an engineer. She drives trains. She also arranges the cars within each train. She prefers to put the cars in decreasing order of weight, with the heaviest car at the f

2014-03-11 16:15:20 1993

原创 UVA 10688 - The Poor Giant(区间DP)

Problem AThe Poor GiantInput: Standard InputOutput: Standard OutputTime Limit: 1 secondOn a table, there are n apples, the i-th apple has the weight k+i(1<=i<=n). Exactly one of

2014-03-11 13:14:29 1059

原创 HDU 4768 Flyer(二分)

FlyerTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1445    Accepted Submission(s): 510Problem DescriptionThe new semester begi

2014-03-09 20:50:41 1207

空空如也

空空如也

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

TA关注的人

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