-
Notifications
You must be signed in to change notification settings - Fork 6
/
EDIST.cpp
31 lines (29 loc) · 1 KB
/
EDIST.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
static int c[3005][3005];
for(int i=0;i<2001;i++)
c[i][0]=c[0][i]=i;
int sum=0;
string a,b;
cin>>a>>b;
for(int i=0;i<a.length();i++)
{
for(int j=0;j<b.length();j++)
{
if(a[i]==b[j])
c[i+1][j+1]=c[i][j];
else
c[i+1][j+1]=1+min(min(c[i][j+1],c[i][j]),c[i+1][j]);
}
}
cout<<c[a.length()][b.length()]<<"\n";
}
}