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<bits/stdc++.h>
#define int long long
#define pii pair<long long, long>
#define INF 10000000000000000
using namespace std;
signed main() {
int n;
cin >> n;
vector<int>v(n);
vector<int>next(n, -1);
map<int, int>mp;
for (int i = 0 ; i < n ; i++) {
cin >> v[i];
if (mp.find(v[i]) != mp.end()) {
next[mp[v[i]]] = i;
}
mp[v[i]] = i;
}
//for (int i = 0 ; i < n ; i++) cout << next[i] << " ";
//cout << "\n";
for (int i = 0 ; i < n ; i++) {
if (next[i] == -1) continue;
int j;
for (j = i+1 ; j <= next[i] ; j++) {
v[j] = v[i];
}
i = next[i]-1;
}
for (int i = 0 ; i < n ; i++) cout << v[i] << "\n";
//cout << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |