Submission #913905

#TimeUsernameProblemLanguageResultExecution timeMemory
913905ReLiceStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
204 ms38332 KiB
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define vll vector<ll> #define bc back() #define arr array #define pll vector<pair<ll,ll>> using namespace std; template <class _T> bool chmin(_T &x, const _T &y){ bool f=0; if (x>y){x=y;f=1;} return f; } template <class _T> bool chmax(_T &x, const _T &y){ bool f=0; if (x<y){x=y;f=1;} return f; } //void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e18+7; const ll mod=1e9+7; const ll N=1e5+7; const ld eps=1e-9; void solve(){ ll i,j; ll n; cin>>n; vll v(n); map<ll,ll> mp; vector<ll> val; for(i=0;i<n;i++) { cin>>v[i]; if(mp[v[i]]==0) val.pb(v[i]); mp[v[i]]++; } sort(all(val)); for(i=0;i<n;i++){ v[i]=lb(all(val),v[i])-val.begin(); } vector<pair<ll,pair<ll,ll>>> ans; vector<vector<ll>> v2(n+5); for(i=0;i<n;i++){ ll l=i,r=i; if(v2[v[i]].sz){ while(ans.bc.fr!=v[i]){ v2[ans.bc.fr].pob; ans.pob; } l=ans.bc.sc.fr; v2[ans.bc.fr].pob; ans.pob; } ans.pb({v[i],{l,r}}); v2[v[i]].pb(i); } ll fin[n]; while(ans.sz){ for(i=ans.bc.sc.fr;i<=ans.bc.sc.sc;i++)fin[i]=ans.bc.fr; ans.pob; } for(i=0;i<n;i++) cout<<val[fin[i]]<<endl; } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; } /* */

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:46:10: warning: unused variable 'j' [-Wunused-variable]
   46 |     ll i,j;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...