Facebook
From rrrr, 7 Months ago, written in C++.
Embed
Download Paste or View Raw
Hits: 235
  1. /*If we keep holding onto yesterday, what are we going to be tomorrow?*/
  2.  
  3. #include <bits/stdc++.h>
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. #include <ext/pb_ds/tree_policy.hpp>
  6. using namespace __gnu_pbds;
  7. using namespace std;
  8. #define int long long int
  9. bool debugg = false;
  10. #define dbg if (debugg)
  11. #define F first
  12. #define S second
  13. template <typename T>
  14. using order_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  15.  
  16.  
  17.  
  18. bool valid (string &s)
  19. {
  20.     if (s[0]!='R') return 0;
  21.     int cnt=0; int g=0;
  22.     for (int i=0; i<s.size(); i++)
  23.     {
  24.         if (s[i]>'9') cnt++;
  25.         if (s[i]=='G') g=i;
  26.  
  27.     }
  28.     if (g>1 && cnt==2) return 1;
  29. }
  30.  
  31.  
  32. int32_t main()
  33. {
  34.     // ios::sync_with_stdio(0);
  35.     // cin.tie(0);
  36.     int t;
  37.     cin >> t;
  38.     int T = 0;
  39.     while (T++ < t)
  40.     {
  41.         string s;
  42.         cin >> s;
  43.         cout <<"Case " <<T <<": ";
  44.         if (valid(s))
  45.         {
  46.             string ans1, ans2;
  47.             bool spc = 0;
  48.             for (int i = 1; i < s.size(); i++)
  49.             {
  50.  
  51.                 if (s[i] == 'G')
  52.                     spc = 1;
  53.                 else if (spc)
  54.                     ans1 += s[i];
  55.                 else
  56.                     ans2 += s[i];
  57.             }
  58.             cout << ans1 << " " << ans2 << "n";
  59.         }
  60.         else
  61.         {
  62.             for (int i = 0; i < s.size(); i++)
  63.             {
  64.                 cout << s[i];
  65.                 if (i < s.size() - 1 && s[i] > '9' && s[i + 1] <= '9')
  66.                     cout << " ";
  67.             }
  68.             cout << "n";
  69.         }
  70.     }
  71. }