Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <sstream>
  5. #include <ctime>
  6. #include <set>
  7. #include <map>
  8. #include <string>
  9. #include <stack>
  10. #include <fstream>
  11. #include <ctime>
  12.  
  13.  
  14. using namespace std;
  15.  
  16. int main()
  17. {
  18. int n;
  19. cin >> n;
  20. vector<vector<string> > v;
  21. for(int i = 0; i < n; ++i)
  22. {
  23. string s;
  24. cin >> s;
  25. string curS;
  26. v.push_back(vector<string>());
  27. for(int j = 0; j < s.size(); ++j)
  28. {
  29. if (s[j] == '\\')
  30. {
  31. v.back().push_back(curS);
  32. curS = "";
  33. }
  34. else
  35. curS += s[j];
  36. }
  37. v.back().push_back(curS);
  38. }
  39.  
  40. sort(v.begin(), v.end());
  41.  
  42. for(int i = 0; i < n; ++i)
  43. {
  44. if (i == 0)
  45. for(int j = 0; j < v[i].size(); ++j)
  46. cout << string(j, ' ') << v[i][j] << endl;
  47. else
  48. {
  49. int k = 0;
  50. while(k < v[i-1].size() && k < v[i].size() && v[i-1][k] == v[i][k])
  51. ++k;
  52. for(int t = k; t < v[i].size(); ++t)
  53. cout << string(t, ' ') << v[i][t] << endl;
  54. }
  55. }
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement