4044: [Cerc2014] Virus synthesis Time Limit: 20 Sec Memory Limit: 128 MB Description Viruses are usually bad for your health. How about fighting them with... other viruses? In this problem, you need to find out how to synthesize such good viruses. …
manacher魔改,hash+二分都好写,但是我魔改了个回文自动机就写自闭了orz 根本上来说只要把==改成!=即可,但是这样一来很多停止条件就没了,需要很多特判手动刹车,最后统计一下size即可 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=500005; int n,ch[N][2],fa[N],dis[N],si[N],con=1,la…
我们预处理出来以i为结尾的最长回文后缀(回文自动机的构建过程中就可以求出)然后就是一个区间覆盖,因为我懒得写贪心,就写了线段树优化的DP. #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; const int N=101010; const int INF=1e9; int L…
https://www.lydsy.com/JudgeOnline/problem.php?id=2565 正着构造回文自动机 倒过来再构造一个回文自动机 分别求出以位置i开始的和结尾的最长回文串 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define N 100001 char ss[N]; int s[N]; int L1[N],L2[N]; struct…
https://www.lydsy.com/JudgeOnline/problem.php?id=3676 回文自动机模板题 4年前的APIO如今竟沦为模板,,,╮(╯▽╰)╭,唉 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define N 300001 char ss[N]; int s[N]; ,last; int fail[N],len[N],cnt[N…
回文自动机板子 或者是SAM+manacher+倍增,就是manacher求本质不同回文串(让f++的串),然后在SAM倍增查询对应点出现次数 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=300005; int n,ch[N][27],fa[N],si[N],dis[N],la=1,con=1; long long ans; char s[N…
传送门: [1]:BZOJ [2]:洛谷 •题意 求串 s 中出现的所有奇回文串,并按照长度由大到小排序: 输出前 k 个奇回文串的乘积 mod 19930726; 如果奇回文串的个数不足 k 个,输出 -1: •题解 将串 s 跑一边回文自动机: 将求解出的 len,cnt 数组存入一个结构体中并按照 len 由大到小排序: 将前 k 个奇回文串的长度相乘就行: 记得用快速幂,并且只要奇回文串的长度乘积: •Code #include<bits/stdc++.h> using namespa…
Palindromes and Super Abilities 2 题目链接: http://acm.hust.edu.cn/vjudge/contest/126823#problem/E Description Dima adds letters s 1, -, s n one by one to the end of a word. After each letter, he asks Misha to tell him how many new palindrome substrings…