fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pb push_back
  5. #define nl '\n'
  6. #define py cout << "YES\n"
  7. #define pn cout << "NO\n"
  8. const double eps = 1e-7;
  9.  
  10. void fastio() {
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(nullptr);
  13. cout.tie(nullptr);
  14. }
  15.  
  16. void solve() {
  17. int n; cin >> n;
  18. vector<string>v(n),ans;
  19. for(auto &i:v) cin >> i;
  20. reverse(v.begin(),v.end());
  21.  
  22. for(int i=0;i<n;i++){
  23. if(find(ans.begin(),ans.end(),v[i]) == ans.end()) ans.pb(v[i]);
  24. }
  25.  
  26. for(auto i:ans) cout << i << nl;
  27. }
  28.  
  29. int main() {
  30. fastio();
  31. int t = 1;
  32. //cin >> t;
  33. while (t--)
  34. solve();
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0.01s 5312KB
stdin
4
alex
ivan
roman
ivan
stdout
ivan
roman
alex