This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main() {
int n, skip = -1;
cin >> n;
vector<int> a(n);
map<int,int> last;
for(int i = 0; i < n; i++) {
cin >> a[i];
last[a[i]] = max(last[a[i]], i);
}
for(int i = 0; i < n; i++) {
if(skip == -1) {
if(last[a[i]] != i) skip = last[a[i]];
cout << a[i] << "\n";
} else cout << a[skip] << "\n";
if(skip == i) skip = -1;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |