codeforces 808G Anthem of Berland】的更多相关文章

codeforces 808G Anthem of Berland 题面 给定\(s\)串和\(t\)串,字符集是小写字母.\(s\)串中有些位置的值不确定,要求你确定这些位置上的值,使得\(t\)在\(s\)中出现次数最多,输出最多出现次数. 参考博客 http://www.cnblogs.com/Oncle-Ha/p/7061929.html 题解 AC自动机预处理 \(ne[i][j]\):字符串 \(t[i]+j\) 的后缀最长匹配到 \(t[ne[i][j]]\). 状态\(f[i][…
题目传送门 传送点I 传送点II 传送点III 题目大意 给定一个字符串$s$,和一个字符串$t$,$t$只包含小写字母,$s$包含小写字母和通配符'?'.询问$t$可能在$s$中出现最多多少次. 原来觉得挺神仙,现在觉得还好. 显然用$g_{i}$表示在匹配到第$i$个字符,最多能匹配$t$的次数. 现在讨论它的转移,需要考虑它和前一个匹配有没有重叠. 如果没有重叠,直接从$g_{i - |t|}$转移. 如果有重叠,上一个可能的匹配的结束位置显然是可以枚举的,通过跳$fail$就能找到.我们…
题意 给定一个字符串 \(s\) ,一个字符串 \(t\) ,其中 \(s\) 包含小写字母和 "?" ,\(t\) 只包含小写字母,现在把 \(s\) 中的问号替换成任意的小写字母,求 \(t\) 最多在 \(s\) 中出现多少次,\(t\) 可以互相覆盖. \(1 \leq |s| \leq 10^5\) \(1 \leq |t| \leq 10^5\) \(1 \leq |s|\cdot|t| \leq 10^7\) 思路 由于 \(|s|\cdot|t| \leq 10^7\)…
LINK 简要题意 给你一个串s,上面有字母和一些通配符,问你将通配符换成字母之后最多可以出现多少次串t 首先有一个很傻子的做法就是\(dp_{i,j}\)表示s到第i个位置匹配t串前j个字符的完整t串个数 然后每次枚举前缀看看能不能转移...太不优秀了 那么就考虑这样做: \(dp_{i}\)表示最后一个出现的完整的串t在第i个位置结尾的最大出现次数 \(maxv_{i}\)表示最后一个出现的完整的串t在第i个位置前结尾的最大出现次数 首先有一个转移是,如果当前位置被匹配,那么\(dp_{i}…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
A. Parliament of Berland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamen…
题目链接: http://codeforces.com/problemset/problem/691/A 题目大意: n个数0或1,要求恰好n-1个1,如果n为1则那个数一定要是1 题目思路: [模拟] 水题一道.看错题目两次.. // //by coolxxx //#include<bits/stdc++.h> #include<iostream> #include<algorithm> #include<string> #include<ioman…
C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.…
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary fro…
水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> #include<vector> #include<map> #include<set> #in…