Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define foreach(i, n) for(auto &i : (n))
- #define all(x) (x).begin(), (x).end()
- #define pb push_back
- #define mp make_pair
- #define ll long long
- const ll MOD = 1e9 + 7;
- const int inf = 1e9;
- const double pi = acos(-1.0);
- string push(char c, int x) {
- string ans;
- for (int i = 0; i < x; i++) {
- ans += c;
- }
- return ans;
- }
- int main() {
- int sum = 0;
- string s, strS = "";
- vector <int> v1;
- cin >> s;
- for (int i = 0; i < s.size(); i++) {
- string c = "";
- for (int j = i; j < s.size(); j++) {
- if (isdigit(s[j])) c += s[j];
- else {
- i = j;
- break;
- }
- }
- if (c != "") {
- v1.pb(atoi(c.c_str()));
- }
- else
- v1.pb(1);
- strS += s[i];
- }
- foreach(i, v1) {
- sum += i;
- }
- if (sum > 50)
- cout << "TOO_LONG\n";
- else {
- s = "";
- for (int i = 0; i < strS.size(); i++) {
- s += push(strS[i], v1[i]);
- }
- cout << s << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement