Advertisement
GastonFontenla

Untitled

Jun 10th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <bitset>
  5.  
  6. using namespace std;
  7. #define F(n) (n=='A' ? 0 : n=='C' ? 1 : n=='G' ? 2 : 3)
  8.  
  9. int n, m;
  10. bool Sirve(int a, int b, int c, const vector <string> &s, const vector <string> &p)
  11. {
  12.     bitset <64> combinacion;
  13.  
  14.     for(int i=0; i<s.size(); i++)
  15.         combinacion[F(s[i][a])*16 + F(s[i][b])*4 + F(s[i][c])] = true;
  16.  
  17.     for(int i=0; i<p.size(); i++)
  18.         if(combinacion[F(p[i][a])*16 + F(p[i][b])*4 + F(p[i][c])])
  19.             return false;
  20.  
  21.     return true;
  22. }
  23.  
  24. int main()
  25. {
  26.     vector <string> spotty, plain;
  27.     cin >> n >> m;
  28.  
  29.     spotty.resize(n);
  30.     plain.resize(n);
  31.  
  32.     for(int i=0; i<n; i++)
  33.         cin >> spotty[i];
  34.  
  35.     for(int i=0; i<n; i++)
  36.         cin >> plain[i];
  37.  
  38.     int res = 0;
  39.  
  40.     for(int i=0; i<m; i++)
  41.         for(int j=i+1; j<m; j++)
  42.             for(int k=j+1; k<m; k++)
  43.                 if(Sirve(i, j, k, spotty, plain))
  44.                     res++;
  45.  
  46.     cout << res << endl;
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement