• + 0 comments

    include

    include

    include

    include

    include

    include

    using namespace std;

    int main() { string S1 = ""; int Queries = 0; cin >> Queries; int Operations = 0; string S2 = ""; stack Temp; while (Queries--) { cin >> Operations; if (Operations == 1) { Temp.push(S1); cin >> S2; S1 += S2; } else if (Operations == 2) { Temp.push(S1); cin >> Operations; S1.erase(S1.size() - Operations, S1.size()); } else if (Operations == 3) { cin >> Operations; cout << S1[Operations-1] << endl;; } else if (Operations == 4) { S1 = Temp.top(); Temp.pop(); } } }