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>
using namespace std;
void main_program();
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
main_program();
}
int n;
map<int, int> mp;
vector<int> v;
stack<int> st;
void main_program(){
cin >> n;
v.resize(n);
for (int i = 0; i < n; i++){
cin >> v[i];
if (mp[v[i]]){
while (!st.empty() && v[st.top()] != v[i]){
mp[v[st.top()]]--;
st.pop();
}
}
mp[v[i]]++;
st.push(i);
}
int crr = n;
while (!st.empty()){
for (int i = st.top(); i < crr; i++){
v[i] = v[st.top()];
}
crr = st.top();
st.pop();
}
for (int i = 0; i < n; i++) cout << v[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... |