fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define in freopen("input.txt", "r", stdin);
  4. #define out freopen("output.txt", "w", stdout);
  5. #define clr(arr, key) memset(arr, key, sizeof arr)
  6. #define pb push_back
  7. #define mp(a, b) make_pair(a, b)
  8. #define infinity (1 << 28)
  9. #define LL long long
  10. #define PI acos(-1)
  11. #define gcd(a, b) __gcd(a, b)
  12. #define CF ios_base::sync_with_stdio(0);cin.tie(0);
  13. #define lcm(a, b) ((a)*((b)/gcd(a,b)))
  14. #define all(v) v.begin(), v.end()
  15. #define no_of_ones __builtin_popcount // __builtin_popcountll for LL
  16. #define SZ(v) (int)(v.size())
  17. #define eps 1e-7
  18.  
  19. //int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  20. //int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
  21. //int col[4] = {1, 0, -1, 0};
  22. //int row[4] = {0, 1, 0, -1};
  23. //int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};
  24.  
  25. using namespace std;
  26.  
  27. struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
  28. template <class T> T sqr(T a){return a * a;}
  29. template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
  30. template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));} // distance between a and b
  31. template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
  32. template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
  33. //LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
  34. struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;
  35.  
  36. #define MAX 200010
  37. /***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/
  38.  
  39. int main()
  40. {
  41. #ifdef Evan
  42. // in;
  43. // out;
  44. #endif
  45. int n;
  46. string line, words;
  47. set <string> myset;
  48. cin >> n;
  49. cin.ignore();
  50. while(n--)
  51. {
  52. getline(cin, line);
  53. stringstream ss(line);
  54. while(ss >> words)
  55. myset.insert(words);
  56. }
  57. for(auto x: myset)
  58. cout << x << "\n";
  59. return 0;
  60. }
  61.  
  62.  
Success #stdin #stdout 0s 3280KB
stdin
4
first sentence
another sentence
second sentence after first
last one
stdout
after
another
first
last
one
second
sentence