Define the distance between two strings of the same length as the numbers of the positions where the characters differ in these two strings.
If two strings of the same length has a distance of no more than k, we call these two string satisfy k−matching.
Given a string S of length n and a integer k. For each i∈[1,n−1], split S into substrings A and B, while A=S[1,i] and B=S[i+1,n]. For all the string pairs formed by some non empty substring of A and some non empty substrings of B, count the numbers of pairs satisfying k−matching.
给定一个串 S,对于每一个前缀 A 以及对应的后缀 B,问有多少个子串对之间的距离不超过 K。
两个相同长度的串的距离定义为他们不同字符的个数。
#include<bits/stdc++.h> usingnamespace std; #define int long long inlineintread(){int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+ (x<<3)+(ch^48);ch=getchar();}return x*f;} //#define M //#define mo #define N 3010 int n, m, i, j, k; int c[N], cha[N], ans[N]; int f, t, l, len, dif; char s[N];