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;
#define ll long long
int a[200001], b[200001];
map<int,int> mp;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i=1; i<=n; i++){
cin>>a[i];
mp[a[i]]++;
}
for(int i=1; i<=n; i++){
b[i]=a[i];
if(mp[a[i]]>=2){
int j=i;
i++;
while(a[i]!=a[j]){
b[i]=a[j];
mp[a[i]]--;
i++;
}
b[i]=a[i];
i--;
mp[a[j]]-=1;
}
}
for(int i=1; i<=n; i++){
cout<<b[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... |