#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];
}
vector<int> ans(n + 1);
map<int,int> M;
for(int i = 1; i <= n; i++) {
M[a[i]] = i;
}
int currentr = 0;
for(int i = 1; i <= n; i++) {
if(i == currentr + 1) {
currentr = M[a[i]];
}
ans[i] = a[currentr];
}
for(int i = 1; i <= n; i++) {
cout << ans[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... |