Submission #1062397

#TimeUsernameProblemLanguageResultExecution timeMemory
1062397yazanshStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
139 ms18456 KiB
/********** 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...