Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <set>
- #include <queue>
- #include <map>
- #include <vector>
- #include <climits>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- void printpair(pair<int, int> a)
- {
- int x = a.first;
- int y = a.second;
- if (x == 1)
- cout << "R";
- if (x == 2)
- cout << "G";
- if (x == 3)
- cout << "B";
- if (y == 1)
- cout << "R";
- if (y == 2)
- cout << "G";
- if (y == 3)
- cout << "B";
- cout << endl;
- }
- int main()
- {
- bool ffffff = true;
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- ffffff = false;
- #endif
- if (ffffff)
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- }
- int n;
- cin >> n;
- vector<vector<int> > vec(n);
- string t;
- map<pair<int, int>, int> mp;
- getline(cin, t);
- for (int i = 0; i < n; i++)
- {
- string s;
- getline(cin, s);
- vector<int> g(s.size());
- for (int j = 0; j < s.size() - 1; j++)
- {
- if (s[j] == 'R')
- g[j] = 1;
- if (s[j] == 'G')
- g[j] = 2;
- if (s[j] == 'B')
- g[j] = 3;
- if (s[j + 1] == 'R')
- g[j + 1] = 1;
- if (s[j + 1] == 'G')
- g[j + 1] = 2;
- if (s[j + 1] == 'B')
- g[j + 1] = 3;
- int x = g[j], y = g[j + 1];
- if (x > y)
- swap(x, y);
- mp[{x, y}]++;
- }
- int x = g[0], y = g[s.size() - 1];
- if (x > y)
- swap(x, y);
- mp[{x, y}]++;
- }
- map<pair<int, int>, int>::iterator it = mp.begin();
- set<pair<int, pair<int, int> > > st;
- int mx = 0;
- for (int i = 0; it != mp.end(); it++, i++)
- {
- st.insert({it->second, it->first});
- mx = max(it->second, mx);
- }
- auto t11 = st.find({mx, {1, 2}});
- if (t11 != st.end())
- {
- auto t1 = *t11;
- printpair(t1.second);
- }
- t11 = st.find({mx, {1, 1}});
- if (t11 != st.end())
- {
- auto t1 = *t11;
- printpair(t1.second);
- }
- t11 = st.find({mx, {2, 2}});
- if (t11 != st.end())
- {
- auto t1 = *t11;
- printpair(t1.second);
- }
- t11 = st.find({mx, {3, 3}});
- if (t11 != st.end())
- {
- auto t1 = *t11;
- printpair(t1.second);
- }
- t11 = st.find({mx, {1, 3}});
- if (t11 != st.end())
- {
- auto t1 = *t11;
- printpair(t1.second);
- }
- t11 = st.find({mx, {2, 3}});
- if (t11 != st.end())
- {
- auto t1 = *t11;
- printpair(t1.second);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement