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;
const int N = 2e5 + 5;
map < int, int > p;
map < int, int > d;
int i,n,a[N],j;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie();
cin>>n;
for(i=1;i<=n;i++) cin>>a[i];
for(i=1;i<=n;i++)
if(p[a[i]]==0)
{
p[a[i]]=i;
}
else d[a[i]]=i;
/*for(i=1;i<=n;i++)
cout<<d[a[i]]<<" "<<p[a[i]]<<'\n';
*/
for(i=1;i<=n;i++)
if(d[a[i]]!=0)
{
for(j=i;j<=d[a[i]];j++)
a[j]=a[i];
i=d[a[i]];
}
for(i=1;i<=n;i++)
cout<<a[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... |