Solution
对于以第 个字符结尾的最长色彩丰富串,如果第 个字符和第 个字符一样或有一个是 V,那么就要重组字符串,长度为 ,否则长度为以第 个字符结尾的最长色彩丰富串加一,所以考虑 DP。
上面已经讲了 DP 转移式,按上面模拟并在过程中取最大值,最大值就是答案。
Code
code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef double db;
typedef __int128 i128;
const ll inf=9e18;
const i128 Inf=1e35;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}