# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955443 | Baytoro | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 235 ms | 16068 KiB |
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 ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define mp make_pair
#define ll long long
//#define int ll
#define double long double
const ll INF=1e18,N=1e6+5;
void solve(){
int n;cin>>n;
map<int,int> mpp;
vector<int> ans(n);
vector<pair<int,int> > st;
for(int i=0;i<n;i++){
int x;cin>>x;
if(mpp[x]>0){
while(!st.empty()){
if(st.back().fr==x) break;
mpp[st.back().fr]--;
st.pop_back();
}
}
st.pb(mp(x,i));
mpp[x]++;
}
st.pb(mp(-1,n));
for(int i=0;i<st.size()-1;i++){
int k=st[i].sc;
while(k<st[i+1].sc){
ans[k]=st[i].fr;
k++;
}
}
for(int i=0;i<n;i++) cout<<ans[i]<<'\n';
}
int main(){
solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |