Nayeemzaman

Untitled

Aug 30th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<string>
  3. #include<vector>
  4.  
  5. using namespace std;
  6.  
  7. typedef long long int ll;
  8. typedef long double ld;
  9. typedef unsigned long long int ull;
  10. typedef long long li;
  11.  
  12. #define ms(x,a) memset(x,a,sizeof(x))
  13. #define forn(i, n) for (int i = 0; i < int(n); i++)
  14. #define pi      acos(0.0)*2 // 3.1415926535897932
  15. #define mxx     100000007
  16. #define mod     1000000007
  17. #define base    10000007
  18. #define pb      push_back
  19.  
  20. void inOut();
  21.  
  22. int max(int a, int b);
  23. int lcs( char *X, char *Y, int m, int n )
  24. {
  25.    int L[m+1][n+1];
  26.    int i, j;
  27.  
  28.    for (i=0; i<=m; i++)
  29.    {
  30.      for (j=0; j<=n; j++)
  31.      {
  32.        if (i == 0 || j == 0)
  33.          L[i][j] = 0;
  34.  
  35.        else if (X[i-1] == Y[j-1])
  36.          L[i][j] = L[i-1][j-1] + 1;
  37.  
  38.        else
  39.          L[i][j] = max(L[i-1][j], L[i][j-1]);
  40.      }
  41.    }
  42.  
  43.  
  44.    return L[m][n];
  45. }
  46.  
  47. int max(int a, int b)
  48. {
  49.     return (a > b) ? a : b;
  50. }
  51.  
  52. int main()
  53. {
  54.     //inOut();
  55.     int i,j;
  56.     char s[100005],s1[100005];
  57.  
  58.     cin>>s>>s1;
  59.     int m = strlen(s);
  60.     int n = strlen(s1);
  61.  
  62.     int mx =lcs(s, s1, m, n);
  63.     //cout<<mx<<endl;
  64.     //int sz2 = lcs(s, s1, m, n);
  65.     //int mx  = max(sz1, sz2);
  66.     double bro = (m*0.99);
  67.  
  68.     if(mx>=bro)
  69.         cout<<"Long lost brothers D:"<<endl;
  70.     else
  71.         cout<<"Not brothers :("<<endl;
  72.  
  73.     return 0;
  74. }
  75.  
  76. void inOut()
  77. {
  78.     ios_base::sync_with_stdio(false);
  79.     cin.tie(NULL);
  80.  
  81.     #ifndef ONLINE_JUDGE
  82.         freopen("input.txt", "r", stdin);
  83.         //freopen("output.txt", "w", stdout);
  84.     #endif
  85. }
Add Comment
Please, Sign In to add comment