Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tested by zydhanlinnar11 on May 25, 2022
- #include <iostream>
- #include <cassert>
- #include <vector>
- #include <string>
- using namespace std;
- typedef vector<string> vs;
- inline string formatPath(vs &arr) {
- string path = arr.front();
- for(int i=1; i<arr.size(); i++) path += "/" + arr[i];
- return path;
- }
- int main() {
- ios_base::sync_with_stdio(false); cin.tie(NULL);
- #ifdef ZYD_WSL
- freopen("/home/zydhanlinnar11/prakfinal-qa/in", "r", stdin);
- #endif
- int q, s;
- string cmd;
- vs arr = {"home", "anton"};
- getline(cin, cmd);
- q = stoi(cmd);
- assert(1 <= q && q <= 30);
- while(q--) {
- getline(cin, cmd);
- if(cmd.find("whereami") != string::npos)
- cout<<(arr.empty() ? "i am nowhere" : formatPath(arr))<<"\n";
- else if (cmd.find("goto") != string::npos) {
- string x = cmd.substr(5);
- for(char &i: x) assert(i != ' ');
- arr.push_back(x);
- }
- else if(cmd.find("goback") == string::npos)cout<<"Query not found\n";
- else if(!arr.empty()) arr.pop_back();
- else cout<<"cannot go back\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment