/* HDU 6078 - Wavel Sequence [ DP ] | 2017 Multi-University Training Contest 4 题意: 给定 a[N], b[M] 要求满足 a[f(1)]<a[f(2)]>a[f(3)]<a[f(4)]>a[f(5)]<a[f(6)]... b[g(i)] == a[f(i)] f(i) < f(i+1), g(i) < g(i+1) 的子序列 的数目 分析: dp[i][j][0] 表示 以a[i]…
题 OvO http://acm.hdu.edu.cn/showproblem.php?pid=6078 (2017 Multi-University Training Contest - Team 4 - 1012) 解 记f[i][j][k]为在s1中以第i位结尾,s2中以第j为结尾,末端状态(上升为1,下降为0)为k的子序列的个数 则f[i][j][k]=∑f[p][q][1-k]  (p<i,q<j,而且新加入的点要使原序列结尾状态发生变化) 可见这是和矩阵差不多的东西 可以把这个当做…
Wavel Sequence Problem Description Have you ever seen the wave? It's a wonderful view of nature. Little Q is attracted to such wonderful thing, he even likes everything that looks like wave. Formally, he defines a sequence a1,a2,...,an as ''wavel'' i…
题目链接 Problem Description Have you ever seen the wave? It's a wonderful view of nature. Little Q is attracted to such wonderful thing, he even likes everything that looks like wave. Formally, he defines a sequence a1,a2,...,an as ''wavel'' if and only…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6078 题意:求两个序列的公共波形子序列的个数. 解法: 类似于最长公共上升子序列,对于每个i,只考虑存在j使得a[i]==b[j]的情况. dp[i][j][0]表示以a[i]和b[j]为公共序列结尾且为波谷的情况总和. dp[i][j][1]则表示波峰的情况总和. S[i][j][0]表示sum(dp[k][j][0] | 1<=k<=j-1). S[i][j][1]则表示sum(dp[k][j…
/* HDU 6047 - Maximum Sequence [ 单调队列 ] 题意: 起初给出n个元素的数列 A[N], B[N] 对于 A[]的第N+K个元素,从B[N]中找出一个元素B[i],在 A[] 中找到一个数字A[p]满足 B[i] <= p <= N+K-1 令 A[N+K] = A[p]-p,直到A[]的长度等于2N 问 A[N+1] + A[N+2] + ... + A[N<<1] 最大是多少 分析: 将A[]中元素全部减去其下标 将B[]排序,可分析一定是从小…
/* HDU 6170 - Two strings [ DP ] | 2017 ZJUT Multi-University Training 9 题意: 定义*可以匹配任意长度,.可以匹配任意字符,问两串是否匹配 分析: dp[i][j] 代表B[i] 到 A[j]全部匹配 然后根据三种匹配类型分类讨论,可以从i推到i+1 复杂度O(n^2) */ #include <bits/stdc++.h> using namespace std; const int N = 2505; int t;…
Distinct Values Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2298    Accepted Submission(s): 740 Problem Description Chiaki has an array of n positive integers. You are told some facts about…
CRB and Tree                                                             Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)                                                                                            To…
题意: 有三种操作: 1 x y: 表示给x位置加上y 2 x y:查询[x,y]的区间和 3 x y:将 [x,y] 区间上的数变为最接近的 Fibonacci. 思路: 1 操作按正常单调更新,区间求和的操作. 2 操作按正常区间求和. 3  如果是之前该区间未被 第三类操作操作过,则更新到底,如果之前已经被第三类操作操作过则直接返回. 这里要打一个标记,要注意 在第1类操作单点加时要把标记往下更新. #include<cstring> #include<algorithm>…