fork download
  1.  
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #include <string>
  4. #include <algorithm>
  5. #include <iostream>
  6. #include<vector>
  7. #include<map>
  8. #include <stack>
  9. #include <deque>
  10. #include <cmath>
  11. #include <queue>
  12. #include <set>
  13. #include<unordered_map>
  14. using namespace std;
  15. typedef long long ll;
  16. typedef unsigned long long ull;
  17. typedef long double ld;
  18. typedef vector<int> vi;
  19. #define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  20. #define endl '\n'
  21. #define sz(s) (int)(s.size())
  22. #define all(s) s.begin(),s.end()
  23. #define allr(s) s.rbegin(), s.rend()
  24. #define exit(s) return cout<<s,0;
  25. #define watch(x) cout << (#x) << " = " << x << endl
  26. void file() {
  27. #ifndef ONLINE_JUDGE
  28. freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
  29. #endif
  30. }
  31.  
  32. int main() {
  33.  
  34. string s, x;
  35. set<string>st;
  36. while (getline(cin, s)) {
  37.  
  38. for (int i = 0; i < sz(s); i++)
  39. {
  40.  
  41. if (isalpha(s[i]) || s[i] == '-')
  42. {
  43. if (isalpha(s[i]))
  44. s[i] = tolower(s[i]);
  45. x += s[i];
  46.  
  47. }
  48.  
  49. else
  50. {
  51.  
  52.  
  53. if (s[i] == ' ')
  54. {
  55. if (x != "" && x != " ")
  56. {
  57. st.emplace(x);
  58.  
  59. }
  60. x = "";
  61.  
  62. }
  63. else
  64. {
  65.  
  66. x += s[i];
  67. }
  68.  
  69.  
  70. }
  71.  
  72.  
  73.  
  74. }
  75. if (x != "" && x != " ")
  76. {
  77. st.emplace(x);
  78. x = "";
  79. }
  80.  
  81. }
  82.  
  83. auto it1 = st.end();
  84. it1--;
  85.  
  86.  
  87. for (auto it : st)
  88. {
  89. if(isalpha(it[0]))
  90.  
  91. cout << it << endl;
  92.  
  93. }
  94.  
  95. }
Success #stdin #stdout 0s 4388KB
stdin
hihi hlsdj-ds - lskd
stdout
hihi
hlsdj-ds
lskd