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 uwu return 0;
using namespace std;
const int SIZE = 2e5 + 5;
int arr[SIZE];
int N;
deque<pair<int, int>> stk;
set<int> color;
#define fs first
#define sc second
int main(){
cin.tie(0), ios::sync_with_stdio(0);
cin >> N;
for (int i = 0; i < N;i++){
cin >> arr[i];
}
for (int i = 0; i < N;i++){
if(color.count(arr[i])){
while(stk.back().sc != arr[i]){
color.erase(stk.back().sc);
stk.pop_back();
}
}
else{
color.insert(arr[i]);
stk.push_back({i, arr[i]});
}
}
for (int i = N - 1; i >= 0;i--){
while(i < stk.back().fs){
stk.pop_back();
}
arr[i] = stk.back().sc;
}
for (int i = 0; i < N;i++){
cout << arr[i] << '\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... |