0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:31:59 +00:00
Baoshuo Ren 2022-02-07 21:19:45 +08:00
parent fb2ad001de
commit d14c69a1bf
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

40
AcWing/899/899.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <algorithm>
#include <cstring>
#include <iostream>
using std::cin;
using std::cout;
#define endl '\n'
int n, m, q, f[15][15];
char s[1005][15], qs[15];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> s[i] + 1;
}
while (m--) {
int ans = 0;
cin >> qs + 1 >> q;
for (int k = 1; k <= n; k++) {
memset(f, 0x00, sizeof(f));
int n = strlen(s[k] + 1),
m = strlen(qs + 1);
for (int i = 1; i <= n; i++) {
f[i][0] = i;
}
for (int i = 1; i <= m; i++) {
f[0][i] = i;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
f[i][j] = std::min({f[i - 1][j] + 1, f[i][j - 1] + 1, f[i - 1][j - 1] + (s[k][i] != qs[j])});
}
}
if (f[n][m] <= q) ans++;
}
cout << ans << endl;
}
return 0;
}