Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <vector>
- #include <cmath>
- #include <string>
- #include <algorithm>
- #include <string>
- #include <deque>
- #define F first
- #define S second
- using namespace std;
- vector<string> a;
- int b[30][30];
- int main()
- {
- ios_base::sync_with_stdio(0);
- // freopen("input.txt", "r", stdin);
- // freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- string t;
- for (int i = 0; i < n; i++)
- {
- cin >> t;
- char c = t[0];
- int u = 1;
- while (u < t.size() && t[u] == c)
- u++;
- char cc;
- if (u < t.size())
- cc = t[u];
- else
- {
- a.push_back(t);
- continue;
- }
- while (u < t.size() && (t[u] == c || t[u] == cc))
- u++;
- if (u == t.size())
- a.push_back(t);
- }
- for (int i = 0; i < a.size(); i++)
- {
- t = a[i];
- char c = t[0];
- int u = 1;
- while (u < t.size() && t[u] == c)
- u++;
- char cc = 'A';
- if (u < t.size())
- cc = t[u];
- if (cc == 'A')
- b[c - 'a'][c - 'a'] += t.size();
- else
- {
- b[c - 'a'][cc - 'a'] += t.size();
- }
- }
- /*for (int i = 0; i < 30; i++)
- {
- for (int j = 0; j < 30; j++)
- cout << b[i][j] << " ";
- cout << endl;
- }*/
- int ans = 0;
- for (int i = 0; i < 30; i++)
- for (int j = 0; j < 30; j++)
- if (i == j)
- continue;
- else
- {
- ans = max(ans, b[i][j] + b[i][i] + b[j][j]);
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement