Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18418   Accepted: 6759 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11542   Accepted: 4962 Description The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousa…
题目网址:http://poj.org/problem?id=1035 思路: 看到题目第一反应是用LCS ——最长公共子序列 来求解.因为给的字典比较多,最多有1w个,而LCS的算法时间复杂度是O(n*m),n,m分别对应两个字符串的长度.还要乘上字典的个数和所要匹配的单词数,不出意外地..超时了. 后面就想到了暴力求解,直接枚举所有情况,先判断字符串长度差是否大于1,大于1的话直接进行下一个循环,否则再继续划分.(len对应字典词长度,l对应要查询的词长度) 假设匹配成功,只会有以下三种情况…
POJ训练计划 Step1-500题 UVaOJ+算法竞赛入门经典+挑战编程+USACO 请见:http://acm.sdut.edu.cn/bbs/read.php?tid=5321 一.POJ训练计划 Moon修订 298道题 集训第一天 POJ纯水题 = =: 17道题 2017 1218 2000 1046 1218 1003 1004 1005 1008 1013(枚举) 1207 1552 2105 2388 1316 2499 3006(筛法求素数) 正式集训计划: 未做  已做 …
Life Forms Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 12484   Accepted: 3502 Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, e…
<题目链接> 题目大意: 就是求k个长度为60的字符串的最长连续公共子串,2<=k<=10 限制条件: 1.  最长公共串长度小于3输出   no significant commonalities 2.  若出现等长的最长的子串,则输出字典序最小的串 解题分析: 将第一个字串的所有子串枚举出来,然后用KMP快速判断该子串是否在所有主串中出现,如果都出现过,那么就按该子串的长度和字典序,不断更新答案,直到得到最终的最优解. #include <cstdio> #incl…
题目链接:http://poj.org/problem?id=1159 题意:给定一个长度为N的字符串.问你最少要添加多少个字符才能使它变成回文串. 思路:最少要添加的字符个数=原串长度-原串最长回文子串长度.对于求原串最长回文子串长度用的是DP的经典问题LCS最长公共子序列的做法. 设原串为S,原串的逆串为S‘,那么原串的最长回文子串长度=S和S'的最长公共子序列长度. 由于N的范围最大是5000,所以5000*5000的数组开不下,所以需要用到滚动数组来求.[关于原串求最长回文子串用的Man…
题目链接:http://poj.org/problem?id=3974 题意:求出给定字符串的最长回文串长度. 思路:裸的Manacher模板题. #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> using namespace std; +; typedef long l…
Spell checker Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u   Java class name: Main [Submit] [Status] [Discuss] Description You, as a member of a development team for a new spell checking program, are to write a m…
链接:http://poj.org/problem?id=2187 Description Bessie, Farmer John's prize cow, has just won first place in a bovine beauty contest, earning the title 'Miss Cow World'. As a result, Bessie will make a tour of N (2 <= N <= 50,000) farms around the wor…
题意:给定一串数字,问你这是一个数字开方根得到的前几位,问你是哪个数字.析:如果 x.123... 这个数字的平方是一个整数的话,那必然sqr(x.124) > ceil(sqr(x.123)) [sqr = 求平方, ceil = 向上取整 所以,就可以从小到大枚举它的整数部分 x ,遇到第一个满足结果的 x,就是答案了. 开始时,我从1开始暴力超时了.. 代码如下: #include <cstdio> #include <string> #include <cstd…
题目 http://poj.org/problem?id=1035 题意 字典匹配,单词表共有1e4个单词,单词长度小于15,需要对最多50个单词进行匹配.在匹配时,如果直接匹配可以找到待匹配串,则直接输出正确信息,否则输出所有满足以下条件的单词: 1. 待匹配串删除任意一个字符后可以匹配的 2. 单词删除任意一个字符后可以匹配的 3. 把待匹配串中某个字符改为单词对应字符后可以匹配的 思路由于单词表容量较小,直接匹配可以直接使用strcmp进行.若直接匹配不成功,那么需要对每个单词进行再次比较…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16675   Accepted: 6087 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
题目网址:http://poj.org/problem?id=3080 思路: 以第一个DNA序列s为参考序列,开始做以下的操作. 1.将一个字母s[i]作为匹配串.(i为当前遍历到的下标) 2.遍历所有序列,看是否是所有序列的公共子串 3.是所有序列的子串的话,再往后增加一个字母,组成一个长度len+1的匹配串(设原先匹配串长度为len),重复步骤2 4.不是所有序列的子串的话,i=len+i;判断len是否大于3,是的话保存子串.len=0;重复步骤1.(为什么 i=len+i呢?因为len…
题意:给定 n 个坐标,问你三个共线的有多少组. 析:这个题真是坑啊,写着 n <= 770,那么一秒时间,三个循环肯定超时啊,我一直不敢写了,换了好几种方法都WA了,也不知道为什么,在比赛时坑我了两个多小时, 最后看到那么多过的,就想试试,真的AC ,三个循环一点没优化,竟然才150多毫秒,....POJ的数据真是水啊. 没什么好说的,只要三个循环,然后判断斜率就好了. 代码如下: #include <cstdio> #include <string> #include &…
题目:http://poj.org/problem?id=1035 还是暴搜 #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack> #include<queue> #include<iomanip> #include<cmath> #include<map> #include&…
题目链接:http://poj.org/problem?id=1035 思路分析: 1.使用哈希表存储字典 2.对待查找的word在字典中查找,查找成功输出查找成功信息 3.若查找不成功,对word增.删.改处理,然后在字典中查询,若查找成功则记录处理后单词在字典中的次序 4.对次序排序再输出 注:对word处理后可能会出现重复,需要进行判断重 代码如下: #include <iostream> using namespace std; ; ; char hashDic[tSize][N];…
Blue Jeans  Time Limit: 1000MS        Memory Limit: 65536K Total Submissions: 21078        Accepted: 9340 Description The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundred…
题目链接 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms. If the word is absent in…
Oulipo [题目链接]Oulipo [题目类型]KMP &题意: 给你两个字符串p和s,求出p在s中出现的次数. &题解: kmpC函数就是解题的,其中也就j=nex[j]难理解一些,j=nex[j]就代表对照的开始,如果j=nex[j]的值是4,就代表从第4个位置开始比较,正如这句话上面的那个j++,你都匹配上了,所以就会有j++,之后便会j大于等于匹配串的长度,这就代表找到了一个和匹配串一样的串,所以ans++,之后再去找该从哪个位置开始匹配 [时间复杂度]\(O(n+m)\) &…
题目链接:http://poj.org/problem?id=2785 大意是输入一个n行四列的矩阵,每一列取一个数,就是四个数,求有多少种着四个数相加和为0的情况 首先脑海里想到的第一思维必然是一个个枚举,用四个for循环,那时间复杂度变成了On4,n的最大值是4000. 肯定会超时.那么,为了简化时间,首先我们可以开两个至少4000*4000的数组分别把第一列与第二列的和的情况 ,第三列与第四列的和的情况存起来.这样就只用考虑两个数组的情况. 然后把两个数组排序,一个数组从头部开始同时另一个…
解题报告 id=3096">题目传送门 题意: 给一个字符串,要求.对于这个字符串空隔为k取字符对(k=0,1,2,3,4...)要求在同样的空隔取对过程汇总.整个字符串中没有一个同样字符对如: ZGBZ: 间隔为0的字符对有: ZG.GB.BZ,三个均不同样 间隔为1的字符对有: ZG. GZ,均不同样 间隔为2的字符对有: ZZ 仅有一个,不必比較. 这样的字符串定义为"surprising". 之后依照格式输出. 思路: map暴力. #include <i…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18693   Accepted: 6844 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
求多个串最长公共子序列,字典序最小输出.枚举剪枝+kmp.比较简单,我用find直接查找16ms #include<iostream> #include<string> #include<algorithm> using namespace std; string s[61]; int main() { int ta; cin>>ta; int n; while(ta--) { cin>>n; string ans; for(int i=0;i&…
思路: 线段树 (分类讨论) 此题数据很水 数据很水 数据很水 但是卡个暴力还是没问题的-- //By SiriusRen #include <cstdio> #include <cstring> using namespace std; #define maxn 1500000 #define inf 1061109567 int n,tot,jy,xx,yy,tree[maxn*6],vis[maxn],cases,q[maxn]; inline int min(int x,i…
Channel Allocation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13357   Accepted: 6836 Description When a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receiver has a s…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16868   Accepted: 6393   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
Flip Game Time Limit: 1000MS  Memory Limit: 65536K  Total Submissions: 4863  Accepted: 1983 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the oth…
题意:一个人要从2先走到4再走到3,计算最少路径. 析:其实这个题很水的,就是要注意,在没有到4之前是不能经过3的,一点要注意.其他的就比较简单了,就是一个双向BFS,先从2搜到4,再从3到搜到4, 然后求最短路即可. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstr…
在输入的单词中删除或替换或插入一个字符,看是否在字典中.直接暴力,172ms.. #include <stdio.h> #include <string.h> ]; ][], s[]; bool del(char s1[], char s2[]) { ; , j = ; s1[i] && s2[j]; i++, j++) { if(s1[i] != s2[j]) { if(isdel) ; j--; isdel = ; } } ; } bool rep(char s…