fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int a; cin>>a;
  5. stack<int> b;
  6. map<int,int> c;
  7. for(int i=0;i<a;i++){
  8. int x; cin>>x;
  9. if(!c[x]){
  10. b.push(x);
  11. c[x]=1;
  12. }
  13. }
  14. stack<int> d;
  15. while(!b.empty()){
  16. d.push(b.top());
  17. b.pop();
  18. }
  19. while(!d.empty()){
  20. cout<<d.top()<<" ";
  21. d.pop();
  22. }
  23. }
  24.  
Success #stdin #stdout 0s 5316KB
stdin
8
7 -6 4 -6 7 1 2 -6
stdout
7 -6 4 1 2