题目链接: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),太…
http://codeforces.com/problemset/problem/150/B 题意: 给出n,m,k,n表示字符串的长度为n,m表示字符种类个数,k表示每k个数都必须是回文串,求满足要求的不同字符串有多少种. 思路:分奇偶推一下,当k为偶数时,容易发现如果n=k,那么有最多有k/2种不同的字符可填,如果n>k,你会发现此时所有位置都必须一样. 奇数的话会稍微麻烦一点,如果n=k,那么最多有k/2+1种不同的字符可填,如果n>k,你会发现此时最后只有2中不同的字符可填. #inc…
假设 k = 5 , n>k ,   (1,2,3,4,5)  -> 1=5,2=4,3任意 (2,3,4,5,6) -> 2=6,3=5,4任意...综合上面的可得出1=3=5,2=4=6 (3,4,5,6,7) -> 3=7,4=6,5任意...综合上面的可得出1=3=5=7,2=4=6 .......                 综上可得..奇数位的数应该相同,偶数位的数应该相同 再假设k = 4,   n>k     (1,2,3,4) - >1=4,2=3…
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…
正反两遍扩展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…
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…
You are given n strings ti. Each string has cost ci. Let's define the function of string , where ps, i is the number of occurrences of s in ti, |s| is the length of the string s. Find the maximal value of function f(s) over all strings. Note that the…