Advertisement
vov44k

Untitled

Dec 13th, 2021
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <set>
  5. #include <queue>
  6. #include <map>
  7. #include <vector>
  8. #include <climits>
  9. #include <algorithm>
  10. #include <cmath>
  11.  
  12. using namespace std;
  13. void printpair(pair<int, int> a)
  14. {
  15.     int x = a.first;
  16.     int y = a.second;
  17.     if (x == 1)
  18.         cout << "R";
  19.     if (x == 2)
  20.         cout << "G";
  21.     if (x == 3)
  22.         cout << "B";
  23.  
  24.     if (y == 1)
  25.         cout << "R";
  26.     if (y == 2)
  27.         cout << "G";
  28.     if (y == 3)
  29.         cout << "B";
  30.     cout << endl;
  31. }
  32. int main()
  33. {
  34.     bool ffffff = true;
  35. #ifdef LOCAL
  36.     freopen("input.txt", "r", stdin);
  37.     freopen("output.txt", "w", stdout);
  38.     ffffff = false;
  39. #endif
  40.     if (ffffff)
  41.     {
  42.         ios::sync_with_stdio(0);
  43.         cin.tie(0);
  44.     }
  45.  
  46.     int n;
  47.     cin >> n;
  48.     vector<vector<int> > vec(n);
  49.     string t;
  50.     map<pair<int, int>, int> mp;
  51.     getline(cin, t);
  52.     for (int i = 0; i < n; i++)
  53.     {
  54.         string s;
  55.         getline(cin, s);
  56.         vector<int> g(s.size());
  57.         for (int j = 0; j < s.size() - 1; j++)
  58.         {
  59.             if (s[j] == 'R')
  60.                 g[j] = 1;
  61.             if (s[j] == 'G')
  62.                 g[j] = 2;
  63.             if (s[j] == 'B')
  64.                 g[j] = 3;
  65.  
  66.             if (s[j + 1] == 'R')
  67.                 g[j + 1] = 1;
  68.             if (s[j + 1] == 'G')
  69.                 g[j + 1] = 2;
  70.             if (s[j + 1] == 'B')
  71.                 g[j + 1] = 3;
  72.             int x = g[j], y = g[j + 1];
  73.             if (x > y)
  74.                 swap(x, y);
  75.             mp[{x, y}]++;
  76.         }
  77.         int x = g[0], y = g[s.size() - 1];
  78.         if (x > y)
  79.             swap(x, y);
  80.         mp[{x, y}]++;
  81.     }
  82.     map<pair<int, int>, int>::iterator it = mp.begin();
  83.     set<pair<int, pair<int, int> > > st;
  84.     int mx = 0;
  85.     for (int i = 0; it != mp.end(); it++, i++)
  86.     {
  87.         st.insert({it->second, it->first});
  88.         mx = max(it->second, mx);
  89.     }
  90.     auto t11 = st.find({mx, {1, 2}});
  91.     if (t11 != st.end())
  92.     {
  93.         auto t1 = *t11;
  94.         printpair(t1.second);
  95.     }
  96.  
  97.     t11 = st.find({mx, {1, 1}});
  98.     if (t11 != st.end())
  99.     {
  100.         auto t1 = *t11;
  101.         printpair(t1.second);
  102.     }
  103.  
  104.     t11 = st.find({mx, {2, 2}});
  105.     if (t11 != st.end())
  106.     {
  107.         auto t1 = *t11;
  108.         printpair(t1.second);
  109.     }
  110.  
  111.     t11 = st.find({mx, {3, 3}});
  112.     if (t11 != st.end())
  113.     {
  114.         auto t1 = *t11;
  115.         printpair(t1.second);
  116.     }
  117.  
  118.     t11 = st.find({mx, {1, 3}});
  119.     if (t11 != st.end())
  120.     {
  121.         auto t1 = *t11;
  122.         printpair(t1.second);
  123.     }
  124.  
  125.     t11 = st.find({mx, {2, 3}});
  126.     if (t11 != st.end())
  127.     {
  128.         auto t1 = *t11;
  129.         printpair(t1.second);
  130.     }
  131.  
  132.     return 0;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement