CF 1131 E. String Multiplication】的更多相关文章

E. String Multiplication 题意 分析: 从后往前考虑字符串变成什么样子. 设$S_i = p_1 \cdot p_2 \dots p_{i}$,最后一定是$S_{n - 1} \cdot p_n$,就是将$S_{n-1}$每两个字符之间放入$p_n$.按照$p_n$分类讨论,那么最后有三种情况. 设$p_n$的开头字符是$c0$,结尾字符是$c1$,包含开头的连续段的长度是$len0$,包含结尾的连续段的长度是$len1$. 1.$c0 \neq c1$,那么答案可以是三…
题意: 给定一系列字符串,每次都是后一个字符串和前面的融合,这个融合操作就是原来的串分成独立的,然后把新串插入到这些空格中.问最后,最长的相同连续的长度. 思路: 这道题可以贪心的来,我们压缩状态,记录串中每个字母对应最长的长度.然后分类讨论处理就行了. #include <algorithm> #include <iterator> #include <iostream> #include <cstring> #include <cstdlib>…
Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Description Input Output Print exactly one integer — the beauty of the product of the strings. Sample Input 3aba Sample Output 3 题解:这个题的思维难度其实不大,需要维护什么东西很容易想到,或…
E. String Multiplication time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Roman and Denis are on the trip to the programming competition. Since the trip was long, they soon got bored, and h…
这题难度2200,应该值了. 题目链接:CF原网 题目大意:定义两个字符串 $s$ 和 $t$($s$ 的长度为 $m$)的乘积为 $t+s_1+t+s_2+\dots+t+s_m+t$.定义一个字符串的美丽度为最长的相同字母连续子序列的长度.现在给出 $n$ 个字符串 $p_i$,问 $((p_1p_2)p_3)\dots p_n$ 的美丽度. $1\le n\le 10^5,\sum|p_i|\le 10^5$. 官方题解讲的很复杂,但看起来也就是个暴力大模拟,跟我的做法差不多. 为叙述方便…
You are given three integers a, b and x. Your task is to construct a binary string s of length n=a+b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1≤i<n) such that si≠si+1. It is guaranteed that the answer always…
Description You have a string ss of length nn consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >,…
在校内OJ上A了,没有加强制在线的东西..不放链接了. 这道题题意是维护一个字符串集合,支持三种操作: 1.加字符串 2.删字符串 3.查询集合中的所有字符串在给出的模板串中出现的次数 操作数\(m \le 3*10^5\),输入字符串总长度\(maxL \le 4*10^6\) 对于查询想到了要用AC自动机.但是还要插入和删除,每次插入一个字符串都得重构fail指针,删除更不可做. 对于删除,我们可以新建一颗代表删除的字符串集合的AC自动机,这样查询只要两个AC自动机的值相减即可. 对于插入,…
传送门 如果没有碍事的?的话,判定字符串的循环节直接用KMP的失配数组就可以搞定.现在有了碍事的?,我们就需要考虑更通用的算法. 考虑KMP失配数组判定字符串循环节的本质,发现判定\(k\)是否为字符串的循环节等价于判定字符串在右移\(k\)位后能否和原字符串匹配(只考虑二者重叠的部分). 我们不妨先把?直接看成一个可以匹配任何字符的通配符,而解决带通配符的字符串匹配问题的一个算法就是FFT. (以下默认下标为\(0\)~\(n-1\)) 设字符串为\(s\),因为字符集只有\(2\),不妨直接…
题目传送门 先把 = 的人用并查集合并在一起. 然后 < > 的建边, 跑一遍 toposort 之后就好了. 入度为0点的值肯定为1, 然后就是因为这个是按照时间线走过来的,所以一个点的最小值,就是在入队的那一刻确定的, 即入度为0的时候,值就是现在的值+1. 注意就是不要同一个点入队多次. 代码: /* code by: zstu wxk time: 2019/02/24 */ #include<bits/stdc++.h> using namespace std; #defi…