Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t_case,i=0,ip,k;
- string w;
- string s;
- s="";
- stack <string> undo;
- cin>>t_case;
- while(i<t_case){
- cin>>ip;
- switch(ip){
- case 1:
- undo.push(s);
- cin>>w;
- s=s+w;
- break;
- case 2:
- cin>>k;
- undo.push(s);
- s.erase(s.end()-k,s.end());
- break;
- case 3:
- cin>>k;
- cout<<s.at(k)<<endl;
- case 4:
- s=undo.top();
- undo.pop();
- break;
- }
- i++;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment