Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <stack>
- #define sc -'a'
- using namespace std;
- ifstream fin("text.in");
- ofstream fout("text.out");
- short maxim = 0;
- short v[20001], a[20001];
- vector < string > cuv;
- int main()
- {
- string s;
- while(fin >> s)
- {
- short aux = -1;
- if(a[s[s.length() - 1] sc] < a[s[0] sc] + 1)
- aux = a[s[s.length() - 1] sc] = a[s[0] sc] + 1;
- if(aux > maxim)
- maxim = aux;
- cuv.push_back(s);
- }
- fout << cuv.size() << '\n' << cuv.size() - maxim << '\n';
- for(int i = 0; i <= 30; i++)
- {
- fout << a[i] << ' ' << (char)(i + 'a') << '\n';
- }
- for(int i = 0; i <= 30; i++)
- {
- if(a[i] == maxim)
- {
- maxim--;
- fout << cuv[i] << '\n';
- i = -1;
- }
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement