当前位置:网站首页>(dp) acwing 899. Edit distance
(dp) acwing 899. Edit distance
2022-06-11 23:35:00 【Age worry】
899. Edit distance
Topic link https://www.acwing.com/problem/content/901/
subject :
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char a[1010][15];
int n,m;
int f[15][15];
int pd(char s[],char c[]){
int lens=strlen(s+1);
int lenc=strlen(c+1);
for(int i=0;i<=lens;i++) f[i][0]=i;
for(int i=0;i<=lenc;i++) f[0][i]=i;
for(int i=1;i<=lens;i++){
for(int j=1;j<=lenc;j++){
f[i][j]=min(f[i][j-1]+1,f[i-1][j]+1);
if(s[i]==c[j]) f[i][j]=min(f[i][j],f[i-1][j-1]);
else f[i][j]=min(f[i][j],f[i-1][j-1]+1);
}
}
return f[lens][lenc];
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++){
scanf("%s",a[i]+1);
}
int k;
char s[15];
while(m--){
scanf("%s%d",s+1,&k);
int ans=0;
for(int i=0;i<n;i++){
memset(f,0x3f,sizeof f);
if(pd(s,a[i])<=k) ans++;
}
printf("%d\n",ans);
}
return 0;
}
边栏推荐
- Application of Lora technology in long distance wireless transmission of water meter reading
- Fonctionnement de la plate - forme d'examen de simulation pour les agents de sécurité - Questions d'examen de certificat a en 2022
- [day15 literature extensive reading] numerical magnetic effects temporary memories but not time encoding
- CVPR 2022 | meta learning performance in image regression task
- Teacher lihongyi, NTU -- tips for DNN regulation
- Cisco private dynamic routing protocol: EIGRP
- MySQL 8.0 decompressed version installation tutorial
- Node version control tool NVM
- swiper
- Handwritten simple promise
猜你喜欢

Altium designer工程下多个原理图和PCB图的一一对应

Zigbee3.0 wireless packet capturing installation method based on e18-2g4u04b

Cisco private dynamic routing protocol: EIGRP
![[day15 literature extensive reading] numerical magnetic effects temporary memories but not time encoding](/img/57/9ce851636b927813a55faedb4ecd48.png)
[day15 literature extensive reading] numerical magnetic effects temporary memories but not time encoding

唤醒手腕 - 神经网络与深度学习(Tensorflow应用)更新中

2022年R1快开门式压力容器操作考题及在线模拟考试

2022年起重机司机(限桥式起重机)考试题模拟考试题库及模拟考试

Remix localization, loading local contract file, local link Remix

2022 safety officer-b certificate theoretical question bank and simulation test

Lake Shore—SuperTran-VP 连续流低温恒温器系统
随机推荐
Software installation and use, etc
Custom font settings
oracle中dblink操作
机器学习之数据处理与可视化【鸢尾花数据分类|特征属性比较】
Mysql5 and mysql8 are installed at the same time
思科私有动态路由协议:EIGRP
How to make scripts executable anywhere
A new product with advanced product power, the new third generation Roewe rx5 blind subscription is opened
A method of relay for ultra long distance wireless transmission of low power wireless module
2022高压电工考试题模拟考试题库及在线模拟考试
Leetcode must review 20 lintcode (5466421166978227)
Solve the problem of slow downloading plug-ins for idea
抗原产品进入家庭,中国医疗器械企业迎来新蓝海
PHP mkdir(): Permission denied上传文件会把文件夹权限改为411权限
Lake Shore—SuperVariTemp 低温恒温器
Flex flexible layout tutorial and understanding of the main axis cross axis: Grammar
RF中使用reuqests的两种方式
[day11-12 intensive literature reading] on languages in memory: an internal clock account of space-time interaction
2022 safety officer-b certificate theoretical question bank and simulation test
VS code 编写汇编代码【微机原理】