fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. const int N=5e3+5;
  5. int dp[N][N];
  6. int lcs(string s1,string s2)
  7. {
  8. int n=s1.size();
  9. int mx=0;
  10. for(int a=0;a<n;a++){
  11. int sum=0;
  12. int c=a;
  13. for(int b=0;b<n;b++){
  14. if(s1[c]==s2[b]){
  15. c++;
  16. sum++;
  17. }
  18. }
  19. mx=max(mx,sum);
  20. }
  21. return mx;
  22. }
  23. signed main()
  24. {
  25. freopen("ANAGRAM.INP","r",stdin);
  26. freopen("ANAGRAM.OUT","w",stdout);
  27. ios_base::sync_with_stdio(false);
  28. cin.tie(0);
  29. cout.tie(0);
  30. string s,t;
  31. cin>>s>>t;
  32. int n=s.size();
  33. cout<<n-lcs(s,t);
  34. }
  35.  
Success #stdin #stdout 0s 5312KB
stdin
areyougay
youaregay
stdout
Standard output is empty