题意: 求两个串的最大$LCS$。 思路: 把第一个串建后缀自动机,第二个串跑后缀自动机,如果一个节点失配了,那么往父节点跑,期间更新答案即可。 代码: cpp include include include include include include include include inclu ...
分类:
其他好文 时间:
2019-10-13 19:14:46
阅读次数:
119
题意: 求$n$个串的最大$LCS$。 思路: 把第一个串建后缀自动机,然后枚举所有串。对于每个串,求出这个串在$i$节点的最大匹配为$temp[i]$(当前串在这个节点最多取多少),然后我们求出最终所有串在$i$节点的匹配最小值$mn[i]$(即为所有串在$i$节点都能取到多少),答案即为$max ...
分类:
其他好文 时间:
2019-10-13 18:31:33
阅读次数:
109
1 using namespace std; 2 typedef pair<int,int> P; 3 typedef long long ll; 4 #define _for(i,a,b) for(register int i = (a);i < b;i ++) 5 #define _rep(i,... ...
分类:
其他好文 时间:
2019-10-13 13:26:35
阅读次数:
121
题目链接: https://vjudge.net/problem/SPOJ-LCS 题意: 最多10行字符串 求最大公共子序列 数据范围: $1\leq |S| \leq100000$ 分析: 让他们都和第一个字符串匹配,算出每个字符串与第一个字符串的,以$i$位置(i指的是在s1中的位置)结尾匹配 ...
分类:
其他好文 时间:
2019-10-07 19:27:35
阅读次数:
77
题目链接 题意: 给定n个数,q次询问,查询当前区间最大值与最小值的差值 题解: 线段树模板题 区间查询最大值、最小值 代码: #include<iostream> #include<stdio.h> #include<math.h> #include<algorithm> #include<vec ...
分类:
其他好文 时间:
2019-10-03 16:26:04
阅读次数:
52
110. Balanced Binary Tree Easy Easy Easy Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is d ...
分类:
其他好文 时间:
2019-10-02 10:23:19
阅读次数:
88
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the dep ...
分类:
其他好文 时间:
2019-09-25 12:15:45
阅读次数:
93
题意 求 $\sum_{i=1}^nlcm(i,n)$ 。 传送 "Luogu" "SPOJ" 分析 原式可以化为 $$\sum_{i=1}^n\frac{i n}{gcd(i,n)}$$ 由于 $gcd(i,n)=gcd(n i,n)$ ,可将原式变形为 $$\frac{1}{2}(\sum_{i ...
分类:
其他好文 时间:
2019-09-21 12:20:50
阅读次数:
83
https://vjudge.net/problem/SPOJ-DQUERY 此题连接; 题目大意:给出一个n个数的序列; 接下来有k个询问,每一次询问某一区间里的不同数的个数; 莫队思想:分块 排序 暴力;先将所有询问存储起来,然后玄学排序降低复杂度; ...
分类:
其他好文 时间:
2019-09-18 00:39:35
阅读次数:
96
【TimeGate】 https://www.luogu.org/problem/P3608 【解题思路】 单点修改+区间查询,用树状数组来维护f数组即可 【code】 ...
分类:
其他好文 时间:
2019-09-15 01:24:26
阅读次数:
93