Advertisement
double_trouble

A

Nov 5th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <cmath>
  5. #include <string>
  6. #include <algorithm>
  7. #include <string>
  8. #include <deque>
  9.  
  10. #define F first
  11. #define S second
  12.  
  13. using namespace std;
  14.  
  15. vector<string> a;
  16. int b[30][30];
  17.  
  18.  
  19. int main()
  20. {
  21.     ios_base::sync_with_stdio(0);
  22. //  freopen("input.txt", "r", stdin);
  23. //  freopen("output.txt", "w", stdout);
  24.  
  25.     int n;
  26.     cin >> n;
  27.     string t;
  28.     for (int i = 0; i < n; i++)
  29.     {
  30.         cin >> t;
  31.         char c = t[0];
  32.         int u = 1;
  33.         while (u < t.size() && t[u] == c)
  34.             u++;
  35.         char cc;
  36.         if (u < t.size())
  37.             cc = t[u];
  38.         else
  39.         {
  40.             a.push_back(t);
  41.             continue;
  42.         }
  43.         while (u < t.size() && (t[u] == c || t[u] == cc))
  44.             u++;
  45.         if (u == t.size())
  46.             a.push_back(t);
  47.     }
  48.     for (int i = 0; i < a.size(); i++)
  49.     {
  50.         t = a[i];
  51.         char c = t[0];
  52.         int u = 1;
  53.         while (u < t.size() && t[u] == c)
  54.             u++;
  55.         char cc = 'A';
  56.         if (u < t.size())
  57.             cc = t[u];
  58.         if (cc == 'A')
  59.             b[c - 'a'][c - 'a'] += t.size();
  60.         else
  61.         {
  62.             b[c - 'a'][cc - 'a'] += t.size();
  63.         }
  64.  
  65.     }
  66.  
  67.     /*for (int i = 0; i < 30; i++)
  68.     {
  69.         for (int j = 0; j < 30; j++)
  70.             cout << b[i][j] << " ";
  71.         cout << endl;
  72.     }*/
  73.  
  74.     int ans = 0;
  75.     for (int i = 0; i < 30; i++)
  76.         for (int j = 0; j < 30; j++)
  77.             if (i == j)
  78.                 continue;
  79.             else
  80.             {
  81.                 ans = max(ans, b[i][j] + b[i][i] + b[j][j]);
  82.             }
  83.  
  84.     cout << ans << endl;
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement