POJ 1936 All in All(串)】的更多相关文章

All in All Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 27537 Accepted: 11274 Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way…
1.链接地址: http://poj.org/problem?id=1936 http://bailian.openjudge.cn/practice/1936 2.题目: All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 26651   Accepted: 10862 Description You have devised a new encryption technique which encod…
All in All 题目链接:http://poj.org/problem?id=1936 题目大意:判断从字符串s2中能否找到子串s1.字符串长度为10W. Sample Input sequence subsequence person compression VERDI vivaVittorioEmanueleReDiItalia caseDoesMatter CaseDoesMatter Sample Output Yes No Yes No 分析:这明明是模拟题,有人竟然把它归为动态…
题目链接:http://poj.org/problem?id=1936 思路分析:字符串子序列查找问题,设置两个指针,一个指向子序列,另一个指向待查找的序列,查找个字符串一次即可判断.算法时间复杂度O(N). 代码如下: #include <cstdio> #include <cstring> using namespace std; #define MAX_LEN 100000 + 1 char s[MAX_LEN], t[MAX_LEN]; bool to_find(const…
题目 http://poj.org/problem?id=1936 题意 多组数据,每组数据有两个字符串A,B,求A是否是B的子串.(注意是子串,也就是不必在B中连续) 思路 设置计数器cnt为当前已匹配A的长度,明显在扫描B的过程中只需要记住cnt这一个状态. 扫描B,每次与A[cnt]匹配就将计数器增加1,cnt与A的长度一致时A就是B的子串. 感想 这道题也许可以用更复杂的方法. 代码 #include <cstdio> #include <cstring> #include…
All in All Time Limit: 1000 MS Memory Limit: 30000 KB 64-bit integer IO format: %I64d , %I64u   Java class name: Main [Submit] [Status] [Discuss] Description You have devised a new encryption technique which encodes a message by inserting between its…
题意:添加最少的字符使之成为回文串 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> using namespace std; ; int n,m,t; short dp[maxn][maxn]; char s[maxn]; int main() { int i,j,k; #…
题目链接:http://poj.org/problem?id=3461 题意:给你两个字符串word和text,求出word在text中出现的次数 思路:kmp算法的简单应用,遍历一遍text字符串即可,当前匹配的字符数达到word字符串的长度,即可确定word字符串出现一次了. code: #include <cstdio> #include <cstring> using namespace std; ; ; char word[MAXM]; char text[MAXN];…
Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generat…
题意:给你两个字符串p和s,求出p在s中出现的次数. 显然,我们要先把模式串放到前面,之后主串放后面,中间隔开,这样就可以根据前缀数组的性质来求了. 我先想直接把p接到s前面,之后求Next数组对strlen(p)取余==0的就可以,之后WA.最后发现A AASSAAS的时候有bug,只有又想到在p和s中间加个不可能出现的字符'$'就可以了,接着就A了. #include <bits/stdc++.h> using namespace std; const int INF=0x3f3f3f3f…