- 博客(11)
- 收藏
- 关注
原创 SPOJ - DISUBSTR(后缀数组)
不相同的子串的个数给定一个字符串,求不相同的子串的个数。算法分析:每个子串一定是某个后缀的前缀,那么原问题等价于求所有后缀之间的不相同的前缀的个数。如果所有的后缀按照 suffix(sa[1]), suffix(sa[2]),suffix(sa[3]), …… ,suffix(sa[n])的顺序计算,不难发现,对于每一次新加进来的后缀 suffix(sa[k]),它将产生 n-sa[k...
2020-03-31 22:56:17 96
原创 后缀数组讲解
1.DC3#include <cstdio>#include <cstring>#include<iostream>#include <algorithm>#define F(x) ((x) / 3 + ((x) % 3 == 1 ? 0 : tb))#define G(x) ((x) < tb ? (x) * 3 + 1 : ((...
2020-03-31 22:53:39 184
原创 回文树(回文自动机)
讲解:https://blog.csdn.net/lwfcgz/article/details/48739051代码:https://www.cnblogs.com/DWVictor/p/11324247.htmlconst int MAXN = 100005 ; const int N = 26 ; struct Palindromic_Tree { //cnt最后co...
2020-03-28 00:32:39 99
原创 Codeforces Global Round 7 D2. Prefix-Suffix Palindrome (Hard version)(马拉车 回文自动机)
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<queue>using namespace std;const int N=1e6+100;char ss[N];char s[N*2];char str[N];...
2020-03-27 23:43:02 89
原创 Codeforces Global Round 7 E. Bombs(线段树)
题目:给你一个置换,p1,p2,…,pn。假设排列的某些位置包含炸弹,这样至少存在一个没有炸弹的位置。对于某些固定的炸弹配置,请考虑以下过程。最初,有一个空集合,A。对于从1到n的每个i:将pi添加到A。如果第i个位置包含炸弹,请移除a中最大的元素。处理完成后,A将为非空。炸弹的配置成本相当于A中最大的元素。给你另一个置换,q1,q2,…,qn。对于每个1≤i≤n,求出炸弹配置的成本,使得在q...
2020-03-27 19:00:06 128
原创 Educational Codeforces Round 84 D. Infinite Path(思维 置换群)
思路:从i->p[i]连一条边 会形成若干个环。最后结果需要每个环的颜色都相同p^k相当于环中的点沿边的方向走k条边,走过的点形成形成一个新的 环。枚举环的长度l的约数,检查形成的新的环颜色是否相同。#include<cstring>#include<iostream>#include<algorithm>#include<vector...
2020-03-27 11:26:38 89
原创 Educational Codeforces Round 84 E. Count The Blocks(思维 计数)
题目:你写下了从0到10^n-1的所有整数,并用前导零填充它们,使它们的长度正好是n。例如,如果n=3,那么你写下了000,001,…,998,999。整数x中的块是一个连续的等号段,不能向左或向右扩展。例如,在整数00027734000中,有三个长度为1的块、一个长度为2的块和两个长度为3的块。对于从1到n的所有整数,计算写下的整数中长度为i的块的数量。由于这些整数可能太大,请将它们按模块9...
2020-03-27 10:47:51 187
原创 树形dp+状态
1.没有上司的舞会一条边上最多选择一个点#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>using namespace std;int num[6100];int deg[6100];int dp[6100][2];int h[6100],...
2020-03-27 10:25:05 107
原创 背包问题
1.01背包#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int dp[1010];int v[1010];int w[1010];int main(){ int n,V; cin>>...
2020-03-26 22:51:19 62
原创 数字转换
数论常用技巧:求倍数比求约数简单。```cpp#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;const int N=1e5+10;int d1[N],d2[N],st[N];int h[N],e[N...
2020-03-26 19:37:20 103
原创 树的中心 树的最长路径
这两道题都做过很多遍了。再次做发现了很多以前没注意到的问题。;1.求树的中心的时候,两次dp后,需要重新遍历所有点求ans。如果在求up时求ans会忽略根节点。2.如果边的权值为负,有很多细节需要考虑。要注意是必须到其他点,还是可以到自己。```cpp#include <cstring>#include <iostream>#include <alg...
2020-03-26 16:22:36 93
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人