Advertisement
PedalaVasile

text

Feb 13th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4. #include <stack>
  5.  
  6. #define sc -'a'
  7.  
  8. using namespace std;
  9.  
  10. ifstream fin("text.in");
  11. ofstream fout("text.out");
  12.  
  13. short maxim = 0;
  14. short v[20001], a[20001];
  15. vector < string > cuv;
  16.  
  17.  
  18.  
  19. int main()
  20. {
  21.     string s;
  22.  
  23.     while(fin >> s)
  24.     {
  25.         short aux = -1;
  26.  
  27.         if(a[s[s.length() - 1] sc] < a[s[0] sc] + 1)
  28.            aux =  a[s[s.length() - 1] sc] = a[s[0] sc] + 1;
  29.  
  30.         if(aux > maxim)
  31.             maxim = aux;
  32.  
  33.         cuv.push_back(s);
  34.     }
  35.  
  36.     fout << cuv.size() << '\n' << cuv.size() - maxim << '\n';
  37.  
  38.     for(int i = 0; i <= 30; i++)
  39.     {
  40.         fout << a[i] << ' ' << (char)(i + 'a') << '\n';
  41.     }
  42.  
  43.     for(int i = 0; i <= 30; i++)
  44.     {
  45.         if(a[i] == maxim)
  46.         {
  47.             maxim--;
  48.             fout << cuv[i] << '\n';
  49.             i = -1;
  50.         }
  51.     }
  52.  
  53.  
  54.     fin.close();
  55.     fout.close();
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement