Submission details
Task:Lukujono
Sender:worst
Submission time:2025-11-02 12:07:31 +0200
Language:text
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.00 s0details

Code

#include <bits/stdc++.h>

using namespace std;

map<char, int> mp;

void solve_operations(vector<pair<string, char>> &operations) {
    for (int j = 0; j < operations.size(); j++) {
        string op = operations[j].first;
        char l = operations[j].second;
        if (op == "INCREASE") {
            mp[l]++;
        } else if (op == "CLEAR") {
            mp[l] = 0;
        } else if (op == "PRINT") {
            cout << mp[l] << " ";
        } else if (op == "REPEAT") {
            vector<pair<string, char>> operationsNew;
            int c = 0;
            for (int jj = j + 2; jj < operations.size(); jj++) {
                if (operations[jj].first == "end" && c == 0) {
                    j = jj;
                    break;
                }
                operationsNew.push_back(operations[jj]);

                if (operations[jj].first == "REPEAT") {
                    c++;
                }
                if (operations[jj].first == "end") {
                    c--;
                }
            }

            int times = mp[l];
            for (int i = 0; i < times; i++) {
                solve_operations(operationsNew);
            }
        }
    }
}

void solve() {
    string s;
    vector<string> v;
    while (getline(cin, s)) {
        v.push_back(s);
    }

    string rawInput;

    for (int i = 0; i < v.size(); i++) {
        if (!rawInput.empty()) {
            if (rawInput[rawInput.size() - 1] != ' ') {
                rawInput += ' ';
            }
        }
        for (int j = 0; j < v[i].size(); j++) {
            if (v[i][j] == '#') {
                break;
            }
            if (v[i][j] == ' ') {
                if (!rawInput.empty()) {
                    if (rawInput[rawInput.size() - 1] != ' ') {
                        rawInput += ' ';
                    }
                }
            } else {
                rawInput += v[i][j];
            }
        }
    }

    for (int i = 65; i <= 90; i++) {
        mp[char(i)] = 0;
    }

    vector<pair<string, char>> operations;
    string word;
    for (int j = 0; j < rawInput.size(); j++) {
        if (rawInput[j] == '#') {
            continue;
        }
        if (rawInput[j] != ' ') {
            word += rawInput[j];
        }
        if (word == "INCREASE" || word == "CLEAR" || word == "PRINT") {
            operations.push_back({word, rawInput[j + 2]});
            j += 2;
            word = "";
        } else if (word == "REPEAT") {
            operations.push_back({word, rawInput[j + 2]});
            operations.push_back({"start", '+'});
            j += 2 + 8;
            word = "";
        } else if (word == ")") {
            operations.push_back({"end", '-'});
            word = "";
        }
    }

    solve_operations(operations);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout << fixed << setprecision(6) << endl;

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Test details

Test 1 (public)

Verdict:

input
(empty)

correct output
(empty)

user output
#include <bits/stdc++.h>

using namespace std;

map<char, int> mp;
...

Feedback: Error: invalid command using