UVA 257 Palinwords(hash)题解】的更多相关文章

UVA 257 - Palinwords 题目链接 题意:输出一个文本里面的palinword,palinword的定义为.包括两个不同的回文子串,而且要求回文子串不能互相包括 思路:对于每一个单词推断一次.因为不能互相包括.对于每一个位置.事实上就仅仅要找长度3和4的情况就可以,这样复杂度为O(n),至于推断反复的.就用hash就可以 代码: #include <cstdio> #include <cstring> char str[260]; int hash[555555],…
思路:给你字符串,如果他包含至少两个长度大于等于3的回文,并且这些回文不能嵌套(例如aaa嵌套在aaaa,waw嵌套在awawa),如果这个字符串这么牛逼的话,就输出他. 思路:拿到字符串先正序hash和逆序hash,用来判断回文串.这里其实只要判断长度为3和4的回文就行,因为3,4大的可以嵌套在比他大的里面.一开始我还在想怎么区分aaa和aaaa,弄了个很复杂的东西,但是我发现其实只要储存回文串的半径的hash就行了!这样长度3和4也能比了. 代码: #include<stack> #inc…
Judging Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=114147 Description The NWERC organisers have decided that they want to improve the automatic grading of the submissions for the contest,…
题目大意: 有若干模式串,将某些模式串拼接起来(一个可以使用多次)形成一个长模式串,判断能否有两种或更多种不同的拼法拼成相同的模式串. 思路: 神奇的构图,暴力的求解. 可以发现,若有不同的拼法,则一个模式串的前缀要与一个模式串的后缀相同. 因此我们就将问题转化成:从两个模式串开始,不停的按照前后缀匹配,最后达到两个串同时在一个点结束. 那么,将每一个串的每一个字符都看作一个点,n2len2暴力枚举i串从z开始的后缀和j串(自己也可以,但不能让前缀是其本身)的前缀做匹配,看是否能将其中一个串匹配…
Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the chi…
所谓"周界搜索",练习搜索的好题,双向宽搜/迭代加深均可,还有很多细节有待完善,判重有比set更优的结构,宽搜还没写,先存一下. //Writer:GhostCai && His Yellow Duck #include<iostream> #include<string> #include<set> #include<queue> using namespace std; set<string> book;…
The decimal expansion of the fraction 1/33 is 0.03, where the 03 is used to indicate that the cycle 03 repeats indefinitely with no intervening digits. In fact, the decimal expansion of every rational number (fraction) has a repeating cycle as opposed…
Prime Words A prime number is a number that has only two divisors: itself and the number one. Examples of primenumbers are: 1, 2, 3, 5, 17, 101 and 10007.In this problem you should read a set of words, each word is composed only by letters in the ran…
Less Prime Let n be an integer, 100 n 10000, nd the prime number x, x n, so that n…
前者之所以叫加强版,就是把uva1027改编了,附加上打印路径罢了. 03年的final题哦!!虽然是水题,但不是我这个只会做图论题的跛子能轻易尝试的——因为有个数学坑. 题意:运送x个货物从a->b,沿途要上交过路费,village(小写字母)只需交一个单位的货物,town(大写字母)要交(x/20+((x%20==0)?0:1))个单位的货物,即每20个货物要上交一个,不足的按20处理.现在已知要送到b点y个货物,那么最少从x出发要携带多少个货物. 注意: 1.路过town:19=20-1,…