fork(1) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <cstdlib>
  7. #include <vector>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <stack>
  12. #include <list>
  13. #include <cmath>
  14. #include <iomanip>
  15. #define dibs reserve
  16. #define OVER9000 1234567890
  17. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  18. #define tisic 47
  19. #define soclose 1e-6
  20. #define chocolate win
  21. // so much chocolate
  22. #define patkan 9
  23. #define ff first
  24. #define ss second
  25. #define abs(x) ((x < 0)?-(x):x)
  26. #define uint unsigned int
  27. using namespace std;
  28. // mylittledoge
  29.  
  30. int N;
  31. vector<string> L;
  32. vector<int> P;
  33.  
  34. void calc(int z, int k, int s) {
  35. // cout << z << " " << k << " " << s << endl;
  36. int c =-1;
  37. for(int i =z; i < k; i++) {
  38. if(L[i].length() > s && L[i][s]-'a' != c) {
  39. for(int j =i+1; j <= k; j++) {
  40. if(j == k || L[j].length() <= s || L[j][s] != L[i][s]) {
  41. calc(i+1,j,s+1);
  42. break;}
  43. else P[j]++;}
  44. }
  45. c =(L[i].length() > s)?(L[i][s]-'a'):-i-2;}
  46. }
  47.  
  48. int main() {
  49. cin.sync_with_stdio(0);
  50. cin.tie(0);
  51. string s;
  52. while(getline(cin,s)) {
  53. if(s.empty()) break;
  54. N++;
  55. L.push_back(s);}
  56. P.resize(N);
  57. calc(0,N,0);
  58. for(int i =0; i < N; i++) {
  59. // cout << P[i] << " ";
  60. for(int j =0; j < P[i]; j++) cout << " ";
  61. cout << L[i] << "\n";}
  62. return 0;}
  63.  
  64. // look at my code
  65. // my code is amazing
Success #stdin #stdout 0s 3480KB
stdin
Standard input is empty
stdout
Standard output is empty