POJ - 1743 顺着原字符串找到所有叶子节点,然后自下而上更新,每个节点right的最左和最右,然后求出答案. #include<cstdio> #include<cstring> #include<algorithm> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI p…
POJ 3518 Boring Problem : 给一个串S,询问串S有多个子串出现至少两次且位置不重叠. Solution : 对S串建立后缀自动机,再建立后缀树,dfs一遍统计处每个结点的子树中最长节点max和最短节点min.枚举一遍后缀自动机的节点,那么对于其对应后缀的长度要求为小于等于max - min. #include <iostream> #include <algorithm> using namespace std; const int N = 1000008;…
Musical Theme Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 30941 Accepted: 10336 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the…
A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this representation of melodies ignores the notion of musical timing; b…
#include<stdio.h> #include<string.h> #include<algorithm> #define maxn 30000 using namespace std; int n; int jilu[maxn]; int wa[maxn],wb[maxn],wv[maxn],ws[maxn],r[maxn],sa[maxn],rankk[maxn],height[maxn];//r数组是将原始字符串进行整数化 int cmp(int *r,in…