Advertisement
kxcoze

pastecringeformaxximus

Oct 27th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.32 KB | None | 0 0
  1. #include <bits/stdc++.h>        
  2.                                                                                                                      
  3. using namespace std;
  4.                                                                                                                      
  5. #define foreach(i, n) for(auto &i : (n))
  6. #define all(x) (x).begin(), (x).end()
  7. #define pb push_back                                                                                                                          
  8. #define mp make_pair                                                                                                                          
  9. #define ll long long                                                                                                                          
  10.                                                                                                                      
  11. const ll MOD = 1e9 + 7;
  12. const int inf = 1e9;
  13. const double pi = acos(-1.0);
  14.                                                                                                                      
  15. string push(char c, int x) {
  16.     string ans;
  17.     for (int i = 0; i < x; i++) {
  18.         ans += c;
  19.     }
  20.     return ans;
  21. }                                                                                                                      
  22.                                                                                                                      
  23. int main() {
  24.     int sum = 0;
  25.     string s, strS = "";
  26.     vector <int> v1;
  27.                                                                                                                      
  28.     cin >> s;
  29.     for (int i = 0; i < s.size(); i++) {
  30.         string c = "";
  31.         for (int j = i; j < s.size(); j++) {
  32.             if (isdigit(s[j])) c += s[j];
  33.             else {
  34.                 i = j;
  35.                 break;
  36.             }
  37.         }
  38.         if (c != "") {
  39.             v1.pb(atoi(c.c_str()));
  40.         }
  41.         else
  42.             v1.pb(1);
  43.         strS += s[i];
  44.     }
  45.     foreach(i, v1) {
  46.         sum += i;
  47.     }
  48.     if (sum > 50)
  49.         cout << "TOO_LONG\n";
  50.     else {
  51.         s = "";
  52.         for (int i = 0; i < strS.size(); i++) {
  53.             s += push(strS[i], v1[i]);
  54.         }
  55.         cout << s << '\n';
  56.     }
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement