Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- int n;
- cin >> n;
- cin.ignore();
- vector<string>v;
- string s;
- int alr=0;
- while (n--) {
- getline(cin,s);
- if (s[0]=='c') {
- if (!alr) {
- s[3]=' '; alr++;
- }
- for (int i=3; i<s.size(); i++) {
- if (s[i]=='.') {
- i+=2;
- s[i]='0';
- if (!v.empty()) v.pop_back();
- }
- else if (isalpha(s[i])) {
- int x = s.find('/', i);
- if (x != string::npos) v.push_back(s.substr(i, x - i));
- else {
- v.push_back(s.substr(i));
- break;
- }
- //v.push_back(s.substr(i, s.find('/')-i));
- i=x;
- // s[i+1]='0';
- }
- }
- }
- else {
- cout << '/';
- for (auto i:v) cout << i << '/';
- cout << endl;
- }
- }
- return 0;
- }
- /*
- *
- *
- */
Advertisement
Add Comment
Please, Sign In to add comment