随笔分类 -  HASH

bunoj 34990(hash)
摘要:传送门:Justice String题意:有两个串A,B,问是否存在A的一个子串S,S和B的长度相等,最多有2个字符不同。如果有多个,输出其实下标最小S的下标,没有输出-1。分析:从A每个位置开始找最长公共前缀,如果最长公共前缀长度不大于lenb,继续从下一次位置开始找,至多找两次,如果一直找不到就... 阅读全文

posted @ 2015-04-03 14:19 lienus 阅读(416) 评论(0) 推荐(0)

CF 514C(hash)
摘要:传送门:Watto and Mechanism题意:输入a个字符串和b个待检测字符串。问待检测字符串是否可以由某个已知字符串改变且只改变一个字母得到。分析:字符串hash,枚举待测字符串每一位进行修改,看是否符合,好像正解是trie树。#include #include #include #incl... 阅读全文

posted @ 2015-04-01 18:59 lienus 阅读(247) 评论(0) 推荐(0)

hdu 1029(hash)
摘要:传送门:Ignatius and the Princess IV题意:给n个数,找出出现次数大于等于(n+1)/2的那个数。分析:大水题,排个序输出中间那个即可,这里随便写个HASHMAP找出次数最大那个。#include #include #include #define N 1000010#de... 阅读全文

posted @ 2015-03-10 23:50 lienus 阅读(179) 评论(0) 推荐(0)

SPOJ DISUBSTR(字符串hash)
摘要:传送门:DISUBSTR题意:给定一个字符串,求不同子串个数。分析:由于数据较小,直接枚举长度为1,2...n的所有子串进行hash即可,复杂度(O(n^2)),后缀数组才是正解(O(nlogn)。#include #include #include #include #include #inclu... 阅读全文

posted @ 2015-03-10 19:27 lienus 阅读(166) 评论(0) 推荐(0)

hdu 5183(hash)
摘要:传送门:Negative and Positive (NP)题意:给定一个数组(a0,a1,a2,⋯an−1)和一个整数K, 请来判断一下是否存在二元组(i,j)(0≤i≤j#include #include #include #include #include #include #include ... 阅读全文

posted @ 2015-03-07 23:31 lienus 阅读(677) 评论(0) 推荐(0)

导航