SHARE
TWEET

Untitled

lalalalalalalaalalla Nov 1st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip>
  5. #include <queue>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <tuple>
  9. #include <iomanip>
  10. #include <stdio.h>
  11. #include <map>
  12. #include <bitset>
  13. #include <set>
  14. #include <stack>
  15. #include <queue>
  16. #include <unordered_set>
  17. #include <cassert>
  18.  
  19.  
  20. //#pragma GCC optimize("Ofast,no-stack-protector")
  21. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  22. //#pragma GCC optimize("unroll-loops")
  23. //#pragma GCC optimize("fast-math")
  24. //#pragma GCC optimize("section-anchors")
  25. //#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
  26. //#pragma GCC optimize("vpt")
  27. //#pragma GCC optimize("rename-registers")
  28. //#pragma GCC optimize("move-loop-invariants")
  29. //#pragma GCC optimize("unswitch-loops")
  30. //#pragma GCC optimize("function-sections")
  31. //#pragma GCC optimize("data-sections")
  32. //#pragma GCC optimize("branch-target-load-optimize")
  33. //#pragma GCC optimize("branch-target-load-optimize2")
  34. //#pragma GCC optimize("btr-bb-exclusive")
  35.  
  36.  
  37. #define int long long
  38. #define ll long long
  39. #define ull unsigned long long
  40. #define all(a) a.begin(), a.end()
  41. #define pii pair<int, int>
  42. #define pb push_back
  43. #define ld long double
  44.  
  45.  
  46. using namespace std;
  47.  
  48. const int INF = 1e17;
  49. //const int mod = 2600000069;
  50. //const int p = 179;
  51.  
  52. signed main() {
  53.     ios_base::sync_with_stdio(0);
  54.     cin.tie(0);
  55.     cout.tie(0);
  56.     string a, b, c;
  57.     cin >> a >> b >> c;
  58.     string aa, bb, cc;
  59.     aa = a[0];
  60.     bb = b[0];
  61.     cc = c[0];
  62.     int s1 = a.size(), s2 = b.size(), s3 = c.size();
  63.     for (int i = 1; i < s1; i++) {
  64.         if (a[i] != a[i - 1]) {
  65.             aa += a[i];
  66.         }
  67.     }
  68.     for (int i = 1; i < s2; i++) {
  69.         if (b[i] != b[i - 1]) {
  70.             bb += b[i];
  71.         }
  72.     }
  73.     for (int i = 1; i < s3; i++) {
  74.         if (c[i] != c[i - 1]) {
  75.             cc += c[i];
  76.         }
  77.     }
  78.     if (aa != bb || bb != cc) {
  79.         cout << "IMPOSSIBLE";
  80.         return 0;
  81.     }
  82.     int k = aa.size();
  83.     vector<int> num1, num2, num3;
  84.     int cnt = 1;
  85.     char cur = a[0];
  86.     for (int i = 1; i < s1; i++) {
  87.         if (a[i] != cur) {
  88.             num1.pb(cnt);
  89.             cur = a[i];
  90.             cnt = 1;
  91.         } else {
  92.             cnt++;
  93.         }
  94.     }
  95.     num1.pb(cnt);
  96.     cur = b[0];
  97.     cnt = 1;
  98.     for (int i = 1; i < s2; i++) {
  99.         if (b[i] != cur) {
  100.             num2.pb(cnt);
  101.             cur = b[i];
  102.             cnt = 1;
  103.         } else {
  104.             cnt++;
  105.         }
  106.     }
  107.     num2.pb(cnt);
  108.     cur = c[0];
  109.     cnt = 1;
  110.     for (int i = 1; i < s3; i++) {
  111.         if (c[i] != cur) {
  112.             num3.pb(cnt);
  113.             cur = c[i];
  114.             cnt = 1;
  115.         } else {
  116.             cnt++;
  117.         }
  118.     }
  119.     num3.pb(cnt);
  120.     string ans = "";
  121.     for (int i = 0; i < k; i++) {
  122.         vector<int> qqq = {num1[i], num2[i], num3[i]};
  123.         sort(all(qqq));
  124.         for (int j = 0; j < qqq[1]; j++) {
  125.             ans += aa[i];
  126.         }
  127.     }
  128.     cout << ans;
  129. }
  130. /*
  131.  
  132. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top