题解 UVA12206 【Stammering Aliens】】的更多相关文章

Dr. Ellie Arroway has established contact with an extraterrestrial civilization. However, all efforts to decode their messages have failed so far because, as luck would have it, they have stumbled upon a race of stuttering aliens! Her team has found…
题意 求一个串中出现至少m次的子串的最大长度,对于最大长度,求出最大的左端点 题解 本来想练哈希的,没忍住就写了一个SAM SAM拿来做就很裸了 只要检查每个节点的right集合大小是否不小于m,然后step[u]就表示u节点所代表字符串的最大长度 为了求出端点,我们还需要记录right集合的最大值 然后就水过啦 #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #in…
思路 可以二分答案+哈希 判断有没有那个长为L的串出现至少m次即可 代码 #include <cstdio> #include <cstring> #include <algorithm> #include <map> using namespace std; int n,m; const int base = 131; unsigned long long hashx[80000],power[80000]; int ans=0,lastans=0; ch…
UVA 12206 - Stammering Aliens 题目链接 题意:给定一个序列,求出出现次数大于m,长度最长的子串的最大下标 思路:后缀数组.搞出height数组后,利用二分去查找就可以 这题之前还写过hash的写法也能过,只是写后缀数组的时候,犯了一个傻逼错误,把none输出成node还一直找不到...这是刷题来第二次碰到这样的逗比错误了,还是得注意. . 代码: #include <cstdio> #include <cstring> #include <alg…
Stammering Aliens Time Limit: 2000MS   Memory Limit: 65536K       Description Dr. Ellie Arroway has established contact with an extraterrestrial civilization. However, all efforts to decode their messages have failed so far because, as luck would hav…
终于A了这道题啊(坑啊) 教练说:这道题不能用map吧,复杂度不一个O(nlogn)吗 于是我就一直想不出来,然后看题解代码,一看就是map... 所以我就在想,那复杂度是不是也不是O(nlogn)呢 教练看了半天,说:好像确实不是诶 原来阻挡我的最大障碍是教练啊!!!(当时只给题面,也不知道时限) 看到这道题题面,找最长,位置又是有序的,肯定就能想到二分(然而我脑抽,想了几分钟才想到) 然后check里怎么写呢,这是最大的问题 能不能直接判断两者相不相等呢,我们可以使用字符串哈希!!!(这就不…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=4080 Description Dr. Ellie Arroway has established contact with an extraterrestrial civilization. However, all efforts to decode their messages have failed so far because, as luck would have it, the…
题意:找一个出现了m次的最长子串,以及这时的最右的位置. hash的话代码还是比较好写的,,但是时间比SA多很多.. #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; + ; typedef long long ll; ; ; char s[N]; int m,len,pw[N]; int H[N],pos; struct node { int id,hash…
题目传送门 题意:训练指南P225 分析:二分寻找长度,用hash值来比较长度为L的字串是否相等. #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int N = 4e4 + 5; const int x = 123; ull H[N], _hash[N], xp[N]; int rk[N]; char str[N]; int m; void get_hash(char *s…
体验了一把字符串Hash的做法,感觉Hash这种人品算法好神奇. 也许这道题的正解是后缀数组,但Hash做法的优势就是编码复杂度大大降低. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; + ; ; int n, m, pos; unsigned long long H[maxn], xp[maxn]; unsigned long long hash[maxn]…