Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- #define ALL(x) x.begin(),x.end()
- #define SZ(x) x.size()
- #define PB push_back
- #define MP make_pair
- #define F first
- #define S second
- typedef long long LL;
- typedef vector<int> VI;
- typedef pair<int,int> PI;
- int n,a[100];
- unordered_set<int> s;
- VI v;
- int main() {
- io;
- cin >> n;
- for(int i = 0; i < n; i++)
- cin >> a[i];
- for(int i = n-1; i >= 0; i--) {
- if(s.count(a[i]) == 0) {
- v.PB(a[i]);
- s.insert(a[i]);
- }
- }
- cout << SZ(v) << "\n";
- for(int i = SZ(v)-1 ; i >= 0; i--)
- cout << v[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment