#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
map<int,int> M;
M[a[1]] = 1;
for(int i = 2; i <= n; i++) {
if(M[a[i]]) {
for(int j = M[a[i]] + 1; j < i; j++) {
M[a[j]] = 0;
a[j] = a[i];
}
}
M[a[i]] = i;
}
for(int i = 1; i <= n; i++) {
cout << a[i] << " ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |