Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.     string killed = "deoxyribonuclein";
  7.     string s1[1050], s2[1050], s1v2[1050], s2v2[1050];
  8.     int n, badBoys = -1, dn;
  9.  
  10.     cin >> n;
  11.     dn = n;
  12.  
  13.     for(int i = 1; i <= n; i++)
  14.         cin >> s1[1050];
  15.     for(int i = 1; i <= n; i++)
  16.         cin >> s2[1050];
  17.  
  18.     int k = 1;
  19.     bool f = true;
  20.     while(f)
  21.     {
  22.         if(k % 2 == 0)
  23.         {
  24.         //VERSION 1
  25.             int localBadBoys = 0;
  26.             bool outrun = false;
  27.             for(int i = 1; i <= n; i++)
  28.             {
  29.                 for(int j = i + 1; j <= n; j++)
  30.                     if(s1[i] == s2[j])
  31.                     {
  32.                         outrun = true;
  33.                         localBadBoys++;
  34.                         badBoys++;
  35.                         s1[i] = killed;
  36.                         s2[j] = killed;
  37.                     }
  38.             }
  39.             if(!outrun)
  40.                 f = false;
  41.             else
  42.             {
  43.                 int r1 = 0, r2 = 0;
  44.                 for(int i = 1; i <= n; i++)
  45.                     if(s1[i] != killed)
  46.                     {
  47.                         r1++;
  48.                         s1v2[r1] = s1[i];
  49.                     }
  50.  
  51.                 for(int i = 1; i <= n; i++)
  52.                     if(s2[i] != killed)
  53.                     {
  54.                         r2++;
  55.                         s2v2[r2] = s2[i];
  56.                     }
  57.  
  58.                 n -= localBadBoys;
  59.             }
  60.         //VERSION 2
  61.         } else
  62.         {
  63.             int localBadBoys = 0;
  64.             bool outrun = false;
  65.             for(int i = 1; i <= n; i++)
  66.             {
  67.                 for(int j = i + 1; j <= n; j++)
  68.                     if(s1v2[i] == s2v2[j])
  69.                     {
  70.                         outrun = true;
  71.                         localBadBoys++;
  72.                         badBoys++;
  73.                         s1v2[i] = killed;
  74.                         s2v2[j] = killed;
  75.                     }
  76.             }
  77.             if(!outrun)
  78.                 f = false;
  79.             else
  80.             {
  81.                 int r1 = 0, r2 = 0;
  82.                 for(int i = 1; i <= n; i++)
  83.                     if(s1v2[i] != killed)
  84.                     {
  85.                         r1++;
  86.                         s1[r1] = s1v2[i];
  87.                     }
  88.  
  89.                 for(int i = 1; i <= n; i++)
  90.                     if(s2v2[i] != killed)
  91.                     {
  92.                         r2++;
  93.                         s2[r2] = s2v2[i];
  94.                     }
  95.  
  96.                 n -= localBadBoys;
  97.             }
  98.         }
  99.  
  100.         k++;
  101.     }
  102.  
  103.     cout << badBoys << "\n";
  104.     return 0;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement