Codeforces 149 E. Martian Strings】的更多相关文章

正反两遍扩展KMP,维护公共长度为L时.出如今最左边和最右边的位置. . .. 然后枚举推断... E. Martian Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output During the study of the Martians Petya clearly understood that the Mart…
Martian Strings 题解: 对于询问串, 我们可以从前往后先跑一遍exkmp. 然后在倒过来,从后往前跑一遍exkmp. 我们就可以记录下 对于每个正向匹配来说,最左边的点在哪里. 对于每个反向匹配来说,最右边的点在哪里. 然后判断可不可以构成这个串就好了. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",stdin);…
Martian Strings Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 149E64-bit integer IO format: %I64d      Java class name: (Any)   During the study of the Martians Petya clearly understood that the Mar…
题目链接:Codeforces 385B Bear and Strings 记录下每一个bear的起始位置和终止位置,然后扫一遍记录下来的结构体数组,过程中用一个变量记录上一个扫过的位置,用来去重. #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int MAX_N = 5000 + 100; char str[MAX_N]; struct Node…
题目链接:Codeforces 482C Game with Strings 题目大意:给定N个字符串,如今从中选定一个字符串为答案串,你不知道答案串是哪个.可是能够通过询问来确定, 每次询问一个位置上字符为多少. 如今你询问的每一个位置的概率是同样的,(问过的位置不会再问).求询问次数的期 望. 解题思路:由于字符串长度不会大于20.所以用二进制表示询问了哪些位置.C[s]即为询问s的位置能够确定多少个字 符串. 这步不能通过枚举s,然后推断处理,复杂度为o(2^20 * 20 * 50),太…
题目链接 给一个字符串s, n个字符串str. 令tmp为s中不重叠的两个连续子串合起来的结果, 顺序不能改变.问tmp能形成n个字符串中的几个. 初始将一个数组dp赋值为-1. 对str做kmp, 然后与串s进行匹配, 看哪些长度的串可以匹配到, 比如说匹配到了长度为j的串, 那么dp[j] = i, i是此时串s的位置. 然后将s和str都反转, 在做一次kmp, 在进行匹配, 对于匹配到的长度j, 看dp[lenStr-j]是否为-1, 如果不为-1, 看lenS-i是否大于等于dp[le…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalen…
Alyona and Strings 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/D Description After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Aly…
A. Vitaly and Strings time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does…
F - Isomorphic Strings 思路:字符串hash 对于每一个字母单独hash 对于一段区间,求出每个字母的hash值,然后排序,如果能匹配上,就说明在这段区间存在字母间的一一映射 代码: #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL long long //#define mp make_pair…