随笔分类 - hash
摘要:noip模拟题day1 总览(Overview) 题目名称 取模 等比数列 回文串 程序名 mod sequence palindromes 输入文件名 mod.in sequence.in palindromes.in 输出文件名 mod.out sequence.out palindromes.
阅读全文
摘要:1.铺瓷砖(tile.cpp/c/pas)【问题描述】有一面很长很长的墙。 你需要在这面墙上贴上两行瓷砖。 你的手头有两种不同尺寸的瓷砖,你希望用这两种瓷砖各贴一行。瓷砖的长可以用分数表示,贴在第一行的每块瓷砖长度为 AB ,贴在第二行的每块瓷砖长度为CD 。本问题中你并不需要关心瓷砖的宽度。如上图
阅读全文
摘要:/* poj 1200 Crazy Search 字符串hash O(n)枚举起点 然后O(1)查询子串hash值 然后O(n)找不一样的个数 复杂度是线性的 */ #include #include #include #include #define P 29 #define maxn 1000010 using namespace std; int n,c,len,p[maxn],ha[...
阅读全文
摘要:/*COGS 610 */ #include #include #include #define mod 23333 #define maxn 200010 using namespace std; int a[maxn],n,c,head[maxn],cnt[maxn],num,ans; struct node{ int v,pre; }e[maxn]; void Insert(int...
阅读全文
摘要:/* 暴力查分 n*n */ #include #include #include #define maxn 100010 using namespace std; int n,m,a[maxn],ans,p[maxn][31],r[31]; int main() { scanf("%d%d",&n,&m); for(int i=1;i #include #include #i...
阅读全文
摘要:/* 这题10^8的暴力可以出答案 但是 慢..... 有个小小的bug 出题人卡int 却没注意short 用short可以不用hash 直接搞 49428K 313MS */ #include #include #include #define base 12500000 using namespace std; int a1,a2,a3,a4,a5,x1,x2,x3,x4,x5,ans; ...
阅读全文
摘要:开始按hash做的 交上去就wa 但是和标称拍了半天也没有不一样的 可能是生成的数据太水了吧... #include #include #include #define maxn 100010 #define mod 10000007 #define ll long long using namespace std; ll ha; int n,a[maxn][6],base,J[7]; bool...
阅读全文
摘要:/*普通的hsah 由于元素太多 空间很小..hash碰撞很厉害.30分*/ #include #include #include #include #define maxn 100010 #define mod 2000007 #define hs 117 using namespace std; int n,l,k,cnt,f[mod+10],l1[maxn],l2[maxn]; char ...
阅读全文
摘要:/* Bfs+Hash 跑的有点慢 但是codevs上时间限制10s 也ok */ #include #include #include #include #define maxn 10000010 using namespace std; int len; bool f[maxn]; string ls,rs; struct node { int step,place; st...
阅读全文
摘要:/* 手打的哈希+线性的维护 第一问:hash一下 并且用个h记录某个单词要背的 第二问:线性的跑一边 开始队列里装下前一些单词使这一坨符合要求 并且记录出现次数num 然后开始从前面删 删除的条件:要么是非法的单词(h值为0) 要么num值大于1 如果删不了就在进来一个 更新num 直到跑完 这过程中每次更新l 注意这样有极端数据 如果第一问答案为 0 需要特判...
阅读全文

浙公网安备 33010602011771号