HDOJ
文章平均质量分 77
GKHack
这个作者很懒,什么都没留下…
展开
-
BestCoder Round #81 (div.2)C HDOJ5672 String(双指针法)
StringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 813 Accepted Submission(s): 258Problem DescriptionThere is a string S.S原创 2016-04-24 22:02:40 · 780 阅读 · 0 评论 -
HDOJ1175 连连看(bfs)
连连看Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25009 Accepted Submission(s): 6183Problem Description“连连看”相信很多人都玩过。没玩过也没原创 2015-08-21 07:49:01 · 509 阅读 · 0 评论 -
BestCoder Round #51 (div.2) & HDOJ5391 Zball in Tina Town(数论)
Zball in Tina TownTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 305 Accepted Submission(s): 186Problem DescriptionTina To原创 2015-08-16 09:45:32 · 914 阅读 · 0 评论 -
HDOJ3336 Count the string(kmp + dp)
题目链接:点击打开链接给你字符串的长度以及这个字符串,问你前缀数量之和是多少。利用kmp中next数组的性质,将该跳多少位保存到nxt数组中,dp数组保存当前子串i所含前缀数量之和,dp[i] = (dp[nxt[i]] + 1) % MOD计算当前结尾子串i数量加上前nxt[i]个字符这一前缀的数量。AC代码:#include "iostream"#incl原创 2015-10-06 23:40:10 · 1077 阅读 · 0 评论 -
HDOJ3746 Cyclic Nacklace(kmp)
题目链接:点击打开链接给你一个字符串,问你最少添加几个字符可以使字符串有循环节。利用nxt数组的性质,len - nxt[len]即为字符串的最小循环节,且如果len % (len - nxt[len]) == 0,那么当前字符串就是有循环节的,且最小循环节为len / (len - nxt[len])。AC代码:#include "iostream"#inc原创 2015-10-07 07:30:44 · 1098 阅读 · 0 评论 -
HDOJ1358 Period(kmp)
题目链接:点击打开链接给你字符串长度以及此字符串,让你输出子字符串位置以及出现的次数。利用nxt数组以及i % (i - nxt[i]) == 0则有循环节的性质,扫一遍字符串,若满足条件就输出。AC代码:#include "iostream"#include "cstdio"#include "cstring"#include "algorithm"usi原创 2015-10-07 07:37:30 · 734 阅读 · 0 评论 -
HDOJ2594 Simpsons’ Hidden Talents(kmp)
题目链接:给你两个字符串,问你第一个字符串的前缀和第二个字符串的后缀最长想等的字符是什么且长度为多少。把第二个字符串连接到第一个字符串后面,求长字符串的nxt数组,而后利用nxt数组的性质,如果nxt[len] > len1就继续比较,如果nxt[len] > len2也继续比较,最后nxt[x]即为所求字符串长度。AC代码:#include "iostream原创 2015-10-07 07:46:18 · 1059 阅读 · 0 评论 -
HDOJ3068 最长回文(Manacher)
题目链接:点击打开链接Manacher算法的模板题, Manacher算法用于求最长回文串的长度及其他拓展, 套板子即可, 最长为p[i] - 1.AC代码:#include "iostream"#include "cstdio"#include "cstring"#include "algorithm"using namespace std;const int MA原创 2015-10-22 23:18:39 · 939 阅读 · 0 评论 -
HDOJ1231 最大连续子序列(dp)
题目链接:点击打开链接给出一个序列, 让你输出子序列最大和以及子序列的起点和终点的值, 最大和为负则输出0以及序列的起点和终点的值.对每个读入的数累加, 比ans大则更新ans与起点终点, 若加到某处小于0则更新tmp与起点.AC代码:#include "iostream"#include "cstdio"#include "cstring"#include原创 2015-10-15 09:07:12 · 934 阅读 · 0 评论 -
BestCoder Round #50 (div.2) & HDOJ5364 Search Result(模拟)
InputThere are multiply cases.For each case,there is a single integer n(1In second line,there are n integer a1,a2...an(0 OutputOutput ID of the man who should be punished.If原创 2015-08-09 10:33:55 · 1003 阅读 · 0 评论 -
HDOJ1232 畅通工程(并查集)
Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N原创 2015-08-09 15:35:38 · 903 阅读 · 0 评论 -
HDOJ5256 序列变换(dp)
序列变换Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 854 Accepted Submission(s): 345Problem Description我们有一个数列A1,A2...An,你现在要求原创 2015-08-22 00:39:54 · 815 阅读 · 0 评论 -
HDOJ066 一个人的旅行(dijkstra)
Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大原创 2015-08-09 11:00:12 · 1150 阅读 · 0 评论 -
HDOJ1671 Phone List(字典树)
Phone ListTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14553 Accepted Submission(s): 4906Problem DescriptionGiven a list o原创 2015-08-15 10:54:34 · 1061 阅读 · 0 评论 -
HDOJ1166 敌兵布阵(线段树)
Input第一行一个整数T,表示有T组数据。每组数据第一行一个正整数N(N接下来每行有一条命令,命令有4种形式:(1) Add i j,i和j为正整数,表示第i个营地增加j个人(j不超过30)(2)Sub i j ,i和j为正整数,表示第i个营地减少j个人(j不超过30);(3)Query i j ,i和j为正整数,i(4)End 表示结束,这条命令在每组数据最后出原创 2015-08-10 00:01:49 · 961 阅读 · 0 评论 -
HDOJ5317 How Many Maos Does the Guanxi Worth(floyd)
Problem Description"Guanxi" is a very important word in Chinese. It kind of means "relationship" or "contact". Guanxi can be based on friendship, but also can be built on money. So Chinese often s原创 2015-08-09 11:15:46 · 959 阅读 · 0 评论 -
BestCoder Round #49 ($) HDOJ5339 Untitled(dfs)
InputThe first line contains one integer T≤5, which represents the number of testcases. For each testcase, there are two lines:1. The first line contains two integers n and a (1≤n≤20,1≤a原创 2015-08-09 10:05:56 · 999 阅读 · 0 评论 -
HDOJ1698 Just a Hook(线段树)
Problem DescriptionIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the sa原创 2015-08-10 00:25:08 · 700 阅读 · 0 评论 -
HDOJ1394 Minimum Inversion Number(线段树)
Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i aj.For a given sequence of numbers a1, a2, ..., an, if we mov原创 2015-08-10 00:20:20 · 909 阅读 · 0 评论 -
HDOJ1159 Common Subsequence(dp)
题目链接:点击打开链接给出两个字符串, 问你最长公共子序列有多长.lcs模板题目, 摘出求解过程:第一步:先计算最长公共子序列的长度。第二步:根据长度,然后通过回溯求出最长公共子序列。设一个C[i,j]: 保存Xi与Yj的LCS的长度。递推方程为:AC代码:#include "iostream"#includ原创 2015-10-15 09:31:48 · 910 阅读 · 0 评论 -
POJ2250 Compromise(dp)
题目链接:点击打开链接给出两段字符串数组, 每段以"#"结尾, 要求输出两段字符串数组最长的公共字符串.lcs题目, 增加了一个flag数组保存字符串比较结果, 用于最后递归数据答案.AC代码:#include "iostream"#include "cstdio"#include "cstring"#include "algorithm"using na原创 2015-10-15 09:39:49 · 1369 阅读 · 0 评论 -
BestCoder Round #62 (div.2) HDOJ5564 Clarke and digits(dp + 快速幂)
Clarke and digitsTime Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 88 Accepted Submission(s): 44Problem DescriptionClarke is a原创 2015-11-18 10:55:40 · 1323 阅读 · 0 评论 -
BestCoder Round #64 (div.2) HDOJ5587 Array(dfs)
ArrayTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 490 Accepted Submission(s): 235Problem DescriptionVicky is a magician原创 2015-12-04 00:00:23 · 985 阅读 · 0 评论 -
BestCoder Round #64 (div.2) HDOJ5585 Numbers(模拟)
NumbersTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 449 Accepted Submission(s): 280Problem DescriptionThere is a number N.原创 2015-12-03 23:31:30 · 820 阅读 · 0 评论 -
BestCoder Round #64 (div.2) HDOJ5586 Sum(脑洞)
SumTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 671 Accepted Submission(s): 355Problem DescriptionThere is a number sequen原创 2015-12-03 23:43:25 · 903 阅读 · 0 评论 -
BestCoder Round #69 (div.2) B HDOJ5611 Baby Ming and phone number(stl)
Baby Ming and phone numberTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 373 Accepted Submission(s): 108Problem DescriptionB原创 2016-01-24 01:23:47 · 586 阅读 · 0 评论 -
BestCoder Round #65 HDOJ5592 ZYB's Premutation(树状数组+二分)
ZYB's PremutationTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 638 Accepted Submission(s): 302Problem DescriptionZYB has原创 2015-12-08 16:24:05 · 1256 阅读 · 0 评论 -
HDOJ1796 How many integers can you find(dfs+容斥)
How many integers can you findTime Limit: 12000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6048 Accepted Submission(s): 1735Problem Descripti原创 2015-12-08 20:37:31 · 1024 阅读 · 0 评论 -
BestCoder Round #43B HDOJ5265 pog loves szh II(脑洞)
pog loves szh IITime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2346 Accepted Submission(s): 677Problem DescriptionPog and Sz原创 2016-02-27 22:36:22 · 558 阅读 · 0 评论 -
BestCoder Round #62 (div.2) HDOJ5563 Clarke and five-pointed star(计算几何)
Clarke and five-pointed starTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 468 Accepted Submission(s): 247Problem Description原创 2015-11-18 10:36:16 · 961 阅读 · 0 评论 -
BestCoder Round #62 (div.2) HDOJ5562 Clarke and food(脑洞)
Clarke and foodTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 501 Accepted Submission(s): 292Problem DescriptionClarke is a原创 2015-11-18 10:23:01 · 1001 阅读 · 0 评论 -
BestCoder Round #58 (div.2) HDOJ5494 5495 5496 5497题解
题目连接: 点击打开链接A: 模拟题, 从小到大排序后求a的前m个和与b的后m个和作比较即可.AC代码:#include "iostream"#include "cstdio"#include "cstring"#include "algorithm"using namespace std;const int MAXN = 505;int n, m, a[MAXN]原创 2015-11-15 13:09:28 · 1063 阅读 · 0 评论 -
BestCoder Round #60 HDOJ5504 5505 5506题解
题目链接:点击打开链接A: 读入数据的时候先把非0的乘到一起, 然后对n分类讨论, n为1直接输出a[0], 0的个数为n输出0. 而后对ans分类讨论, 大于0直接输出, 小于0的时候, 若0的个数为n - 1输出0, 其他情况则找到绝对值最小的负数除掉就为答案.AC代码:#include "iostream"#include "cstdio"#include "cs原创 2015-10-30 21:42:06 · 987 阅读 · 0 评论 -
HDOJ3294 Girls' research(Manacher)
题目链接:点击打开链接给你一个字符串, 让你输出这个字符串最长回文的起点和终点以及此回文串.Manacher算法的应用, 记录最长回文时i的指, 通过i以及p[i]求出起点和终点, 比较棘手的是输出, 搞了大半天发现一句话就可以解决..AC代码:#include "iostream"#include "cstdio"#include "cstring"#inclu原创 2015-10-23 00:23:24 · 992 阅读 · 0 评论 -
BestCoder Round #63 (div.2) HDOJ5570 balls(数学期望)
ballsTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 90 Accepted Submission(s): 59Problem DescriptionThere are n balls with原创 2015-11-23 00:10:00 · 903 阅读 · 0 评论 -
BestCoder Round #63 (div.2) HDOJ5567 sequence1(暴力)
sequence1Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 132 Accepted Submission(s): 103Problem DescriptionGiven an array a w原创 2015-11-22 11:11:49 · 681 阅读 · 0 评论 -
BestCoder Round #63 (div.2) HDOJ5568 sequence2(dp + 大数)
sequence2Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 231 Accepted Submission(s): 95Problem DescriptionGiven an integer ar原创 2015-11-22 21:15:29 · 934 阅读 · 0 评论 -
BestCoder Round #63 (div.2) HDOJ5569 matrix(dp)
matrixTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 304 Accepted Submission(s): 187Problem DescriptionGiven a matrix with n原创 2015-11-22 23:19:49 · 1045 阅读 · 0 评论 -
BestCoder Round #61 HDOJ5522 5523 5524题解
题目链接: 点击打开链接A: 直接无脑暴力枚举三个数, 或者枚举前两个数, 第三个数二分, 我用了stl的lower_bound()AC代码:#include "iostream"#include "cstdio"#include "cstring"#include "algorithm"using namespace std;const int MAXN = 105原创 2015-10-31 23:46:21 · 1103 阅读 · 0 评论 -
HDOJ1317 XYZZY(floyd + bellman)
Problem DescriptionIt has recently been discovered how to run open-source software on the Y-Crate gaming device. A number of enterprising designers have developed Advent-style games for deployment原创 2015-08-09 11:09:20 · 1038 阅读 · 0 评论