lina_os

Untitled

Mar 10th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  8. int n;
  9. cin >> n;
  10. cin.ignore();
  11. vector<string>v;
  12. string s;
  13. int alr=0;
  14. while (n--) {
  15. getline(cin,s);
  16. if (s[0]=='c') {
  17. if (!alr) {
  18. s[3]=' '; alr++;
  19. }
  20. for (int i=3; i<s.size(); i++) {
  21. if (s[i]=='.') {
  22. i+=2;
  23. s[i]='0';
  24. if (!v.empty()) v.pop_back();
  25. }
  26. else if (isalpha(s[i])) {
  27. int x = s.find('/', i);
  28. if (x != string::npos) v.push_back(s.substr(i, x - i));
  29. else {
  30. v.push_back(s.substr(i));
  31. break;
  32. }
  33. //v.push_back(s.substr(i, s.find('/')-i));
  34. i=x;
  35. // s[i+1]='0';
  36. }
  37. }
  38. }
  39. else {
  40. cout << '/';
  41. for (auto i:v) cout << i << '/';
  42. cout << endl;
  43. }
  44. }
  45. return 0;
  46. }
  47.  
  48. /*
  49. *
  50. *
  51. */
Advertisement
Add Comment
Please, Sign In to add comment