当前位置:网站首页>(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;
}
边栏推荐
- sonarqube介紹和安裝步驟
- [day13-14 intensive literature reading] cross dimensional magnetic interactions arise from memory interference
- Jetpack架构组件学习(3)——Activity Results API使用
- Si4432 RF chip scheme typical application of data transmission of wireless communication module of Internet of things
- Two ways of using reuqests in RF
- Discrete mathematics attention points, priority problems
- PHP mkdir(): permission denied uploading a file will change the folder permission to 411 permission
- Dblink operation in Oracle
- 2022年起重机司机(限桥式起重机)考试题模拟考试题库及模拟考试
- Altium designer工程下多个原理图和PCB图的一一对应
猜你喜欢

Wake up wrist - neural network and deep learning (tensorflow application) updating
![Vs code writing assembly code [microcomputer principle]](/img/fc/e32262fcd80841ba7b82882a89ad0b.png)
Vs code writing assembly code [microcomputer principle]

Mysql5 and mysql8 are installed at the same time

Lake Shore—SuperTran 连续流低温恒温器系统

Pad printing process flow and application precautions

Flex flexible layout tutorial and understanding of the main axis cross axis: Grammar

【自然语言处理】【多模态】ALBEF:基于动量蒸馏的视觉语言表示学习

CVPR 2022 | meta learning performance in image regression task

HMS core shows the latest open capabilities in mwc2022, helping developers build high-quality applications

The latest "capsule Network Overview" paper of imperial technology, etc., 29 pages of PDF, expounds the concept, method and application of capsule
随机推荐
My creation anniversary
Flex flexible layout tutorial and understanding of the main axis cross axis: Grammar
一文读懂Logstash原理
机器学习之数据处理与可视化【鸢尾花数据分类|特征属性比较】
[day13-14 intensive literature reading] cross dimensional magnetic interactions arise from memory interference
2022高压电工考试题模拟考试题库及在线模拟考试
Les produits antigéniques entrent dans la famille et les entreprises chinoises de dispositifs médicaux accueillent un nouvel océan bleu
[day4 literature intensive reading] space – time interdependence: evidence against Asymmetric mapping between time and space
我的创作纪念日
Introduction aux bases de SOLR
Research Report on development trend and competitive strategy of global customized power supply industry
04 automatic learning rate - learning notes - lihongyi's in-depth learning 2021
Method for WiFi wireless transmission module to access cloud platform using esp8266 chip scheme
sonarqube介绍和安装步骤
Here we go! Dragon lizard community enters PKU classroom
2022年安全员-A证考题模拟考试平台操作
[Day10 literature extensive reading] temporary cognition can affect spatial cognition more than vice versa: the effect of
MySQL 8.0 decompressed version installation tutorial
[day15 literature extensive reading] numerical magnetic effects temporary memories but not time encoding
Delete the receiving address [project mall]