This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**********
the author:
shimutski_zoro
************ */
#include <bits/stdc++.h>
using namespace std;
#define yon(x) cout<<((x)?"Yes\n":"No\n");
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define em emplace_back
#define rep(i,j,k) for(int i=j;i<k;i++)
#define per(i,j,k) for(int i=k;i>=j;i--)
#define mem(a ,val) memset(a,val,sizeof val);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<double>vd;
template< typename T> void cmax(T&a,T &b){a=max(a,b);}
template< typename T> void cmin(T&a,T &b){a=min(a,b);}
const int mod=1e9+7;
const int N=1e6+1;
const ll inf=1e18;
void solve(){
ll n;
cin>>n;
vl a(n);
map<ll,ll>mp;
rep(i,0,n){cin>>a[i];mp[a[i]]=i;}
ll j=0;
while(j<n){
ll nxt=mp[a[j]]+1;
for(int i=j;i<nxt;i++){
a[i]=a[j];
}
j=nxt;
}
rep(i,0,n){
cout<<a[i]<<"\n";
}
}
signed main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef Usaco
string f = "milkvisits";
freopen((f+".in").c_str(),"r",stdin);
freopen((f+".out").c_str(),"w",stdout);
#endif
int t = 1;
//cin >> t;
while (t--)
{
solve();
cout<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |